-
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
Add Async Event Support #921
Conversation
Looks good. Except JSHint doesn't like this (function in a loop)... for (i = 0; i < cbs.length; i++) {
cb = cbs[i];
// Force async
setTimeout(function() {
cb(res);
},0);
} Not sure what we can do about that though – could swap it round so the loop's in a single call to the timeout function, but then all the callbacks would be synchronous with each other, which probably isn't ideal. I agree the documentation should focus on async tests, but I don't think we should categorically say it's not supported for sync tests... maybe just don't mention sync at all, or say something like:
An extra thought: how about renaming |
I say we just add the exception comment :D
Right. Just undocumented. The note is good too.
We have a lot of docs on adding your own test with |
Testing wise I think we should include sinon.js so we can mock setTimeout and spy on the |
Yeah I think we want to keep the external API the same. I reckon keep it as it is, but I'll stick some thoughts in another ticket for us to mull over for a later release. |
Fixed the jshint error. Gonna pull this in since the whole repo is pretty much in dev mode. I think this works though, either way. |
Add Async Event Support
Sorry I'm a bad citizen and also have a bunch of metadata changes in this (I work on planes a lot). If you scroll to the bottom of the diff, it's the new stuff. Seems to work in my testing, though we could probably add some formal tests for it. Async stuff is always a joy to test, but it shouldn't be too bad.
Docs for it are in the readme.
Currently I have support for this working for sync and async tests, but I think we should only document async tests, and leave in sync because it's not much code and people will accidentally do it, and if tests ever change, etc etc.
/cc @stucoxmedia @paulirish