Skip to content

Commit a5c5b24

Browse files
Issue #1592 Improve reporter documentation for mocha in browser.
You can pass the constructor function of your custom reporter in options and mocha will use it.
1 parent ba96962 commit a5c5b24

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,13 +1576,21 @@ mocha.setup({
15761576

15771577
### Browser-specific Option(s)
15781578

1579-
The following option(s) _only_ function in a browser context:
1579+
Browser Mocha supports many, but not all [cli options](#command-line-usage).
1580+
To use a [cli option](#command-line-usage) that contains a "-", please convert the option to camel-case, (eg. `check-leaks` to `checkLeaks`).
1581+
1582+
#### Options that have additional/slightly different usage than the corresponding [cli option](#command-line-usage) are listed here:
1583+
1584+
`reporter` _{string|constructor}_
1585+
Accepts a reporter name _{string}_ or constructor _{function}_. 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).
1586+
1587+
#### The following option(s) _only_ function in a browser context:
15801588

15811589
`noHighlighting`: If set to `true`, do not attempt to use syntax highlighting on output test code.
15821590

15831591
### Reporting
15841592

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

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

lib/mocha.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ exports.Test = require('./test');
8383
* @param {boolean} [options.inlineDiffs] - Display inline diffs?
8484
* @param {boolean} [options.invert] - Invert test filter matches?
8585
* @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
86-
* @param {string} [options.reporter] - Reporter name.
86+
* @param {string|constructor} [options.reporter] - Reporter name or constructor.
8787
* @param {Object} [options.reporterOption] - Reporter settings object.
8888
* @param {number} [options.retries] - Number of times to retry failed tests.
8989
* @param {number} [options.slow] - Slow threshold value.

0 commit comments

Comments
 (0)