#1537·RxJS

Spy on observables with Rx 5.5

Author: nivekcodeCreated Dec 20, 2017Updated Dec 20, 2017

Hi there

I am trying to use lettable operators in my project. The productive code works without problems but I am struggling with the tests. Inside my tests I want to use Jasmine Spy to be in control on what my Observable returns. With the old syntax I was able to write the following:

spyOn(Observable.prototype, 'switchMap').and.returnValue(Observable.of(myValue)) or spyOn(Observable, 'of').and.returnValue(Observable.of(myValue))

I thought that the same should look like the snippet below with the new syntax spyOn(ArrayObservable, 'of').and.returnValue(of('Superman')) Is this possible with lettable operators or is it generally a bad idea to test observable chains with the help of spies?

Source: Reactive-Extensions/RxJS