Created
August 8, 2014 19:03
-
-
Save yyx990803/a6154353ae17dde81444 to your computer and use it in GitHub Desktop.
Simple helper for async tests in Jasmine 1.3 that mimics 2.0 and Mocha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Jasmine 1.3 async helper | |
*/ | |
function async (run) { | |
return function () { | |
var done = false | |
waitsFor(function () { return done }) | |
run(function () { done = true }) | |
} | |
} | |
// usage: | |
// it('should be async', async(function(done) { | |
// setTimeout(done, 1000) | |
// })) |
Sweet, just what i was looking for. Thanks 👍
Thanks a ton.
I'm stuck on Jasmine 1.3 for debugging/VSCode/NodeJS reasons, so this was very useful! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just wrote pretty much the same thing in a project of mine. If you want a drop-in replacement without having to wrap all your test functions in
async()
, then you can also overrideit()
and wrap all test functions inasync()
if they have length >= 1.