MiniJest
A Node testing framework inspired by MiniTest for Ruby.
I like the idea of making tests methods on an object. I find it acts as a nice natural divider to make sure each test file isn't doing too much.
Example
var MiniJest = ; var testMyThing = ; // all tests are added to the fn objecttestMyThingfn { this;}; // nothing happens without this line!testMyThing;
To run your tests, just execute them through Node:
$ node myTest.js
Customising the Reporter
You can change the reporter like so:
var MiniJest = ; var testMyThing = ; testMyThingreporter { // called when test passes}; testMyThingreporter { // called when test fails}; testMyThingreporter { // called when an async test times out}; testMyThing;
Adding Matchers
var MiniJest = ; var testMyThing = ; // a new matcher that always fails// matchers added to the matchers object// a failed matcher is expected to throw an errortestMyThingmatchers { throw 'test failed';}; testMyThingfn { this;}; testMyThing;
Handling Async
MiniJest handles async a little differently. An async test takes a callback, but you pass that callback a function in which you make your assertions:
testMyThingfn { ;};
This seems a little odd but is actually quite a nice way of doing things in practice.