Mocha Service
An Express service that can be used for testing client side applications with Mocha and Chai.
The service dynamically creates the Mocha test.html
file. The file can be
accessed at http://localhost:9002/test/index.html
(or whatever port you
choose to run it on).
Installation
# Install into project (as dev dependency) $ npm install mocha-service --save-dev # Install globally $ npm install mocha-service -g
Usage Embedded
mochaService
sets up the tests under /test/index.html
var app = ; if app === 'test' var mochaService = ; ;
Available options to mochaService
are:
app
An instance of an Express application.options
appRoot
: The path to the directory with the client files (./public)appFile
: The URL of an html file to include the body of * (null)srcPattern
: Glob pattern to find source files (/scripts/*.js)testPattern
: Glob pattern to find test files (/scripts/test/*.js)libPattern
: Glob pattern to find lib files (/scripts/lib/*.js)globals
: Global variables that mocha ignores
Usage standalone
$ bin/mocha-service --helpStarts a client test server.Usage: node ./bin/mocha-service Options: --help This information --root The root directory of the client files --src Glob pattern
Other
If you want to run the test in a command line interface, I recommend mocha-phantom-js.