我在TestBed中注入了服务,这意味着在我的控件之外调用构造函数方法。那么我在哪里/如何建立一个间谍?
describe('MySvc', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
MySvc,
spyOn(MySvc, "methodcalledinconstructor")
]
});
});
it("should test all aspects of the service",
inject([MySvc], fakeAsync((mySvc) => {
expect(mySvc.methodcalledinconstructor).toHaveBeenCalled();
// the above check fails! Help me here.
}));
});
});