1 | initial version |
The process for testing an infinite stream using Jasmine Marbles has several steps:
import { TestScheduler } from 'rxjs/testing';
import { cold } from 'jasmine-marbles';
TestScheduler
class:const scheduler = new TestScheduler((actual, expected) => {
expect(actual).toEqual(expected);
});
cold
function from jasmine-marbles
. This function takes a string as its argument, representing the values emitted by the stream over time. For example:const input = cold('a-b-c-d-|');
cold
function:const expectedOutput = cold('a-b-c-d-|');
expectObservable
function:scheduler.expectObservable(input).toBe(expectedOutput);
scheduler.flush();
This will test whether the input stream emits the expected values at the expected times.