Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mocha-srv with all npm packages installed. Try it out:

var mochaSrv = require("mocha-srv")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mocha-srv v0.1.0

Bundle node tests and serve them up for running in-browser


mocha-srv runs a simple HTTP server, serving up your Mocha tests. This allows you to run the same suite of tests on the command line (with Node.js) and in the browser.

Current Version: 0.1.0
Node Support: 0.8, 0.10

Getting Started

mocha-srv requires Node.js and npm. Once you have these dependencies, you can install mocha-srv with the following command:

$ npm install -g mocha-srv


Once installed, the mocha-srv command should be available to you.

  Usage: mocha-srv [options] <path>


    -h, --help           output usage information
    -V, --version        output the version number
    -p, --port <port>    specify the port to run the server on. Default: 3000
    -t, --title <title>  specify the test suite title
    -u, --ui <ui>        specify the Mocha UI your tests use, one of: bdd (default), tdd


# Run mocha-srv, serving unit tests in ./tests
$ mocha-srv ./tests

# Run mocha-srv on port 1337 and run tests in TDD style
$ mocha-srv -p 1337 -u tdd ./tests


To develop mocha-srv, you'll need to clone the repo and install dependencies with make deps. If you're on Windows, you'll also need to install Make for Windows.

Once you're set up, you can run the following commands:

$ make deps         # Install dependencies
$ make lint         # Run JSHint with the correct config
$ make test         # Run unit/feature tests

When no build target is specified, make will run deps lint test. This means you can use the following command for brevity:

$ make

Code with lint errors or no/failing tests will not be accepted, please use the build tools outlined above.


mocha-srv is licensed under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free