I made a simple app
which is running correctly.
Now I am trying to write test cases of that application, so I tried with routing
.
stackblitz
My routing code is this
Main module:
export const routes: Routes = [
{ path: '', redirectTo: '/users', pathMatch: 'full' },
];
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
UserModule,
HttpClientModule,
RouterModule.forRoot(routes)
],
Feature module:
const routes: Routes = [
{path: 'users', component: ListingComponent}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes)
],
declarations: [ListingComponent]
})
Code
I try to run my spec
but I am getting above error
describe('Initial navigation', () => {
it('default route redirects to home (async)', fakeAsync(() => {
router.initialNavigation(); // triggers default
fixture.detectChanges();
tick();
console.log('==================');
console.log(location.path());
// fixture.whenStable().then(() => {
expect(location.path()).toBe('/users');
// })
}));
});