node package manager

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
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 () { 
// }); 

You can also use the done callback with:

  • beforeEach
  • afterEach
  • beforeAll
  • afterAll

...this is usefull if your setup is async.

  • Find test files in sub-directories
  • Detect global created variables
  • Allow the test-file-naming-scheme to be configured

Inspired by mocha

ntest is released under the MIT license: