From a5c5b24de34484583e7aef468db8626195ddda99 Mon Sep 17 00:00:00 2001 From: Lindsay-Needs-Sleep Date: Sat, 12 Oct 2019 21:40:01 -0600 Subject: [PATCH] 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. --- docs/index.md | 12 ++++++++++-- lib/mocha.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 5dac9ff173..b74730097f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1576,13 +1576,21 @@ 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`). + +#### Options that have additional/slightly different usage than the corresponding [cli option](#command-line-usage) are listed here: + +`reporter` _{string|constructor}_ +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). + +#### The following option(s) _only_ function in a browser context: `noHighlighting`: 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"} diff --git a/lib/mocha.js b/lib/mocha.js index 6c8bf2561b..839a523111 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -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.