mocha-json-runner
v2.0.0
Published
A Mocha.js runner that replays from JSON input
Downloads
8
Readme
Mocha.js JSON Runner
A Mocha.js runner that replays from JSON input
Pairs well with mocha-json-serialize-reporter!
Usage
Command-line
npm install --global mocha-json-runner
mocha-json-runner ./path/to/input.json
mocha-json-runner --help
mocha-json-runner <json>
Playback JSON test results with Mocha
Reporting & Output
-c, --color, --colors Force-enable color output [boolean]
--diff Show diff on failure
[boolean] [default: true]
--full-trace Display full stack traces [boolean]
-G, --growl Enable Growl notifications [boolean]
--inline-diffs Display actual/expected differences
inline within each string [boolean]
-R, --reporter Specify reporter to use
[string] [default: "spec"]
-O, --reporter-option, Reporter-specific options
--reporter-options (<k=v,[k1=v1,..]>) [array]
--warn-on-missing-state Warn when test is missing `state`.
Outputs to stderr. If mocha was run
with `--grep` this would produce
warnings for tests not matching.
File Handling
-r, --require Require module [array] [default: (none)]
Positional Arguments
json One file to load and playback
Other Options
-h, --help Show usage information & exit [boolean]
-V, --version Show version number & exit [boolean]
--reporters List built-in reporters & exit [boolean]
Programmatically
npm install --save-dev mocha-json-runner
const Mocha = require('mocha');
const MochaJsonRunner = require('mocha-json-runner');
const json = JSON.stringify({
suite: {
title: '',
tests: [
{ title: 'passing test', state: 'passed' },
{ title: 'failing test', state: 'failed', err: { message: 'FAIL' } },
{ title: 'pending test', pending: true },
],
},
});
const runner = new MochaJsonRunner(json);
new Mocha.reporters.Spec(runner);
runner.run();
Output: