I'm moderately new to RxJS and very new to unit testing with Jest and I've run into a pretty confusing problem when trying to test some mocked-up RxJS observables.
In order to mimic a data stream, I created an Observable in a test spec.js
file like this:
var Rx = require("rx");
var source = Rx.Observable.interval(500).take(10);
source.subscribe(
function(x){ console.log(x) },
function(e){ console.log(e) },
function(){ console.log('completed') }
);
Although this logs correctly when just ran as a node script, it doesn't log anything when ran through npm test
. The Observable.delay
and setTimeout
functions don't appear to work as well.