SpyNgModuleFactoryLoader

Stable

Class

What it does

Allows to simulate the loading of ng modules in tests.

How to use

  1. const loader = TestBed.get(NgModuleFactoryLoader);
  2. @Component({template: 'lazy-loaded'})
  3. class LazyLoadedComponent {}
  4. @NgModule({
  5. declarations: [LazyLoadedComponent],
  6. imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]
  7. })
  8. class LoadedModule {}
  9. // sets up stubbedModules
  10. loader.stubbedModules = {lazyModule: LoadedModule};
  11. router.resetConfig([
  12. {path: 'lazy', loadChildren: 'lazyModule'},
  13. ]);
  14. router.navigateByUrl('/lazy/loaded');

Class Overview

class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {
constructor(compiler: Compiler)
stubbedModules 
load(path: string) : Promise<NgModuleFactory<any>>

}

Class Description

Annotations

@Injectable()

Constructor

constructor(compiler: Compiler)

Class Details

exported from @angular/router/testing/index, defined in @angular/router/testing/router_testing_module.ts