Allows to simulate the loading of ng modules in tests.
See more...
Description
const loader = TestBed.get(
NgModuleFactoryLoader);
@
Component({template: 'lazy-loaded'})
class LazyLoadedComponent {}
@
NgModule({
declarations: [LazyLoadedComponent],
imports: [RouterModule.forChild([{path: '
loaded', component: LazyLoadedComponent}])]
})
class LoadedModule {}
// sets up
stubbedModules
loader.stubbedModules = {lazyModule: LoadedModule};
router.resetConfig([
{path: 'lazy',
loadChildren: 'lazyModule'},
]);
router.navigateByUrl('/lazy/
loaded');
- const loader = TestBed.get(NgModuleFactoryLoader);
-
- @Component({template: 'lazy-loaded'})
- class LazyLoadedComponent {}
- @NgModule({
- declarations: [LazyLoadedComponent],
- imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
- })
-
- class LoadedModule {}
-
- // sets up stubbedModules
- loader.stubbedModules = {lazyModule: LoadedModule};
-
- router.resetConfig([
- {path: 'lazy', loadChildren: 'lazyModule'},
- ]);
-
- router.navigateByUrl('/lazy/loaded');