Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

added async tests using callback pattern. runsAsync. #135

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants

I think callback-style tests would be a good addition to Jasmine. Jasmine already has async tests but they are based either on waiting a specified time, or continuously polling for a condition to be true.

This change adds a runsAsync method that is modeled after node.js style async functions. You pass runsAsync a function just like runs, but this time it takes a callback parameter. You call callback() when your async function is all done. If the first parameter you call callback with is not null, then the test will fail.

Tests included in commit.

tf commented Oct 1, 2011

Yes, I have also used an idiom like that a lot in my specs, either calling it runsUntil(function(done) {...}) or waitsForCallback(function(callack) {...}).

Thanks! I'm just in the process of porting a few hundred tests from QUnit to Jasmine and this has enabled us to proceed. We do not want to go back to polling/timeout async tests :)

I hope this gets pulled soon. There was some discussion on the Jasmine mailing list back in 2009 about this and it looks like they agreed it was a good idea but I guess nothing came of it.

Thank you. There is a similar testing framework called Mocha that looks like it has better async features. http://visionmedia.github.com/mocha/

Contributor

infews commented May 26, 2013

Master has a Mocha-inspired "done" callback syntax. Closing.

@infews infews closed this May 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment