1

我在 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.

         }));    
     });
 });
4

0 回答 0