Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plasticrake/mocha-json-runner
A Mocha.js runner that replays from JSON input
https://github.com/plasticrake/mocha-json-runner
json mocha mocha-runner
Last synced: 23 days ago
JSON representation
A Mocha.js runner that replays from JSON input
- Host: GitHub
- URL: https://github.com/plasticrake/mocha-json-runner
- Owner: plasticrake
- Created: 2019-12-22T23:48:50.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-31T07:16:10.000Z (3 months ago)
- Last Synced: 2024-10-22T03:48:03.953Z (24 days ago)
- Topics: json, mocha, mocha-runner
- Language: JavaScript
- Size: 900 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Mocha.js JSON Runner
[![NPM Version](https://img.shields.io/npm/v/mocha-json-runner.svg)](https://www.npmjs.com/package/mocha-json-runner)
[![Build Status](https://github.com/plasticrake/mocha-json-runner/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/plasticrake/mocha-json-runner/actions/workflows/ci.yml?query=branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/plasticrake/mocha-json-runner/badge.svg?branch=master)](https://coveralls.io/github/plasticrake/mocha-json-runner?branch=master)**A [Mocha.js](https://mochajs.org/) runner that replays from JSON input**
Pairs well with [mocha-json-serialize-reporter](https://github.com/plasticrake/mocha-json-serialize-reporter)!
## Usage
### Command-line
```shell
npm install --global mocha-json-runner
``````shell
mocha-json-runner ./path/to/input.json
``````shell
mocha-json-runner --help
``````text
mocha-json-runnerPlayback 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 () [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 playbackOther Options
-h, --help Show usage information & exit [boolean]
-V, --version Show version number & exit [boolean]
--reporters List built-in reporters & exit [boolean]
```### Programmatically
```shell
npm install --save-dev mocha-json-runner
``````js
import Mocha from 'mocha';
import MochaJsonRunner from '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 test1 passing (0ms)
1 pending
1 failing1) failing test:
FAIL## License
[MIT](LICENSE)