Within my Angular 4.0.0 application, I have a method called in my component.
This method is invoked within a service:
this.myService.myMethod(param).then(any => {
console.log("success case");
})
.catch(error => {
console.log("error");
});
As I am working on unit testing, I am isolating my component by mocking the service. I mock this method as follows:
myMethodSpy = spyOn(service, 'myMethod').and.callFake((reg) => {
return Observable.of('always error message');
});
However, when running the test, it seems that my spy method is not being called:
TypeError: this.service.myMethod(...).then is not a function
Do you have any insights on the root cause of this issue?