Skip to content

Commit

Permalink
Issue #1592 Improve reporter documentation for mocha in browser.
Browse files Browse the repository at this point in the history
You can pass the constructor function of your custom reporter in options and mocha will use it.
  • Loading branch information
Lindsay-Needs-Sleep committed Oct 13, 2019
1 parent ba96962 commit 40bbaaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1576,13 +1576,22 @@ mocha.setup({

### Browser-specific Option(s)

The following option(s) _only_ function in a browser context:
Browser Mocha supports many, but not all [cli options](#command-line-usage).
To use a [cli option](#command-line-usage) that contains a "-", please convert the option to camel-case, (eg. `check-leaks` to `checkLeaks`).

`noHighlighting`: If set to `true`, do not attempt to use syntax highlighting on output test code.
#### Options that differ slightly from [cli options](#command-line-usage):

`reporter` _{string|constructor}_
You can pass a reporter's name or a custom reporter's constructor. You can find **recommended** reporters for the browser [here](#reporting). It is possible to use [built-in reporters](#reporters) as well, but we don't recommend it, (you can put your cat in the microwave, but don't blame us).

#### Options that _only_ function in browser:

`noHighlighting` _{boolean}_
If set to `true`, do not attempt to use syntax highlighting on output test code.

### Reporting

The "HTML" reporter is what you see when running Mocha in the browser. It looks like this:
The "html" reporter is the default reporter when running Mocha in the browser. It looks like this:

![HTML test reporter](images/reporter-html.png?withoutEnlargement&resize=920,9999){:class="screenshot" lazyload="on"}

Expand Down
2 changes: 1 addition & 1 deletion lib/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports.Test = require('./test');
* @param {boolean} [options.inlineDiffs] - Display inline diffs?
* @param {boolean} [options.invert] - Invert test filter matches?
* @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
* @param {string} [options.reporter] - Reporter name.
* @param {string|constructor} [options.reporter] - Reporter name or constructor.
* @param {Object} [options.reporterOption] - Reporter settings object.
* @param {number} [options.retries] - Number of times to retry failed tests.
* @param {number} [options.slow] - Slow threshold value.
Expand Down

0 comments on commit 40bbaaa

Please sign in to comment.