Skip to content
A driver for testing the same as browser and Node.js http://tricknotes.github.io/mocha-ci-driver/
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
README.md
index.js
package.json

README.md

mocha CI driver

Build Status

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

$ 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
  , basedir = '../'
  , port = 8080
  , driver = new Driver(basedir, port)

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

And run

$ node ./test/driver.js

Optional

Use other reporter (default is Dot):

driver.run('/test/index.html', 'Spec');

Run multiple tests:

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

Supported mocha version

Supported revision is later visionmedia/mocha@a186b8dba1 .

This revision is not tagged yet.

To use mocha-ci-driver, use source from GitHub

<script src="https://raw.github.com/visionmedia/mocha/master/mocha.js"></script>

Or download and load:

$ curl https://github.com/visionmedia/mocha/blob/master/mocha.js > mocha.js
<script src="./mocha.js"></script>

Or build mocha for your project:

$ git clone git://github.com/visionmedia/mocha.git mocha
$ cd mocha
$ make clean && make

Use generated mocha.js to your html for test.

(I will publish to npm module after mocha tagged.)

Test

$ npm test

License

(The MIT License)

Copyright (c) 2012 Ryunosuke SATO <tricknotes.rs@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.