Skip to content

Instantly share code, notes, and snippets.

@repeatingbeats
Created January 27, 2011 20:07

Revisions

  1. repeatingbeats revised this gist Jan 27, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions nodeunit_example.js
    Original file line number Diff line number Diff line change
    @@ -32,6 +32,7 @@ exports.groupOne = testCase({
    },

    nestedGroup: testCase({

    setUp: function groupOneNestedSetup(cb) {
    console.log(arguments.callee.name);
    cb();
  2. repeatingbeats created this gist Jan 27, 2011.
    75 changes: 75 additions & 0 deletions nodeunit_example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    /**
    * Example structure for nodeunit tests with nested groups and setup/teardown
    * functions. Run | nodeunit nodeunit_example.js | to see a printout of
    * function names in the order that they are called. There aren't any actual
    * tests here.
    */

    process.env.NODE_ENV = 'test';

    var testCase = require('nodeunit').testCase;

    exports.groupOne = testCase({

    setUp: function groupOneSetup(cb) {
    console.log(arguments.callee.name);
    cb();
    },

    tearDown: function groupOneTearDown(cb) {
    console.log(arguments.callee.name);
    cb();
    },

    groupOneTestOne: function groupOneTestOne(test) {
    console.log(arguments.callee.name);
    test.done();
    },

    groupOneTestTwo: function groupOneTestTwo(test) {
    console.log(arguments.callee.name);
    test.done();
    },

    nestedGroup: testCase({
    setUp: function groupOneNestedSetup(cb) {
    console.log(arguments.callee.name);
    cb();
    },

    tearDown: function groupOneNestedTearDown(cb) {
    console.log(arguments.callee.name);
    cb();
    },

    groupOneNestedTestOne: function groupOneNestedTestOne(test) {
    console.log(arguments.callee.name);
    test.done();
    },

    groupOneNestedTestTwo: function groupOneNestedTestTwo(test) {
    console.log(arguments.callee.name);
    test.done();
    },

    }),

    groupOneTestThree: function groupOneTestThree(test) {
    console.log(arguments.callee.name);
    test.done();
    }

    });

    exports.groupTwo = {

    groupTwoTestOne: function groupTwoTestOne(test) {
    console.log(arguments.callee.name);
    test.done();
    },

    groupTwoTestTwo: function groupTwoTestTwo(test) {
    console.log(arguments.callee.name);
    test.done();
    }
    }