nodeunit
nodeunit copied to clipboard
setUp and tearDown do not appear to work in the browser
Steps to reproduce:
- Go into the examples/browser folder
- Open test.html
- Everything works as expected
- Add setUp and tearDown functions to suite1.js
- Refresh the page to rerun the tests
Defect: the functions added in step 4 are run just like normal tests
This appears to be a defect in the copy of nodeunit.js in the examples/browser folder. The example's version of nodeunit.js has a function wrapGroup but this is never called; whereas the node-based nodeunit.js in lib/core.js does call this.
(Sorry that I don't understand the code base well enough at the moment to offer a patch.)
Here's a copy+paste fix for broken setUp and tearDown methods in the examples version of nodeunit:
- replace the following functions in
examples/nodeunit.jswith the corresponding versions from thelib/core.jsfile:-
exports.runModule() -
wrapGroup() -
exports.runModule()
-
- copy the
getSerialCallback()function fromlib/core.jsand paste intoexamples/nodeunit.js, just before thewrapGroup()function.
https://gist.github.com/dfkaye/9280921