Stable Class
What it does
Sets up the router to be used for testing.
How to use
beforeEach(() => { TestBed.configureTestModule({ modules: [ RouterTestingModule.withRoutes( [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}])] ) ] }); });
Class Overview
class RouterTestingModule { staticwithRoutes(routes: Routes) : ModuleWithProviders }
Class Description
The modules sets up the router to be used for testing. It provides spy implementations of Location
, LocationStrategy
, and NgModuleFactoryLoader
.
Annotations
@NgModule({ exports: [RouterModule], providers: [ ROUTER_PROVIDERS, {provide: Location, useClass: SpyLocation}, {provide: LocationStrategy, useClass: MockLocationStrategy}, {provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader}, { provide: Router, useFactory: setupTestingRouter, deps: [ UrlSerializer, RouterOutletMap, Location, NgModuleFactoryLoader, Compiler, Injector, ROUTES ] }, provideRoutes([]) ] })
Static Members
withRoutes(routes: Routes) : ModuleWithProviders
exported from @angular/router/testing/index, defined in @angular/router/testing/router_testing_module.ts
Please login to continue.