Toolkit and utilities for automated testing in Node.js
npm install test-toolsTest Tools
==========
A set of Node.js application testing tools we use at
Fireworks Project.
We use Mocha
for most of our testing, but you should find these tools useful for most of the
Node.js automated testing tools out there.
package.json file of your project or install it with npm:npm install test-tools
* Bind the test function to a utility object for easy access to assertion functions.
* Keep an assertion count and check it when the test is over.
Here's an example useing Mocha:
``JavaScript
describe('something', function () {
it('should do something', function (done) {
// If anything more or less than 9 assertions are run, then
// an assertion error will be thrown.
this.expectCount(9);
// Asynchronous testing is done as usual
// but don't forget to call done()
setTimeout(function () {
this.assert();
this.equal();
this.notEqual();
this.strictEqual();
this.notStrictEqual();
this.deepEqual();
this.notDeepEqual();
return done();
}, 12);
this.throws(function () {
throw new Error('testing');
});
this.doesNotThrow(function () { return; });
// if done() is not called in an asynchronous closure, like it``
// was above, then make sure it is called here
return;
});
});
rake test
Of course you'll need to install Rake first.