我正在尝试使用 jasmine 测试一个具有以下构造函数的简单组件
constructor(public sanitizer: DomSanitizer) { }
在我的测试中,我有一个像
describe("Component: myComponent", () => {
let component: myComponent;
let fixture: ComponentFixture<myComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [FormsModule, CommonModule],
declarations: [myComponent],
}).compileComponents().then(() => {
fixture = TestBed.createComponent(myComponent);
component = fixture.componentInstance;
});
}));
});
我收到错误
失败:无法解析 myComponent 的所有参数
我已经尝试了一切。我遵循了关于这里的问题的建议Test pipe with dependencies on services和 import browserModule 而不是 CommonModule 都无济于事。请问我如何注入这种依赖关系?任何帮助,将不胜感激