How to use the ng-mocks.MockOf function in ng-mocks

To help you get started, we’ve selected a few ng-mocks examples, based on popular ways it is used in public projects.

github getsaf / shallow-render / lib / tools / mock-module.ts View on Github external
throw new InvalidModuleError(mod);
  }

  const modClass = mod as Type<any>;

  const {imports, declarations, exports, entryComponents, providers, schemas} = getNgModuleAnnotations(modClass);
  const mockedModule: NgModule = {
    imports: ngMock(imports, setup),
    declarations: ngMock(declarations, setup),
    exports: collapseModuleWithProviders(ngMock(exports, setup)),
    entryComponents: ngMock(entryComponents, setup),
    providers: providers.map(p => mockProvider(p, setup)),
    schemas,
  };
  @NgModule(mockedModule)
  @MockOf(modClass)
  class MockModule {}

  return setup.mockCache.add(mod, MockModule) as TModule;
}

ng-mocks

An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests. It provides shallow rendering, precise stubs to fake child dependencies. ng-mocks works with Angular 5 6 7 8 9 10 11 12 13 14 15, jasmine and j

MIT
Latest version published 4 days ago

Package Health Score

89 / 100
Full package analysis

Similar packages