rxjs
rxjs copied to clipboard
Marble testing of interval with shareReplay pipe crashes the test
Describe the bug
I made a copy of the test from Rxjs marble-testing examples (one with interval) and added shareReplay pipe to interval. It broke test, which never completes and sometimes even crashes my browser.
Expected behavior
Test would complete as expected. Or at least it must tell me if test is failed and why.
Reproduction code
import {interval, map, shareReplay} from 'rxjs';
import {TestScheduler} from 'rxjs/testing';
describe('interval', () => {
let testScheduler: TestScheduler;
beforeEach(() => {
testScheduler = new TestScheduler((actual, expected) => {
expect(actual).toEqual(expected);
});
});
// This one works as expected
it('should repeat forever without shareReplay', () => {
testScheduler.run(({ expectObservable }) => {
const foreverStream$ = interval(1).pipe(map(() => 'a'));
const unsub = '------!';
expectObservable(foreverStream$, unsub).toBe('-aaaaa');
});
});
// This one would crash
it('should repeat forever with shareReplay', () => {
testScheduler.run(({ expectObservable }) => {
const foreverStream$ = interval(1).pipe(map(() => 'a'), shareReplay(1));
const unsub = '------!';
expectObservable(foreverStream$, unsub).toBe('-aaaaa');
});
});
});
Reproduction URL
https://github.com/iofedurin/rxjs-sharereplay-bug-reproduction
Version
7.5.6
Environment
No response
Additional context
No response