Skip to content

A test reporter for mocha that generates output using multiple reporters

License

Notifications You must be signed in to change notification settings

MisanthropicBit/mocha-multi-reporter

Repository files navigation

mocha-multi-reporter

version badge test badge license badge

A mocha reporter written in TypeScript that can run multiple reporters at once. Developed for personal use and inspired by mocha-multi-reporters and multi-reporter.

Installation

Git clone this repository or install using npm and the git url.

> npm i git+https://github.com/MisanthropicBit/mocha-multi-reporter.git

Building and testing

> npm i
> npm run build
> npm test

Usage

In the following command, replace ./build/dist/src/index.js with the path to the built index file. Here, we are selecting the json and spec reporters, loading the configuration file sample-config.json and passing an option to the json reporter.

> mocha --reporter ./build/dist/src/index.js --reporter-options reporters=json:spec --reporter-options config=sample-config.json --reporter-options json:test-output.json \"src/**/*.test.ts\"

You can also use a json configuration file which defaults to .reporters.json in the current directory or you can set the path using --reporter-options=config=sample-config.json as above. Reporter options specified on the command line will be merged with those in the configuration file but the former with higher precedence.

Sample configuration file.

{
  "json": {
    "output": "test-output.log"
  },
  "spec": true
}

A reporter can be enabled or disabled by setting its value to true or false respectively. An object value enables the reporter and passes those options to the reporter.

About

A test reporter for mocha that generates output using multiple reporters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published