-
Notifications
You must be signed in to change notification settings - Fork 782
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
assert.timeout() can fail on simple synchronous tests #1539
Comments
I suspect the issue might be with this assumption in Lines 18 to 33 in 9f16eed
I added the following to confirm the issue: QUnit.test( "does not push a failure if test is synchronous", function( assert ) {
+ if ( QUnit.config.timeout ) {
+ throw new Error( "QUnit.config.timeout: " + QUnit.config.timeout );
+ }
assert.timeout( 1 );
With this patch in place, I confirmed that indeed this condition is being intemittently. About every other test run for me. And while it doesn't cause a test failure normally for me in Firefox or Chrome, I do find this condition being met met half the time in those browsers. So it would seem we have a race condition where about half the time, |
For an async test, we normally remember the assigned timeout amount, and the actual scheduling and enforcement of the timeout doesn't happen until after the test callback returns. If the test doesn't happen to be asynchronous, then the amount is discarded and we simply move on to the next test. Sometimes, the timeout ID stored in `config.timeout` for a previous async test would remain and thus caused `assert.timeout()` to wrongly think it was called twice in the same test, and tries clear and reschedule it, when actually it is clearing nothing and scheduling the first timeout and doing so before the test callback has returned. Thus when the test is over and we "ignore" the timeout, QUnit then got confused thinking it's an async test and thus waits until it times out. Fix this by making sure `config.timeout` is always explicitly emptied (or re-assigned) when a timeout is cancelled or has completed. Fixes #1539.
For an async test, we normally remember the assigned timeout amount, and the actual scheduling and enforcement of the timeout doesn't happen until after the test callback returns. If the test doesn't happen to be asynchronous, then the amount is discarded and we simply move on to the next test. Sometimes, the timeout ID stored in `config.timeout` for a previous async test would remain and thus caused `assert.timeout()` to wrongly think it was called twice in the same test, and tries clear and reschedule it, when actually it is clearing nothing and scheduling the first timeout and doing so before the test callback has returned. Thus when the test is over and we "ignore" the timeout, QUnit then got confused thinking it's an async test and thus waits until it times out. Fix this by making sure `config.timeout` is always explicitly emptied (or re-assigned) when a timeout is cancelled or has completed. Fixes #1539.
Tell us about your runtime:
What are you trying to do?
Code that reproduces the problem:
The following test fails intermittently in IE Opera (Chromium-based) and IE 10 on Windows (probably other browsers as well). However, it passes consistently in Firefox, Chrome, and Safari on macOS:
Failure
The text was updated successfully, but these errors were encountered: