• Overview
@angular/router/testing

RouterTestingHarness

Class

A testing harness for the Router to reduce the boilerplate needed to test routes and routed components.

  
    class RouterTestingHarness {
}

fixture

ComponentFixture<{ routerOutletData: WritableSignal<unknown>; }>

Fixture of the root component of the RouterTestingHarness

detectChanges

void

Instructs the root fixture to run change detection.

@returnsvoid

routeDebugElement

The DebugElement of the RouterOutlet component. null if the outlet is not activated.

routeNativeElement

HTMLElement | null

The native element of the RouterOutlet component. null if the outlet is not activated.

create

Creates a RouterTestingHarness instance.

The RouterTestingHarness also creates its own root component with a RouterOutlet for the purposes of rendering route components.

Throws an error if an instance has already been created. Use of this harness also requires destroyAfterEach: true in the ModuleTeardownOptions

@paraminitialUrlstring | undefined

The target of navigation to trigger before returning the harness.

@returnsPromise<RouterTestingHarness>
Jump to details