vendredi 28 août 2015

Writing a basic test module in nodeunit

I am trying to use nodeunit and this is what I have. Following is testRunner.js:

#!/usr/bin/env node
var nodeunit = require('nodeunit');
var myTest = require('mytest.js');
nodeunit.runModule(myTest);

Following is myTest.js:

var testCase = require('nodeunit').testCase;
module.exports = testCase({
  setUp: function(callback) {
    // Called before all tests execute
  },
  tearDown: function(callback) {
    // Called after all tests execute
  },
  testFunction1: function(test) {
    // A test
  }
  testFunction2: function(test) {
    // Another test
  }
});

I try ./testRunner.js but I get:

TypeError: Cannot read property 'moduleStart' of undefined!

Unfortunately, nodeunit doc is not 100% clear about how to write test suites. I They have a few examples but they could make it better. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire