Skip to content

Commit

Permalink
(!!Broken) Pull request mochajs#4026 Improve documentation for mocha …
Browse files Browse the repository at this point in the history
…in browser.

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 12, 2019
1 parent ec17f63 commit 62ae27a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
17 changes: 16 additions & 1 deletion docs/index.md
Expand Up @@ -1574,6 +1574,21 @@ mocha.setup({
});
```

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`).

```text
colors {boolean} - Use color TTY output from reporter?
diff {boolean} - Show diff on failure?
inlineDiffs {boolean} - Display actual/expected differences
inline within each string
reporter {string|constructor} - Reporter** name or constructor.
ui {string} - Interface name.
```

\*\* 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:
Expand All @@ -1582,7 +1597,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"}

Expand Down
14 changes: 7 additions & 7 deletions lib/mocha.js
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 All @@ -103,7 +103,7 @@ function Mocha(options) {
.bail(options.bail)
.reporter(options.reporter, options.reporterOption)
.slow(options.slow)
.useInlineDiffs(options.inlineDiffs)
.inlineDiffs(options.inlineDiffs)
.globals(options.global);

// this guard exists because Suite#timeout does not consider `undefined` to be valid input
Expand Down Expand Up @@ -547,7 +547,7 @@ Mocha.prototype.globals = function(globals) {
* @return {Mocha} this
* @chainable
*/
Mocha.prototype.useColors = function(colors) {
Mocha.prototype.color = function(colors) {
if (colors !== undefined) {
this.options.color = colors;
}
Expand All @@ -563,7 +563,7 @@ Mocha.prototype.useColors = function(colors) {
* @return {Mocha} this
* @chainable
*/
Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
Mocha.prototype.inlineDiffs = function(inlineDiffs) {
this.options.inlineDiffs = inlineDiffs !== undefined && inlineDiffs;
return this;
};
Expand All @@ -572,12 +572,12 @@ Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
* Determines if reporter should include diffs in test failure output.
*
* @public
* @param {boolean} [hideDiff=false] - Whether to hide diffs.
* @param {boolean} [showDiff=true] - Whether to hide diffs.
* @return {Mocha} this
* @chainable
*/
Mocha.prototype.hideDiff = function(hideDiff) {
this.options.diff = !(hideDiff === true);
Mocha.prototype.diff = function(showDiff) {
this.options.diff = showDiff;
return this;
};

Expand Down

0 comments on commit 62ae27a

Please sign in to comment.