DEV Community

Discussion on: How I Write Marble Tests For RxJS Observables In Angular

Collapse
 
anduser96 profile image
Andrei Gatej

You can avoid to explicitly specify the scheduler by running your tests inside TestScheduler.run(cb). TestScheduler.run will replace the AsyncScheduler with TestScheduler.

const testScheduler = new TestScheduler((actual, expected) => {})

testScheduler.run(({ cold, hot, expectObservable }) => {
 const src$ = interval(1000).pipe(take(3));
 const expected = '1000ms 0 999ms 1 999ms (2|)';

 expectObservable(src$).toBe(expected);
});