它对我不起作用的原因是我打过电话
TestBed.overrideComponent()
之后
compileComponents()
.
正确的顺序是:
TestBed.configureTestingModule({
declarations: [IFrameComponent]
}).overrideComponent(IFrameComponent, {
remove: {
templateUrl: './iframe.component.html'
},
add: {
template: '<div data-test-iframe="iframe"></div>'
}
}).compileComponents();
fixture = TestBed.createComponent(IFrameComponent);