Home

Awesome

qunit2node

QUnit adapter for nodeunit.

Run all your QUnit tests natively in node.js using nodeunit!

Getting Started

Install the module with: npm install qunit2node.

Create a new file where you concat node_modules/qunit2node/lib/qunit2node.js on top and your QUnit file right after and you are done!

Documentation

qunit2node provides the boolean NODE variable that can help you make your QUnit tests run on both environments (web and node.js). So if you are testing a library that can be reached on a certain namespace in the web, say ss.ready, then you'd want to do something like;

// my QUnit test file
var NODE = NODE || false;
if (NODE) {
	var ss = {
		ready: require('../path/to/lib/ready.js');
	};
}

test('basic test', function(){
	ok(ss.ready.loaded, 'Our library is loaded');
});

In case testing goes haywire, a DEBUG variable exists which you can set to boolean true and view in a very verbose way, what is going on when your QUnit test runs on nodeunit.

QUnit Supported functionality

qunit2node supports the majority of the QUnit API.

QUnit NOT supported functionality

qunit2node does not support:

Examples

A plain and straightforward example can be viewed in this repo's test/ folder.

There we have a typical QUnit test file (test/qunit/a_qunit.test.js), which after concatenation becomes test/qunit2node.test.js.

This is a pretty straightforward concat operation, nothing more to say here, except maybe if you use grunt have a quick look in the grunt file i use to concat and test.

License

Copyright (c) 2012 Thanasis Polychronakis Licensed under the MIT license.