Sets up the router to be used for testing.
beforeEach(() => { TestBed.configureTestModule({ imports: [ RouterTestingModule.withRoutes( [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}])] ) ] }); });
class RouterTestingModule { static withRoutes(routes: Routes) : ModuleWithProviders }
The modules sets up the router to be used for testing. It provides spy implementations of Location
, LocationStrategy
, and NgModuleFactoryLoader
.
@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, [UrlHandlingStrategy, new Optional()] ] }, {provide: PreloadingStrategy, useExisting: NoPreloading}, provideRoutes([]) ] })
withRoutes(routes: Routes) : ModuleWithProviders
exported from @angular/router/testing/index, defined in @angular/router/testing/router_testing_module.ts
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v2.angular.io/docs/ts/latest/api/router/testing/index/RouterTestingModule-class.html