ntest

Simple testing tool for nodejs

ntest

Simple unit testing tool for nodejs

  • Run tests sequentially
  • Provide as best as possible stacktraces
  • Keep it simple
sudo npm install ntest -g

Create test files named like: test-foo.js or test-bar.js. And then run:

ntest test-directory
test/test-example.js --- ```javascript var assert = require('assert');

beforeAll(function () { console.log('before all tests in this file'); });

afterAll(function() { console.log('after all tests in this file'); });

beforeEach(function() { console.log('before each test in this file'); });

afterEach(function() { console.log('after each test in this file'); });

test('simple test', function () { assert.equal('hello', 'he' + 'llo'); });

test('async test', function (done) { setTimeout(function () { done() // <-- finish test }, 100) });

test('async2 test', function (done) { this.timeout(1000) // <-- change timeout to one second setTimeout(function () { done() }, 500) });

// use bang(!) as first letter in test name to execute only this test // test('!execute only this test', function () { // });

<!-- /INSERT -->
 
You can also use the *done* callback with:
* beforeEach
* afterEach
* beforeAll
* afterAll
 
...this is usefull if your setup is async.
 
 
Todos
-----
 
* Find test files in sub-directories
* Detect global created variables
* Allow the test-file-naming-scheme to be configured
 
 
Credits
-------
 
Inspired by mocha
 
http://visionmedia.github.com/mocha/
 
 
License
-------
 
ntest is released under the MIT license:
 
http://www.opensource.org/licenses/MIT