-
Notifications
You must be signed in to change notification settings - Fork 783
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
Async: Implement new assert.async mechanism #653
Conversation
For QUnit |
config.current.semaphore = 1; | ||
config.semaphore = 0; | ||
} else { | ||
QUnit.assert.ok( false, "Test timed out" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pushFailure instead, if there's no current test it's the best option here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, just a holdover from the existing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
I'm missing also the deprecation messages on |
I also vote for deprecating For |
To make tests async by default, we would need to either:
QUnit.test( "x", function( assert, done ) {
/* ... */
done();
});
|
also as anyway, let's bring this 2.0.0 discussion to another issue so here we can focus on the changes on this PR. |
|
Added deprecation warnings for |
That's not really what I suggested (I hope). With the two approaches we're going for now, I don't think we really need something else. The third approach would be to make assert.expect() trigger an async test, then running the specified of assertions ending the test. That wouldn't work for expect(0), which we currently support. There's probably more reasons why this isn't great, at least in the context of our existing APIs. |
Please ignore style issues with lines that are too long until #654 is addressed, which will help fix these. That kind of issue is just distracting from the important parts here. |
Other than that, \o/ \o/ \o/ This is great. |
Thanks, @gibson042! @jzaefferer @leobalter @Krinkle: Did you guys want to review this PR further? I'm not sure I have anyone's stamp of approval yet. |
setTimeout(function() { | ||
currentTest.state = "beforeEach"; | ||
done(); | ||
}, 50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space
LGTM, so I reported only few style issues I saw |
@leobalter: All fixed, and a few more. |
So @leobalter and @gibson042 have approved now. @jzaefferer @Krinkle @scottgonzalez, did any of you want to review this further before it gets merged? Forewarning: The Promise PR (#634) will be ready for rebasing for further review and/or merging immediately after this one is merged, so you should also go review that one (which contains this PR as well) before I have to pester you. 😜 |
@@ -15,6 +15,8 @@ QUnit.init = function() { | |||
config.autorun = false; | |||
config.filter = ""; | |||
config.queue = []; | |||
|
|||
// DEPRECATED: QUnit.config.semaphore will be removed in QUnit 2.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fine, but since this property was never in the public API, it's not really necessary. I also see no reason why something outside QUnit should ever fiddle with this, except as workarounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, per implementation of #653 (comment)
@@ -0,0 +1,6 @@ | |||
QUnit.start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling start() again here doesn't cause any failure. It should, and it does in master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test for it locally and it does cause a failure for me, so...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added many tests for the various start
/stop
error scenarios mentioned in #653 (comment)
Overall looking very promising. No game-breaker, just some details that we need to iron out. No need to discuss |
The new commit implemented all of the error scenario rules for |
QUnit.start(); | ||
}, config.testTimeout ); | ||
|
||
// If there isn't a test running, don't allow QUni.stop() to be called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's QUni
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QUnicorns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. Fixed. :)
LGTM |
Also adds minor test cleanup Fixes #659
Fixes #534.
Typical Usage Example:
This PR should now be merged before #634 (which I will then rebase).