How to write test case for lazy loaded routes whose path is declared inside Children Branch to get 100% code coverage?

Viewed 9
  {
    path: '',
    children: [
      {
        path: 'dashboard',
        loadChildren: () =>
          import('./modules/dashboard/dashboardv10.module').then((m) => m.Dashboardv10Module),
      }
    ],
  }

I have written test case for above lazy loaded routes and it is successfully passing but the problem is that it is not showing in the code coverage. Since the route is declared inside the children properties. It is not able to recognize.

it('Should lazzily navigate to Dashboard Component', fakeAsync(() =>{
    const loader = TestBed.inject(SpyNgModuleFactoryLoader);
    loader.stubbedModules = {lazyModule: Dashboardv10Module };
    router.navigateByUrl('/dashboard');

    tick();
    fixture.detectChanges();
    expect(location.path()).toEqual('/dashboard');
}));

This test case is successfully running everywhere except for above mention route because of the children property.

this is not covering function test. Please Help!

0 Answers
Related