我将如何继续为以下组件运行 jasmine 测试:
@Component({
moduleId: module.id,
selector: "testComp",
template: "<div>{{value}}</div>",
})
export class TestComp {
public value: string = "This is me";
constructor(public zone: NgZone) {
this.zone.run(() => console.log("zone is here"));
}
}
以下失败并显示无法解析 NgZone 的所有参数:
describe("test", () => {
let fixture;
let component;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TestComp],
schemas: [NO_ERRORS_SCHEMA],
providers: [NgZone]
}).compileComponents;
}));
beforeEach(() => {
fixture = TestBed.createComponent(TestComp);
component = fixture.debugElement.componentInstance;
});
it("should check that the component is created", () => {
expect(component).toBeTruthy();
});
})
使用 Angular 4.1.3。我找到了 MockNgZone 类 @ https://no-shadow-angular-io.firebaseapp.com/docs/ts/latest/api/core/testing/MockNgZone-class.html。但在这个特定版本的@angular/core/testing 中似乎不可用:
有人知道我应该怎么做来测试这个组件吗?
问候