1.4.0 • Published 3 years ago

mocha-json-runner v1.4.0

Weekly downloads
20
License
MIT
Repository
github
Last release
3 years ago

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:

License

MIT

1.4.0

3 years ago

1.3.0

3 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago