Angular router
vitest-auto-spy/angular-router replaces ActivatedRoute, Router, and Location in tests. Use it when your component reads route params, requests navigation, or checks the URL, but you do not need to test routing itself.
import { TestBed } from '@angular/core/testing';
import { expect, it } from 'vitest';
import 'vitest-auto-spy/angular';
import { injectRouterDouble, provideActivatedRoute, provideRouterDouble } from 'vitest-auto-spy/angular-router';
import { ProfileComponent } from './profile.component';
it('opens orders for the user in the route', () => {
TestBed.configureTestingModule({
imports: [ProfileComponent],
providers: [provideActivatedRoute({ params: { id: '7' } }), provideRouterDouble()],
});
const fixture = TestBed.createComponent(ProfileComponent);
fixture.detectChanges();
fixture.componentInstance.openOrders();
expect(injectRouterDouble().navigate).toHaveBeenCalledWith(['/users', '7', 'orders']);
});In this example, ProfileComponent is standalone. It reads the string id from route.paramMap and calls Router.navigate() in openOrders(). The spy records the call and resolves true without moving the route. To change id in the same test, use injectActivatedRoute().
Import vitest-auto-spy/angular in the spec or your setup file to enable Vitest spies. Without a runner adapter, the Router double throws No mock adapter registered. Importing it in both places is harmless.
Use only the providers your component needs. A component that just reads route params needs provideActivatedRoute() alone.
| Your code uses | Provide | Drive it with |
|---|---|---|
ActivatedRoute | provideActivatedRoute() | injectActivatedRoute() |
Router | provideRouterDouble() | injectRouterDouble() |
Location | provideLocationDouble() | injectLocationDouble() |
| the order of router events | — | collectRouterEvents() |
any of the above, without TestBed | — | createActivatedRoute(), createRouterDouble(), createLocationDouble() |
Why not a hand-written ActivatedRoute
ActivatedRoute keeps what a component reads (snapshot, params, queryParams, data, fragment, url) in instance fields. The usual hand-written mocks cover only part of it:
| Mock | What breaks |
|---|---|
provideAutoSpy(ActivatedRoute) | no snapshot, no params: a spy is built from the prototype, not fields |
{ provide: ActivatedRoute, useValue: { snapshot: { params } } } | route.paramMap is undefined, so route.paramMap.pipe(…) throws |
{ provide: ActivatedRoute, useValue: { params: of({ id }) } } | snapshot is undefined, and a second navigation cannot be tested |
| both halves, written by hand | they drift apart as soon as a spec updates one and forgets the other |
The stand-in here is a real Angular ActivatedRoute. Its streams and its snapshot come from one record, so they always agree.
provideActivatedRoute(init?)
Provides an ActivatedRoute with the values you pass. Use it in providers of the testing module.
TestBed.configureTestingModule({
imports: [ProfileComponent],
providers: [
provideActivatedRoute({
params: { id: '7' },
queryParams: { tab: 'orders' },
data: { user: ada },
fragment: 'contacts',
url: 'users/7',
}),
],
});init member | Type | Default | What it sets |
|---|---|---|---|
params | Params | {} | params, paramMap, snapshot.params, snapshot.paramMap |
queryParams | Params | {} | queryParams, queryParamMap and their snapshot versions |
data | Data | {} | data, snapshot.data |
title | string | undefined | route.title, snapshot.title |
fragment | string | null | null | fragment, snapshot.fragment |
url | string | UrlSegment[] | [] | url, snapshot.url; a string is split on / |
outlet | string | 'primary' | outlet, snapshot.outlet |
component | Type | null | null | component, snapshot.component |
routeConfig | Route | null | null | routeConfig, snapshot.routeConfig |
resolve | ResolveData | {} | the snapshot's resolve record, kept apart from data as Angular keeps it |
children | ActivatedRouteInit[] | [] | children, firstChild, and each child's parent and root |
resources | the route's resources record | undefined | resources, snapshot.resources; Angular 22.2+ only (developer preview) |
Child routes. Each entry in children becomes a child route built from the same options. The handle's children array has a setter handle for each child; change a child through it, and the parent's snapshot tree updates too:
const { route, children } = createActivatedRoute({
children: [{ outlet: 'aside', routeConfig: { path: 'map' } }],
});
children[0]?.setParams({ id: '8' }); // route.snapshot.firstChild.params is now { id: '8' }Resources. For a component that reads route.resources, pass an empty record and install each resource with mockResourceProp. The route and every snapshot share that one record. restoreMockedProps() removes the stand-in.
const resources = {};
TestBed.configureTestingModule({ providers: [provideActivatedRoute({ resources })] });
const user = mockResourceProp(resources, 'user', undefined as User | undefined, { status: 'loading' });
user.set({ name: 'Ada' });Matrix parameters. A string url has none. Pass UrlSegments when the code reads them: url: [new UrlSegment('users', { role: 'admin' })].
Sharing providers between tests is safe. Each test gets a fresh route, even when you keep the provider list in a constant at the top of the file.
With Angular's real router, list it last
Angular's real provideRouter() and RouterModule also provide an ActivatedRoute, and the later provider wins, so put provideActivatedRoute() after them. If you do not, injectActivatedRoute() throws and says which route it found instead. provideRouterDouble() provides no ActivatedRoute, so with the Router stand-in the order does not matter.
injectActivatedRoute(injector?)
Use this handle to change the route after creating the component. To extend the first example, add injectActivatedRoute to its imports and put this code after the first assertion:
injectActivatedRoute().setParams({ id: '8' });
fixture.detectChanges();
fixture.componentInstance.openOrders();
expect(injectRouterDouble().navigate).toHaveBeenLastCalledWith(['/users', '8', 'orders']);When the params change, setParams() updates the snapshot and notifies params and paramMap subscribers right away. Call detectChanges() to refresh the view. If the component saved the old id from route.snapshot, that saved value stays the same.
The handle contains the route and its setters. By default, it reads from TestBed. If the component provides the route itself, pass fixture.debugElement.injector.
| Member | What it does |
|---|---|
route | the ActivatedRoute every injector in the test hands out |
setParams(params) | replaces the params |
setQueryParams(params) | replaces the query params |
setData(data) | replaces the data |
setFragment(fragment) | replaces the fragment; null means none |
setUrl(url) | replaces the URL segments; a string or UrlSegment[] |
set(change) | several of the above as one navigation: one new snapshot, each stream emits at most once |
children | handles of the child routes from init.children, in order |
Each change behaves like the router's own update after a navigation:
The snapshot changes first. A
paramssubscriber that readsroute.snapshotalready sees the new values. Each change creates a new snapshot object, so a snapshot you saved earlier keeps the old values.Streams emit in the router's order:
queryParams,fragment,params,url,data.An equal value emits nothing. Setting
{ id: '7' }when the id is already'7'emits nothing. Equal means the same keys (symbol keys too) and===values; an array value (?tag=a&tag=b) is compared regardless of order. A stringurlalways builds new segments, so it always emits.A setter replaces, it does not merge. To keep the old values, spread them from the handle's
route:tsconst { route, setQueryParams } = injectActivatedRoute(); setQueryParams({ ...route.snapshot.queryParams, page: '2' });
createActivatedRoute(init?)
The same route without TestBed. Use it for a class you create with new, or for a functional guard or resolver that takes the route as an argument. It takes the same init as provideActivatedRoute() and returns the same handle.
import { createActivatedRoute } from 'vitest-auto-spy/angular-router';
const { route, setParams } = createActivatedRoute({ params: { id: '7' } });
const page = new ProfilePage(route);
setParams({ id: '8' });
expect(page.userId()).toBe('8');The setters are plain functions, so you can destructure them.
Angular's own route, checked against Angular
route instanceof ActivatedRouteandroute.snapshot instanceof ActivatedRouteSnapshotare both true. The library's own tests compare its keys with a realnew ActivatedRoute(), so a member that a future Angular adds is there too.Without
children, the route sits in a tree of one node, so tree getters return values instead of throwing:rootis the route itself,parentandfirstChildarenull,childrenis empty, andpathFromRootis[route]. The snapshot answers the same way.The real
Routeraccepts it as a real route:tsTestBed.configureTestingModule({ providers: [provideRouter([]), provideActivatedRoute({ url: 'users/12' })] }); const router = TestBed.inject(Router); router.serializeUrl(router.createUrlTree(['orders'], { relativeTo: injectActivatedRoute().route })); // → '/users/12/orders'
If a future Angular builds its routes differently, the first provideActivatedRoute() throws and names the member that came out wrong.
What it deliberately does not do
- No parent route and no tree from a config. The route you build is the root, so
route.parentisnull. If a component readsroute.parent.params, patch that member withmockReadonlyProp, or use a real router withRouterTestingHarness. Child routes come only fromchildren; arouteConfig.childrenarray does not create routes. titleis a plain string.provideActivatedRoute({ title: 'User 7' })setsroute.snapshot.title. Atitle: () => …resolver onrouteConfigis not run; pass the final string.resourcesis a plain record. Aresources: (ctx) => …function onrouteConfigis not run. Pass the record the component reads, and drive each resource withmockResourceProp. No setter changes it: the router keeps one record for the route's life.navigate()does not move this route. Assert thenavigate()call on the Router stand-in and move the route with the setters. To test real routing (guards, resolvers, redirects), use Angular'sRouterTestingHarness.- No input binding.
withComponentInputBinding()is the outlet's job. Set the input yourself:fixture.componentRef.setInput('id', '7').
What each failure says
| Message contains | Cause and fix |
|---|---|
injectActivatedRoute(): nothing provides ActivatedRoute here | no provider at all; add provideActivatedRoute({ … }) to providers |
the ActivatedRoute here is … not one provideActivatedRoute() built | a later provider won (provideRouter(), RouterModule, a useValue, provideAutoSpy); list this one last |
@angular/router <version> does not wire ActivatedRoute … | this router version builds its classes differently; provide the route by hand and report the version |
provideActivatedRoute({ title }): … keeps the route title under a key this helper could not find | this router version stores the title elsewhere; leave title out and report the version |
The Router double
provideRouterDouble(init?)
Provides a Router stand-in. navigate() and navigateByUrl() are spies, and url, routerState and events always agree with each other.
import { TestBed } from '@angular/core/testing';
import 'vitest-auto-spy/angular';
import { injectRouterDouble, provideRouterDouble } from 'vitest-auto-spy/angular-router';
import { ProfileComponent } from './profile.component';
it('goes to checkout', async () => {
TestBed.configureTestingModule({
imports: [ProfileComponent],
providers: [provideRouterDouble({ url: '/users/7' })],
});
const fixture = TestBed.createComponent(ProfileComponent);
const router = injectRouterDouble();
await fixture.componentInstance.checkout();
expect(router.navigate).toHaveBeenCalledWith(['/checkout']);
router.emitNavigation('/users/8'); // synchronous; events emits a NavigationEnd; router.url is '/users/8'
fixture.detectChanges();
});navigate() and navigateByUrl() are Vitest vi.fn() spies. To build them, the library needs import 'vitest-auto-spy/angular' (or 'vitest-auto-spy') somewhere in the test run. Import it once, in the spec or in the setup file. Without it, the first provideRouterDouble() throws No mock adapter registered and names the import.
init member | Type | Default | What it sets |
|---|---|---|---|
url | string | '/' | where the router stands; routerState and events follow from it |
navigated | boolean | true | whether a navigation has finished; use false before initial navigation |
currentNavigation | NavigationInit | null | null | a navigation in flight, for a component that reads it in a field initializer |
children | ActivatedRouteInit[] | none | routes under routerState.root, nested as deep as you need |
children is for code that walks routerState.root.children to find open outlets. setUrl() keeps them:
provideRouterDouble({
url: '/cards/7',
children: [{ routeConfig: { path: 'cards' }, children: [{ outlet: 'report' }, { outlet: 'map' }] }],
});What the stand-in's members are:
| Member | What it is |
|---|---|
url | the URL, serialized like the real router's: setUrl('users/7') reads back /users/7 |
events | a BehaviorSubject replaying the starting NavigationEnd; with navigated: false, a Subject that starts empty |
navigate, navigateByUrl | spies that resolve true and record the call; they do not change the URL |
serializeUrl, parseUrl | Angular's own DefaultUrlSerializer |
createUrlTree | builds a URL tree using relativeTo, queryParamsHandling and preserveFragment without navigating |
routerState | Angular's own RouterState: snapshot.url is the URL; root carries its query params and fragment |
currentNavigation | the navigation in flight (Angular 20.2+ signal), null while the router is idle |
navigated | true after a completed navigation; updated before subscribers receive NavigationEnd |
isActive(url, options) | Angular URL matching, including exact/subset paths, query parameters, matrix parameters and fragments |
lastSuccessfulNavigation | the last successful navigation and its finalUrl: a signal on Angular 21+, a value on Angular 20; follows setUrl() and NavigationEnd |
getCurrentNavigation() | the same answer through the deprecated method |
Query-only URLs. Call createUrlTree() with an empty command list ([]) and omit relativeTo to keep the current path. Set queryParamsHandling: 'merge' to keep any parameters you don't mention. Passing null or undefined for a parameter removes it from the new URL.
import { expect } from 'vitest';
import 'vitest-auto-spy/angular';
import { createRouterDouble } from 'vitest-auto-spy/angular-router';
const { router } = createRouterDouble({ url: '/products?tab=old&page=2&sort=asc' });
const tree = router.createUrlTree([], {
queryParamsHandling: 'merge',
queryParams: { tab: null, page: undefined },
});
expect(router.serializeUrl(tree)).toBe('/products?sort=asc');Active links. The real RouterLink and RouterLinkActive directives work with this double. RouterLink also injects ActivatedRoute, so add provideActivatedRoute() next to it. routerLink="/products" is active on /products and on any URL below it, such as /products/7. The directive sets its class in a microtask, so await fixture.whenStable() before you check it:
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { RouterLink, RouterLinkActive } from '@angular/router';
import 'vitest-auto-spy/angular';
import { injectRouterDouble, provideActivatedRoute, provideRouterDouble } from 'vitest-auto-spy/angular-router';
@Component({
imports: [RouterLink, RouterLinkActive],
template: `<a routerLink="/products" routerLinkActive="active">Products</a>`,
})
class NavComponent {}
it('marks the link of the current section active', async () => {
TestBed.configureTestingModule({
imports: [NavComponent],
providers: [provideRouterDouble({ url: '/products/7' }), provideActivatedRoute()],
});
const fixture = TestBed.createComponent(NavComponent);
fixture.detectChanges();
await fixture.whenStable();
const link: HTMLAnchorElement = fixture.nativeElement.querySelector('a');
expect(link.classList).toContain('active');
await injectRouterDouble().emitNavigation('/checkout');
fixture.detectChanges();
await fixture.whenStable();
expect(link.classList).not.toContain('active');
});Before the first navigation. By default the double has already navigated: navigated is true and lastSuccessfulNavigation holds the starting URL. To test an app that has not navigated yet, pass { navigated: false }. Then navigated is false, lastSuccessfulNavigation is null and events replays nothing. RouterLinkActive adds no class until navigated is true, even when url matches the link. An emitNavigation() that ends in NavigationEnd sets navigated and lastSuccessfulNavigation before subscribers see the event:
const { router, emitNavigation } = createRouterDouble({ navigated: false });
expect(router.navigated).toBe(false);
expect(router.lastSuccessfulNavigation()).toBeNull();
await emitNavigation('/products');
expect(router.navigated).toBe(true);
expect(router.lastSuccessfulNavigation()?.finalUrl?.toString()).toBe('/products');lastSuccessfulNavigation is a signal on Angular 21+ and a plain value on Angular 20. The example uses the signal.
Any other Router member (resetConfig, initialNavigation, …) throws when read. The error names the member and lists what the stand-in covers. You get a clear failure instead of a silent undefined.
The stand-in is not an instance of Angular's Router class: a real Router pulls in the whole routing stack. It is an object provided for the Router token.
Common mistake: the hand-written createAutoMock<Router>({ events: of(), url: '/' }, { returns: { navigate: Promise.resolve(true) } }) breaks quietly. of() never emits again, url never changes, routerState is missing, and serializeUrl throws when a guard builds a redirect. Use provideRouterDouble() instead.
injectRouterDouble(injector?)
Returns the handle you use to drive the router in a test. By default it reads from TestBed. If the router is in the component's own providers, pass fixture.debugElement.injector.
const router = injectRouterDouble();
router.setUrl('/users/8?tab=orders');
router.navigate.resolveWith(false); // the next navigate() resolves false| Member | What it does |
|---|---|
router | the value every injector in the test hands out for Router |
navigate | the navigate() spy: assert on it, or answer with resolveWith(false) |
navigateByUrl | the navigateByUrl() spy, the same way |
setUrl(url) | moves the router to a URL; url, routerState and the root route change together, with no event |
emitNavigation(event?) | pushes an event through router.events; returns a promise |
setCurrentNavigation(navigation?) | puts a navigation in flight, or ends it with null |
emitNavigation() accepts:
- nothing: announces the current URL again;
- a URL string: builds a
NavigationEndfor it; - any router event you build, such as
new NavigationEnd(1, '/a', '/a')ornew NavigationStart(1, '/a').
A NavigationEnd moves the URL, as the real router's does. Other events leave the URL alone.
The work is synchronous, so a spec does not need await: the next line already sees the new state. The promise exists for code under test that awaits a navigation. It resolves once the event is delivered and any navigation it ended is cleared.
By default events is a BehaviorSubject, not a plain Subject like the real router's. With { navigated: false } it is a plain Subject. With the default, two things follow:
- A late subscriber still sees the last navigation. It no longer matters whether
emitNavigation()runs before or afterfixture.detectChanges(). - A subscriber first receives the
NavigationEndfor the starting URL. A component that counts navigations starts at one, not zero.
The navigation in flight
Components read currentNavigation() to learn where a navigation came from: the extras.state the caller passed, or the trigger ('popstate' versus a click). Set it with setCurrentNavigation():
const router = injectRouterDouble();
router.setCurrentNavigation({ extras: { state: { from: 'the card' } } });
expect(fixture.componentInstance.origin()).toBe('the card');- It answers
nulluntil you set it, as a real idle router does. - What you pass is kept. The rest is filled from the current URL:
id,initialUrl,extractedUrl;triggeris'imperative',extrasis empty,previousNavigationisnull. abortdefaults to a no-op. Pass your own when the spec asserts it.
It also follows the events, as the real router does:
emitNavigation(new NavigationStart(4, '/users/8', 'popstate'))puts a navigation in flight with that id, URL and trigger.- A
NavigationEnd,NavigationCancel,NavigationErrororNavigationSkippedends it, after the event is delivered. A component that readscurrentNavigation()while handlingNavigationEndstill sees the finished navigation, as in production. See In depth for why.
createRouterDouble(init?)
The same Router stand-in without TestBed, for a guard or a class you create with new:
import 'vitest-auto-spy/angular';
import { createRouterDouble } from 'vitest-auto-spy/angular-router';
const { router, navigate } = createRouterDouble({ url: '/admin' });
expect(new AuthGuard(router).canActivate()).toBe(false);
expect(navigate).toHaveBeenCalledWith(['/login']);What the Router double does not do
- It does not navigate.
navigate()andnavigateByUrl()record the call and resolvetrue;urlstays where it was. Move it withsetUrl()oremitNavigation(). To test the navigation itself (guards, cancellation), useRouterTestingHarnessover a realprovideRouter(). - It is only the
Routertoken. No routes and no outlet.routerLinkandrouterLinkActivein the template still work, becausecreateUrlTree,serializeUrlandisActiveare the router's own. When the spec is about routing rather than a component, use the real router. - It does not provide the component's
ActivatedRoute. A component that reads route params and callsnavigate()needs bothprovideActivatedRoute()andprovideRouterDouble(), in any order. The stand-in'srouterState.roothas the URL's query params and fragment, but no params.
What each Router failure says
| Message contains | Cause and fix |
|---|---|
the Router double has no … | the code under test used a Router member the stand-in does not cover |
the Router here is Angular's own, not one provideRouterDouble() built | Router is providedIn: 'root', so TestBed without the stand-in gives a real one; add provideRouterDouble() |
the Router here is a value written by hand … | a useValue or provideAutoSpy(Router) won; list provideRouterDouble() last |
nothing provides Router in the injector given | an injector you built by hand has no Router at all |
The order of provideRouterDouble() and a real provideRouter() does not matter: provideRouter() does not provide the Router token, so the stand-in always wins.
collectRouterEvents(events)
Records every router event from now until the test ends, then checks the sequence in one call.
import { NavigationEnd, NavigationStart } from '@angular/router';
import { collectRouterEvents, injectRouterDouble } from 'vitest-auto-spy/angular-router';
const router = injectRouterDouble();
const events = collectRouterEvents(router.router.events);
await router.emitNavigation(new NavigationStart(2, '/checkout'));
await router.emitNavigation('/checkout');
events.expect([
[NavigationStart, '/checkout'],
[NavigationEnd, '/checkout'],
]);- The recording starts empty. The
NavigationEndaBehaviorSubjectreplays on subscribe is not recorded. expect()takes one[EventClass, url?]pair per event, in order, with nothing left over.events.eventsis the raw recording, for checks that are not a plain sequence.- The recording ends with the test that started it, on Vitest and Bun.
A mismatch fails with one message: where the sequences first differ, then both in full.
[vitest-auto-spy] collectRouterEvents().expect(): the events differ at #2: expected NavigationEnd /checkout, got NavigationCancel /checkout.
Expected: NavigationStart /checkout, NavigationEnd /checkout
Recorded: NavigationStart /checkout, NavigationCancel /checkoutThe Location double
Provides Angular's own SpyLocation for Location, so you can check where a redirect landed or what the back button did.
import { TestBed } from '@angular/core/testing';
import { injectLocationDouble, provideLocationDouble } from 'vitest-auto-spy/angular-router';
TestBed.configureTestingModule({ providers: [provideLocationDouble()] });
const location = injectLocationDouble();
location.go('/reports/7');
expect(location.urlChanges).toEqual(['/reports/7']);
location.simulateUrlPop('/'); // a browser back/forward, which no method call can cause| Helper | What it does |
|---|---|
provideLocationDouble() | provides SpyLocation and MockLocationStrategy in one line |
injectLocationDouble(injector?) | returns that SpyLocation; throws if another Location provider won |
createLocationDouble() | the same SpyLocation without TestBed |
What SpyLocation gives you:
go(),back()andhistoryGo()move a real history;path()andgetState()read it back.urlChangeslists every move the app asked for.simulateUrlPop()andsimulateHashChange()fire the events that only the browser causes.back()andforward()notify popstate subscribers but do not add tourlChanges. The list holds what the app asked for; subscribers get what the browser did.
One difference from Angular's SpyLocation. Angular's SpyLocation.path() drops the query. The real Location.path() keeps it, and so does this one: after go('/reports', 'tab=7'), path() returns /reports?tab=7. isCurrentPathEqualTo(path, query) and the popstate url agree with it. The object is still a SpyLocation.
Common mistake: skipping the provider. Location is providedIn: 'root', so a spec without provideLocationDouble() gets the real platform Location, and nothing the test does is recorded. A hand-written { provide: Location, useValue: { path: vi.fn() } } has the opposite problem: it answers only the members its author thought of.
| Message contains | Cause and fix |
|---|---|
injectLocationDouble(): nothing provides Location here | no provider; add provideLocationDouble() to providers |
the Location here is … not the SpyLocation | a later Location provider won; list provideLocationDouble() last |
Its own entry, and an optional peer
vitest-auto-spy/angular-routeris the only entry that imports@angular/router. So@angular/routeris an optional peer dependency: you install it only if you import this entry.vitest-auto-spy/angular-httpworks the same way for@angular/common.- The Location stand-in needs no extra package. It wraps
@angular/common/testing, and@angular/routeralready depends on@angular/common. - It does not re-export the core. Import it next to
vitest-auto-spy/angular. - It registers no hooks and no runner adapter. The Router stand-in's spies need
vitest-auto-spy/angular, as described underprovideRouterDouble(). - It does not import
vitest.collectRouterEvents()stops recording when its test finishes, through the runner's ownonTestFinished(Vitest or Bun). Onnode:test, which has no per-test teardown, the recording lasts as long as the Router stand-in. - Its type declarations do not name
vitesteither, so a Bun ornode:testproject type-checks it withskipLibCheck: falseand no Vitest installed.
In depth
Why currentNavigation clears after the event, not before. Angular's doc comment says "the current navigation becomes to null after the NavigationEnd event is emitted". The router emits the final event from a tap while the navigation is still in flight, and clears it in a finalize after that (cancelNavigationTransition never clears it). events is a Subject, so a synchronous subscriber runs between the two steps. It gets the finished navigation, and null only after navigate() resolves. This was checked against a real provideRouter() on Angular 22. A stand-in that cleared it first would break the common pattern "read the navigation state when the navigation lands".
Why unknown Router members throw. currentNavigation, config and routeReuseStrategy live on the Router instance, not on Router.prototype. A mock built from the prototype would return undefined for them, and router.currentNavigation() would then fail as "is not a function" far from the cause. The stand-in throws on read instead, with the member's name.
Why currentNavigation is hard to mock by hand. It is a signal on the instance, not on the prototype, so nothing reads it off the class. A hand-written mock has to list it with instanceMethodsToSpyOn: ['currentNavigation'].
How the route is built. Every stream is a BehaviorSubject over one field of a single record. The snapshot is Angular's own ActivatedRouteSnapshot of the same record, and both ParamMaps are the ones Angular derives from them. There is no second copy to fall out of step. The title goes into data under the router's RouteTitleKey, a symbol the router does not export; the stand-in learns it from the installed router. The package's CI builds the route on every Angular major it supports.