mocha-json-runner

1.4.0 • Public • Published

Mocha.js JSON Runner

NPM Version Build Status codecov Total alerts Language grade: JavaScript

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:


 passing test
  1) failing test
  - pending test

  1 passing (0ms)
  1 pending
  1 failing

  1) failing test:
     FAIL

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i mocha-json-runner

Weekly Downloads

0

Version

1.4.0

License

MIT

Unpacked Size

19.8 kB

Total Files

6

Last publish

Collaborators

  • plasticrake