Update 2/5/2012: as of version 1.0.15 jasmine-node includes this enhancement to support asynchronous specs. The original post follows…
We’re using jasmine-node for BDD-style testing of our node apps. It’s not an amazing implementation of jasmine for node but it gets the job done.
One of my issues with jasmine-node is its awkward support for asynchronous tests with the global
Inspired by the BDD style supported by Mocha, I decided that our jasmine specs should support asynchronous specs in the same style where
afterEach wait until the spec is finished if passed a function that expects a
done callback will fail the spec if passed an error, so even more succinctly:
In order to modify the behavior of the jasmine spec methods, I wrote a spec helper that monkey patches
afterEach to run with asynchronous support if the spec is written to expect a
done handler. Here’s a Gist of my file
async_helper.coffee that I have in my
The use of
Function.length to check how many arguments a function expects was a new and very handy trick that made this spec style possible. Much better!!
Posted by Alon Salant