Skip to content

Instantly share code, notes, and snippets.

@yyx990803
Created August 8, 2014 19:03
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yyx990803/a6154353ae17dde81444 to your computer and use it in GitHub Desktop.
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
/**
* 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)
// }))
@dylansmith
Copy link

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 override it() and wrap all test functions in async() if they have length >= 1.

@imaximix
Copy link

Sweet, just what i was looking for. Thanks 👍

@YurySolovyov
Copy link

Thanks a ton.

@craigbrett17
Copy link

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