How to use the ng-mocks.MockHelper.findDirective 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 ike18t / ng-mocks / lib / mock-directive / mock-directive.spec.ts View on Github external
it('should display structural directive content', () => {
    const mockedDirective = MockHelper
    .findDirective(fixture.debugElement, ExampleStructuralDirective) as MockedDirective<ExampleStructuralDirective>;

    // structural directives should be rendered first.
    mockedDirective.__render();
    fixture.detectChanges();
    expect(mockedDirective.exampleStructuralDirective).toBeTruthy();

    const debugElement = fixture.debugElement.query(By.css('#example-structural-directive'));
    expect(debugElement.nativeElement.innerHTML).toContain('hi');
  });

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