ntest

0.9.1 • Public • Published

ntest

Simple unit testing tool for nodejs

Target

  • Run tests sequentially
  • Provide as best as possible stacktraces
  • Keep it simple

Install

sudo npm install ntest -g

Usage

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

ntest test-directory

test/test-example.js

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.

Todos

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

Credits

Inspired by mocha

License

ntest is released under the MIT license:

Readme

Keywords

none

Package Sidebar

Install

npm i ntest

Weekly Downloads

1

Version

0.9.1

License

MIT

Last publish

Collaborators

  • holgerk