Skip to content

Instantly share code, notes, and snippets.

@jxson
Created September 8, 2011 18:39
Show Gist options
  • Save jxson/1204245 to your computer and use it in GitHub Desktop.
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
// 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