From ff6b64f66fb67050292e83d6bfa609740ef4d8c8 Mon Sep 17 00:00:00 2001 From: Lindsay-Needs-Sleep Date: Fri, 4 Oct 2019 02:31:57 -0600 Subject: [PATCH] Issue #1592 Improve documentation for mocha in browser. You can specify a the constructor of your custom reporter in options and mocha will use it. Make references to a reporters' names more uniform. --- docs/index.md | 18 ++++++++++++++---- lib/mocha.js | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/index.md b/docs/index.md index 5dac9ff173..2d78890fcd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1391,13 +1391,13 @@ The "nyan" reporter is exactly what you might expect: ### TAP -The TAP reporter emits lines for a [Test-Anything-Protocol][] consumer. +The "TAP" reporter emits lines for a [Test-Anything-Protocol][] consumer. ![test anything protocol](images/reporter-tap.png?withoutEnlargement&resize=920,9999){:class="screenshot" lazyload="on"} ### Landing Strip -The Landing Strip (`landing`) reporter is a gimmicky test reporter simulating a plane landing :) unicode ftw +The Landing Strip ("landing") reporter is a gimmicky test reporter simulating a plane landing :) unicode ftw ![landing strip plane reporter](images/reporter-landing.png?withoutEnlargement&resize=920,9999){:class="screenshot" lazyload="on"} ![landing strip with failure](images/reporter-landing-fail.png?withoutEnlargement&resize=920,9999){:class="screenshot" lazyload="on"} @@ -1488,7 +1488,7 @@ example, here is the Connect [test output][connect-test-output]. ### XUnit -The `xunit` reporter is also available. It outputs an XUnit-compatible XML document, often applicable in CI servers. +The "xunit" reporter is also available. It outputs an XUnit-compatible XML document, often applicable in CI servers. By default, it will output to the console. To write directly to a file, use `--reporter-options output=filename.xml`. @@ -1574,6 +1574,16 @@ mocha.setup({ }); ``` +Some available options: + +```text +reporter {string|constructor} - Reporter** name or constructor. +ui {string} - Interface name. +useColors {boolean} - Use color TTY output from reporter? +``` + +\*\* Available built in reporters that can be referenced by name [here](#reporters), and recommended reporters for the browser [here](#reporting). + ### Browser-specific Option(s) The following option(s) _only_ function in a browser context: @@ -1582,7 +1592,7 @@ The following option(s) _only_ function in a browser context: ### 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..e9077b926f 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -70,7 +70,6 @@ exports.Test = require('./test'); * @param {boolean} [options.asyncOnly] - Force `done` callback or promise? * @param {boolean} [options.bail] - Bail after first test failure? * @param {boolean} [options.checkLeaks] - Check for global variable leaks? - * @param {boolean} [options.color] - Color TTY output from reporter? * @param {boolean} [options.delay] - Delay root suite execution? * @param {boolean} [options.diff] - Show diff on failure? * @param {string} [options.fgrep] - Test filter given string. @@ -83,12 +82,13 @@ 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. * @param {number|string} [options.timeout] - Timeout threshold value. * @param {string} [options.ui] - Interface name. + * @param {boolean} [options.useColors] - Use color TTY output from reporter? */ function Mocha(options) { options = utils.assign({}, mocharc, options || {});