spyOn could not find an object to spy upon for start()
问题 I am using angular-cli testing framework. inside my component , I have used 'ng2-slim-loading-bar' node module. submit(){ this._slimLoadingBarService.start(() => { }); //method operations } Now when I am testing this component, I have applied spyOn this service as : beforeEach(() => { let slimLoadingBarService=new SlimLoadingBarService(); demoComponent = new DemoComponent(slimLoadingBarService); TestBed.configureTestingModule({ declarations: [ DemoComponent ], providers: [ { provide: