Skip to content

Instantly share code, notes, and snippets.

@yyx990803
Created Aug 8, 2014
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@dylansmith dylansmith commented Apr 7, 2015

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

This comment has been minimized.

Copy link

@imaximix imaximix commented Nov 18, 2015

Sweet, just what i was looking for. Thanks 👍

@YurySolovyov

This comment has been minimized.

Copy link

@YurySolovyov YurySolovyov commented Dec 23, 2016

Thanks a ton.

@craigbrett17

This comment has been minimized.

Copy link

@craigbrett17 craigbrett17 commented Aug 9, 2017

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