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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

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

  const modClass = mod as Type;

  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 16 17, jasmine

MIT
Latest version published 12 days ago

Package Health Score

89 / 100
Full package analysis