Fork Me on GitHub

mocha-ci-driver

A driver for testing the same as browser and Node.js

Download this project as a .zip file Download this project as a tar.gz file

mocha-ci-driver is a driver that make test written by mocha for browser working on Node.js.

Your code and test for browser works on Node.js without rewriting for Node.js.

Install

$ npm install mocha-ci-driver

The other way:

$ cd YOUR_PROJECT_HOME
$ git clone git://github.com/tricknotes/mocha-ci-driver.git ./node_modules/mocha-ci-driver

Usage

Setup:

Modify ./test/index.html(Your test html)

<script>
  // Execute `mocha.run()` when accessed from browser
  if (!/Node.js/.test(navigator.appName)) {
    mocha.run();
  }
</script>

Add ./test/driver.js

var Driver = require('mocha-ci-driver').Driver
  , driver = new Driver()

driver.run(__dirname+'/test/index.html');

And run

$ node ./test/driver.js

Optional

Use other reporter (default is Dot):

driver.run(__dirname+'/test/index.html', {reporter: 'Spec'});

Run multiple tests:

driver.run(__dirname+'/test/index1.html');
driver.run(__dirname+'/test/index2.html');

Test

$ npm test

Author

Copyright (c) 2012 Ryunosuke SATO <tricknotes.rs@gmail.com>