How to use the ng-mocks.MockDirective 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 / models / rendering.spec.ts View on Github external
it('finds mocked directives', () => {
      const {findDirective} = new Rendering(fixture, element, instance, {}, testSetup);

      expect(findDirective(DirectiveToMock) instanceof MockDirective(DirectiveToMock)).toBe(true);
    });
github T-Systems-MMS / phonebook / Phonebook.Frontend / src / app / pages / page-information / page-information.component.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [MatListModule, RouterTestingModule],
      declarations: [
        PageInformationComponent,
        MockComponent({ selector: 'mat-card' }),
        MockComponent({ selector: 'mat-card-title' }),
        MockComponent({ selector: 'mat-card-header' }),
        MockComponent({ selector: 'mat-card-content' }),
        MockComponent({ selector: 'mat-card-subtitle' }),
        MockDirective(FeedbackDrawerDirective)
      ],
      providers: [WINDOW_PROVIDER],
      schemas: [NO_ERRORS_SCHEMA]
    }).compileComponents();
  }));
github T-Systems-MMS / phonebook / Phonebook.Frontend / src / app / app.component.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [NgxsModule.forRoot([AppState]), HttpClientTestingModule, RouterTestingModule],
      declarations: [AppComponent, MockDirective(FeatureFlagDirective)],
      providers: [
        { provide: PersonService, useValue: null },
        { provide: SwUpdate, useValue: null },
        { provide: MailService, useValue: null },
        { provide: MatSnackBar, useValue: null },
        { provide: ServiceWorkerService, useValue: null },
        { provide: FeatureFlagService, useValue: null },
        { provide: MatDialog, useValue: null },
        { provide: I18n, useClass: MockI18nService },
        { provide: ThemeService, useValue: null }
      ],
      schemas: [NO_ERRORS_SCHEMA]
    }).compileComponents();
  }));
github getsaf / shallow-render / lib / models / rendering.spec.ts View on Github external
beforeEach(async () => {
    MockedDirective = MockDirective(DirectiveToMock);
    MockedStructuralDirective = MockDirective(StructuralDirectiveToMock);
    MockedComponent = MockComponent(ComponentToMock);
    testSetup = new TestSetup(OuterComponent, class {});
    testSetup.mockCache.add(DirectiveToMock, MockedDirective);
    testSetup.mockCache.add(ComponentToMock, MockedComponent);
    return TestBed.configureTestingModule({
      declarations: [
        TestHostComponent,
        OuterComponent,
        OtherComponent,
        InnerComponent,
        TestDirective,
        OtherDirective,
        MockedComponent,
        MockedDirective,
        MockedStructuralDirective
github T-Systems-MMS / phonebook / Phonebook.Frontend / src / app / pages / settings / settings.component.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({
      schemas: [NO_ERRORS_SCHEMA],
      declarations: [SettingsComponent, MockDirective(FeatureFlagDirective)],
      providers: [{ provide: ThemeService, useClass: MockThemeService }]
    }).compileComponents();
  }));
github ike18t / ng-mocks / e2e / context-with-directives / context-with-directives.spec.ts View on Github external
beforeEach((done) => {
    TestBed.configureTestingModule({
      declarations: [
        MockDirective(CustomTypeDirective),
        MockDirective(CustomRootComponent),
      ],
    }).compileComponents().then(done);
  });
github ike18t / ng-mocks / e2e / context-with-directives / context-with-directives.spec.ts View on Github external
beforeEach((done) => {
    TestBed.configureTestingModule({
      declarations: [
        MockDirective(CustomTypeDirective),
        MockDirective(CustomRootComponent),
      ],
    }).compileComponents().then(done);
  });
github ike18t / ng-mocks / examples / MockDirective-Attribute / MockDirective.spec.ts View on Github external
beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        TestedComponent,
        MockDirective(DependencyDirective),
      ]
    });

    fixture = TestBed.createComponent(TestedComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });
github getsaf / shallow-render / lib / models / rendering.spec.ts View on Github external
beforeEach(async () => {
    MockedDirective = MockDirective(DirectiveToMock);
    MockedStructuralDirective = MockDirective(StructuralDirectiveToMock);
    MockedComponent = MockComponent(ComponentToMock);
    testSetup = new TestSetup(OuterComponent, class {});
    testSetup.mockCache.add(DirectiveToMock, MockedDirective);
    testSetup.mockCache.add(ComponentToMock, MockedComponent);
    return TestBed.configureTestingModule({
      declarations: [
        TestHostComponent,
        OuterComponent,
        OtherComponent,
        InnerComponent,
        TestDirective,
        OtherDirective,
        MockedComponent,
        MockedDirective,
        MockedStructuralDirective
      ],
github intershop / intershop-pwa / src / app / shared / login / components / login-modal / login-modal.component.spec.ts View on Github external
beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [RouterTestingModule, TranslateModule.forRoot()],
      declarations: [
        LoginModalComponent,
        MockComponent(LoginFormContainerComponent),
        MockDirective(ServerHtmlDirective),
      ],
    }).compileComponents();
  }));

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 11 days ago

Package Health Score

89 / 100
Full package analysis