-
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
TestScheduler can miss tests when flushing #3898
Comments
cartant
added a commit
to cartant/rxjs
that referenced
this issue
Jul 7, 2018
cartant
pushed a commit
to cartant/rxjs
that referenced
this issue
Jul 9, 2018
@cartant 👍 to close? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug Report
Current Behavior
Calling
expectObservable
adds tests toflushTests
field, and callingtoBe
on the expect, marks those tests as ready. Then callingflush
should go overflushTests
, and execute and remove those that are ready at this point. The logic of removing is broken, and different tests get removed than should be. As a result, some tests might never be checked, and some are checked multiple times.The problem is that
TestScheduler.flush
is broken. When removing items fromflushTests
, it uses the index of the item from before removal, so for example if there are 3 tests,[ready1, ready2, notReady]
, thenflush()
will executeready1
, then remove at index 0, soready1
. Then executeready2
, then remove at index 1, but now it'snotReady
that is present at index 1. So afterflush()
,flushTests
should be[notReady]
, but in fact it is[ready2]
.Reproduction
https://stackblitz.com/edit/rxjs-testscheduler-flush-bug
Expected behavior
The expectation in the code above should be executed, and the test should fail, because
'z'
is not equal to'q'
. The test of'y'
should be executed once, while it is executed twice.Environment
Possible Solution
Change the relevant part of
TestScheduler.flush
to:Additional context
I'm testing a service in an Angular application, calling also a material dialog. For some reason, I need to call
flush()
at some point, between subscribing to an observable (by callingexpectObservable
) and actually comparing its result with the expectation.The text was updated successfully, but these errors were encountered: