SpyNgModuleFactoryLoader

Stable Class

What it does

Allows to simulate the loading of ng modules in tests.

How to use

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');

Class Overview

class SpyNgModuleFactoryLoader {
  constructor(compiler: Compiler)
  
  
  stubbedModules : {[path: string]: any}
  load(path: string) : Promise<NgModuleFactory<any>>
}

Class Description

Annotations

@Injectable()

Constructor

constructor(compiler: Compiler)

Class Details

stubbedModules : {[path: string]: any}
load(path: string) : Promise<NgModuleFactory<any>>

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

doc_Angular
2016-10-06 09:47:04
Comments
Leave a Comment

Please login to continue.