Skip to content

Commit

Permalink
browser setup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Oct 16, 2019
1 parent 9584202 commit bcac901
Showing 1 changed file with 52 additions and 7 deletions.
59 changes: 52 additions & 7 deletions lib/mocha.js
Expand Up @@ -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
Expand All @@ -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]) {
Expand Down Expand Up @@ -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;
};
Expand All @@ -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
*/
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit bcac901

Please sign in to comment.