-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limitation in marble testing use cases due to grouping semantics #5677
Comments
So the desired solution would look like this? rxTest.run(({ cold, expectObservable }) => {
const a = cold(' (aaaaa) ');
const b = cold(' (bbbbb) ');
const c = cold(' (ccccc)');
const source = cold('------a --b --c ---|', { a, b, c });
const expected = ' ------(aaaaa)--(bbbbb)--(ccccc)---|';
const result = source.pipe(mergeAll());
expectObservable(result).toBe(expected);
}); It seems reasonable. I'm not totally sure of the use case though. The primary use for marble tests is for testing operators, and the dashes and characters really signify the arbitrary passage of time to ensure order. It's unlikely that any process could consistently get the fidelity of < 1ms... but I suppose that will change as time marches on. In fact, each dash could just as easily represent an hour as a millisecond. In other words "what is a frame?" There are similar limitations with the difference between jobs on the event loop, micro tasks, etc. Animation frames are even more difficult.. N functions executing with the same high res timestamp? Not a lot of great ways to emulated that with marble diagrams at the moment. It would certainly be a breaking change, so we couldn't just introduce this as a default. It would need to be via a setting. As a team, we'll have to weigh this against it's usefulness and other priorities. I'll make this an agenda item to discuss. |
@benlesh those reasoning is actually reason why we did decide to not upstream my rx-sandbox. |
(Since rx-sandbox is still using frame-based |
Yes that’s correct. Imagine an operator that runs multiple concurrent intervals internally that can emit on the same tick if they happen to run in sync with each other. Eg. One interval started at 109ms to fire every 200ms, a second interval started at 209ms for every 100ms. This is only an edge case and the consumer desires singular values in the happy path. Now imagine that operator also emits at the point in time some other event happens (which starts a new interval and has to emit a 0 initial value) For all we know we may have N emissions at the 100ms mark, and then an event at 101ms requires another emission at that exact ms. Right now it’s not possible to test
One option is to do with the addition of new syntax and optionally deprecate old syntax such that it’s non breaking, but we’re saying the same thing (it’d need to be optional) An easy workaround may be to |
After discussion about #5760, core team decided to punt on certain TestScheduler ergonomics issues until next major. |
Hi all, I would like to ask if this request can be brought back to life for RX v8. I wrote the following UT to illustrate:
Here I have to alter the input observable to ensure that I get a passing test. |
Feature Request
Is your feature request related to a problem? Please describe.
It is therefore impossible to use marbles to test that pairs of values are emitted in subsequent frames. I would propose making this behavior configurable or making a breaking change to revert it. The rationale, people who want to visually align things can still do so (eg by adding spaces, or writing their test around the visual alignment). Contrast this with people who don't care about visual alignment, but want to be able to test some logic that must work this way (pairs of values on subsequent ticks). I for one disagree its a good tradeoff to make certain use cases impossible for the sake of making visual alignment easier.
Describe the solution you'd like
Have an option to change, or make a breaking change so it uses 1 tick when there are groupings. Users can use spaces to create alignment, or the users who insist on visual alignment can contort their tests instead of imposing this "contortion" on the use cases that marbles can possibly test
Describe alternatives you've considered
N/a, other than working around by not testing this use case at all
Additional context
The text was updated successfully, but these errors were encountered: