jxson
9/8/2011 - 6:39 PM

nodeunit test stub that allows you to run the file directly with node

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]);
}