ReactiveX / ReactiveX/rxjs

TestScheduler can't be reused ? Doc is unclear.

Open
#7,141 0 comments 0 reactions 0 assignees View on GitHub

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 simplified my problem to this : I reuse a scheduler for multiple test, reading the doc I thought this would be ok.

But unless I reset the frame at 0, the 2nd test will fail.

Is this expected ? If so that might need a clarification on the marble testing doc.

Anyway, thanks for the good work.

Expected behavior

Both test should pass without reseting the frame.

Reproduction code
const testScheduler = new TestScheduler((actual, expected) => {
  console.log(actual, expected, isEqual(actual, expected));
});

const test = (helpers: RunHelpers) => {
  const { cold, expectObservable } = helpers;
  const source = cold('---a--b--|');
  const expected = '   ---a--b--|';
  expectObservable(source).toBe(expected);
};

testScheduler.run(test);
testScheduler.frame = 0; // 2nd test fails if removed
testScheduler.run(test);
Reproduction URL

https://stackblitz.com/edit/rxjs-tucw4y?file=index.ts

Version

7.8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and the TestScheduler.run calls shown in the issue. Check whether reusing a scheduler without resetting frame is supported; done means the marble testing documentation clearly explains the expected reuse and frame-reset behavior, or the issue is redirected if documentation is not the appropriate fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation, testing-qa
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.