• Overview
@angular/router/testing

RouterTestingModule

Class
deprecated

Sets up the router to be used for testing.

Deprecation warning

Use provideRouter or RouterModule/RouterModule.forRoot instead. This module was previously used to provide a helpful collection of test fakes, most notably those for Location and LocationStrategy. These are generally not required anymore, as MockPlatformLocation is provided in TestBed by default. However, you can use them directly with provideLocationMocks.

API

  
    class RouterTestingModule {}
  
  

withRoutes

ModuleWithProviders<RouterTestingModule>
@paramroutesRoutes
@paramconfigany

Description

Sets up the router to be used for testing.

The modules sets up the router to be used for testing. It provides spy implementations of Location and LocationStrategy.

Usage Notes

Example

beforeEach(() => {  TestBed.configureTestingModule({    imports: [      RouterModule.forRoot(        [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]      )    ]  });});
Jump to details