我有Parent Component
,其View child
组件与之关联。我正在尝试为parent component
设置单元测试,但我无法使用模拟类覆盖View Child
组件。我在架构提供程序中尝试了NO_ERRORS_SCHEMA
,CUSTOM_SCHEMA
,并使用了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);
});
});