Marble testing of interval with shareReplay pipe crashes the test
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided reproduction and the TestScheduler.run examples in the issue, comparing the interval cases with and without shareReplay. Investigate why the shareReplay case does not complete or report a failure when the '------!' unsubscribe is used. Done means the test completes reliably and exposes a useful failure when expectations are wrong.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100