Jasmine: Mocking ViewChild component, Angular 2

Viewed 1025

I have Parent Component which has View child component associated with it. I'm trying to set up unit test for parent component but i'm not able to override the View Child component with mock class. I tried NO_ERRORS_SCHEMA, CUSTOM_SCHEMA in Schema provider and also used ng2-mock-component.

describe('Mobile Application Card:', () => {
  let comp: MobileAppCardComponent;
  let fixture: ComponentFixture<MobileAppCardComponent>;

  beforeEach(() => {

    const mock = MockComponent({ selector: 'bt-modal'}); // View Child Component. 
    TestBed.configureTestingModule({
      declarations: [MobileAppCardComponent, mock],
      providers: [{provide: MobileAppService, useValue: serviceStub},
                  {provide: ToastService, useValue: {}},
                  {provide: Router, userValue: null }
                 ]
    });
    fixture = TestBed.createComponent(MobileAppCardComponent);
  });
});

0 Answers
Related