Spy on the result of an Observable Subscription with Jasmine

前端 未结 3 910
粉色の甜心
粉色の甜心 2021-01-24 13:22

I am Jasmine unit testing an angular component, which uses Observables. My component has this lifecycle hook that I am testing:

ngOnInit() {
  this.dataService.ge         


        
3条回答
  •  生来不讨喜
    2021-01-24 13:45

    Instead of

    spyOn(service, 'getCellOEE').and.returnValue({ subscribe: () => { } });
    

    You could try

    spyOn(service, 'getCellOEE').and.returnValue( {subscribe: (callback) => callback()});
    

提交回复
热议问题