From bcac9019dd3cea6d9790d1ffee763131740c0678 Mon Sep 17 00:00:00 2001 From: juergba Date: Wed, 16 Oct 2019 11:14:26 +0200 Subject: [PATCH] browser setup functions --- lib/mocha.js | 59 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/mocha.js b/lib/mocha.js index 839a523111..f20e3b8183 100644 --- a/lib/mocha.js +++ b/lib/mocha.js @@ -103,7 +103,6 @@ function Mocha(options) { .bail(options.bail) .reporter(options.reporter, options.reporterOption) .slow(options.slow) - .useInlineDiffs(options.inlineDiffs) .globals(options.global); // this guard exists because Suite#timeout does not consider `undefined` to be valid input @@ -119,11 +118,14 @@ function Mocha(options) { 'allowUncaught', 'asyncOnly', 'checkLeaks', + 'color', 'delay', + 'diff', 'forbidOnly', 'forbidPending', 'fullTrace', 'growl', + 'inlineDiff', 'invert' ].forEach(function(opt) { if (options[opt]) { @@ -430,17 +432,17 @@ Mocha.prototype.invert = function() { /** * Enables or disables ignoring global leaks. * + * @deprecated * @public * @see {@link Mocha#checkLeaks} * @param {boolean} [ignoreLeaks=false] - Whether to ignore global leaks. * @return {Mocha} this * @chainable - * @example - * - * // Ignore global leaks - * mocha.ignoreLeaks(true); */ Mocha.prototype.ignoreLeaks = function(ignoreLeaks) { + utils.deprecate( + '"ignoreLeaks()" is DEPRECATED, please use "checkLeaks()" instead.' + ); this.options.checkLeaks = !ignoreLeaks; return this; }; @@ -449,8 +451,6 @@ Mocha.prototype.ignoreLeaks = function(ignoreLeaks) { * Enables checking for global variables leaked while running tests. * * @public - * @see {@link /#-check-leaks|CLI option} - * @see {@link Mocha#ignoreLeaks} * @return {Mocha} this * @chainable */ @@ -542,45 +542,90 @@ Mocha.prototype.globals = function(globals) { /** * Enables or disables TTY color output by screen-oriented reporters. * + * @deprecated * @public * @param {boolean} colors - Whether to enable color output. * @return {Mocha} this * @chainable */ Mocha.prototype.useColors = function(colors) { + utils.deprecate('"useColors()" is DEPRECATED, please use "color()" instead.'); if (colors !== undefined) { this.options.color = colors; } return this; }; +/** + * Enables TTY color output by screen-oriented reporters. + * + * @public + * @return {Mocha} this + * @chainable + */ +Mocha.prototype.color = function() { + this.options.color = true; + return this; +}; + /** * Determines if reporter should use inline diffs (rather than +/-) * in test failure output. * + * @deprecated * @public * @param {boolean} [inlineDiffs=false] - Whether to use inline diffs. * @return {Mocha} this * @chainable */ Mocha.prototype.useInlineDiffs = function(inlineDiffs) { + utils.deprecate( + '"useInlineDiffs()" is DEPRECATED, please use "inlineDiffs()" instead.' + ); this.options.inlineDiffs = inlineDiffs !== undefined && inlineDiffs; return this; }; +/** + * Enables reporter to use inline diffs (rather than +/-) + * in test failure output. + * + * @public + * @return {Mocha} this + * @chainable + */ +Mocha.prototype.inlineDiffs = function() { + this.options.inlineDiffs = true; + return this; +}; + /** * Determines if reporter should include diffs in test failure output. * + * @deprecated * @public * @param {boolean} [hideDiff=false] - Whether to hide diffs. * @return {Mocha} this * @chainable */ Mocha.prototype.hideDiff = function(hideDiff) { + utils.deprecate('"hideDiff()" is DEPRECATED, please use "diff()" instead.'); this.options.diff = !(hideDiff === true); return this; }; +/** + * Enables reporter to include diffs in test failure output. + * + * @public + * @return {Mocha} this + * @chainable + */ +Mocha.prototype.diff = function() { + this.options.diff = true; + return this; +}; + /** * @summary * Sets timeout threshold value.