Skip to content

Commit

Permalink
updated doc to reflect calling mocha programmatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Wilkins committed Mar 9, 2017
1 parent 8f8885c commit 2b6f802
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $ ./node_modules/.bin/mocha --reporter mocha-multi-reporters
</testsuite>
```

### Advance
### Advanced

* Generate `spec` and `json` reports.

Expand Down Expand Up @@ -215,6 +215,27 @@ $ cat xunit-custom.xml
</testsuites>
```

* When calling Mocha programmatically

Note that when Mocha is called programmatically, it is passed an options object when created. This object is usually derived from a config file that your mocha test runner reads prior to instantiation. This is the object that must contain a key `reporter` with a value of `mocha-multi-reporters` for this plugin to be used. You can also pass the key `reporterOptions` with a value of any of the above listed config files (including the `reporterEnabled` subkey and any other plugin configuration information.) This removes the requirement to have an intermediate configuration file specifically for the multireporter configuration.

```js
var mocha = new Mocha({
reporter: "mocha-multi-reporters",
timeout: config.testTimeout || 60000,
slow: config.slow || 10000,
reporterOptions: {
"reporterEnabled": "mocha-junit-reporter, tap",
"mochaJunitReporterReporterOptions": {
"mochaFile": "junit-custom.xml"
}
}
});
mocha.addFile(...)
mocha.run(...)

```

## License

The MIT License (MIT)
Expand Down

0 comments on commit 2b6f802

Please sign in to comment.