Static methods
|
static withRoutes(routes: Route[], config?: ExtraOptions): ModuleWithProviders<RouterTestingModule>
static withRoutes(routes: Route[], config?: ExtraOptions): ModuleWithProviders<RouterTestingModule>
Parameters
Returns
ModuleWithProviders<RouterTestingModule>
|
Providers
Provider |
ROUTER_PROVIDERS
ROUTER_PROVIDERS
|
{ provide: Location, useClass: SpyLocation }
|
{ provide: LocationStrategy, useClass: MockLocationStrategy }
|
{ provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader }
|
{
provide: Router,
useFactory: setupTestingRouter,
deps: [
UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,
ROUTES, ROUTER_CONFIGURATION, [ UrlHandlingStrategy, new Optional()]
]
}
{
provide: Router,
useFactory: setupTestingRouter,
deps: [
UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,
ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()]
]
}
|
{ provide: PreloadingStrategy, useExisting: NoPreloading }
|
provideRoutes([])
|
Usage notes
Example
beforeEach(() => {
TestBed.configureTestModule({
imports: [
RouterTestingModule.withRoutes(
[{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]
)
]
});
});
beforeEach(() => {
TestBed.configureTestModule({
imports: [
RouterTestingModule.withRoutes(
[{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]
)
]
});
});