Created
September 8, 2011 18:39
-
-
Save jxson/1204245 to your computer and use it in GitHub Desktop.
nodeunit test stub that allows you to run the file directly with node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy this file into the appropriate test directory with an appropriate | |
// filename and remove/ edit the tests defined below. Once you do that you can | |
// run the tests directly using: | |
// | |
// node test/my_whatever_test.js | |
// | |
// neat. | |
// | |
// - checkout https://github.com/caolan/nodeunit | |
var testCase = require('nodeunit').testCase; | |
exports.foo = function(test){ | |
test.ok(true); | |
test.done(); | |
}; | |
exports.bar = testCase({ | |
setUp: function(callback){ | |
this.baz = true; | |
callback(); | |
}, | |
tearDown: function(callback){ | |
callback(); | |
}, | |
'some test': function(test){ | |
test.ok(this.baz); | |
test.done(); | |
}, | |
'some other test': function(test){ | |
test.ok(this.baz); | |
test.done(); | |
} | |
}); | |
if (module == require.main) { | |
var filename = __filename.replace(process.cwd(), ''); | |
require('nodeunit').reporters.default.run([filename]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment