Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.49k stars 2.1k forks source link

Spy on observables with Rx 5.5 #1537

Open kreuzerk opened 6 years ago

kreuzerk commented 6 years ago

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?