diff --git a/docs/index.md b/docs/index.md index 5dac9ff173..9271adc114 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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: @@ -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"} diff --git a/lib/mocha.js b/lib/mocha.js index 6c8bf2561b..3b0a969f0e 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. @@ -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 @@ -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; } @@ -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; }; @@ -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; };