I have the following test, it works...
import { TestScheduler } from 'rxjs/internal/testing/TestScheduler';
describe('RxJx', () => {
const testScheduler = new TestScheduler((actual, expected) => {
console.log('works here?');
console.log(actual);
console.log(expected);
expect(actual).toEqual(expected);
});
it('rxjs delay should work', () => {
testScheduler.run((helpers) => {
const {cold, expectObservable} = helpers;
const sequence1 = cold('-a--b--c---|', {a: 2, b: 2, c: 10});
// const sequence = '- 1ms a--b--c---|';
const sequence = '-a--b--c---|';
expectObservable(
// sequence1.pipe(delay(1))
sequence1
).toBe(sequence, {a: 2, b: 2, c: 10});
});
});
});
but as soon as I add a delay operator, the code stops working.
import { TestScheduler } from 'rxjs/internal/testing/TestScheduler';
import { delay } from 'rxjs';
describe('RxJx', () => {
const testScheduler = new TestScheduler((actual, expected) => {
console.log('works here?');
console.log(actual);
console.log(expected);
expect(actual).toEqual(expected);
});
it('rxjs delay should work', () => {
testScheduler.run((helpers) => {
const {cold, expectObservable} = helpers;
const sequence1 = cold('-a--b--c---|', {a: 2, b: 2, c: 10});
const sequence = ' 1s -a--b--c---|';
// const sequence = '-a--b--c---|';
expectObservable(
sequence1.pipe(delay(1000))
// sequence1
).toBe(sequence, {a: 2, b: 2, c: 10});
});
});
});
TestScheduler gets confusing result.
Please help me figure out what am I doing wrong?
If I do so, the tests pass...
const sequence1 = cold('-a--b--c', {a: 2, b: 2, c: 10});
const sequence = ' 1s -a--b--c';
Angular 15, build in test with RxJs