lib/mocha.js
function Mocha(options) {
  options = utils.assign({}, mocharc, options || {});
  this.files = [];
  this.options = options;
  // root suite
  this.suite = new exports.Suite('', new exports.Context(), true);

  if ('useColors' in options) {
    utils.deprecate(
      'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
    );
    options.color = 'color' in options ? options.color : options.useColors;
  }

  this.grep(options.grep)
    .fgrep(options.fgrep)
    .ui(options.ui)
    .bail(options.bail)
    .reporter(options.reporter, options.reporterOptions)
    .useColors(options.color)
    .slow(options.slow)
    .useInlineDiffs(options.inlineDiffs)
    .globals(options.globals);

  if ('enableTimeouts' in options) {
    utils.deprecate(
      'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
    );
    if (options.enableTimeouts === false) {
      this.timeout(0);
    }
  }

  // this guard exists because Suite#timeout does not consider `undefined` to be valid input
  if (typeof options.timeout !== 'undefined') {
    this.timeout(options.timeout === false ? 0 : options.timeout);
  }

  if ('retries' in options) {
    this.retries(options.retries);
  }

  if ('diff' in options) {
    this.hideDiff(!options.diff);
  }

  [
    'allowUncaught',
    'asyncOnly',
    'checkLeaks',
    'delay',
    'forbidOnly',
    'forbidPending',
    'fullTrace',
    'growl',
    'invert'
  ].forEach(function(opt) {
    if (options[opt]) {
      this[opt]();
    }
  }, this);
}
function Mocha(options) {
  options = utils.assign({}, mocharc, options || {});
  this.files = [];
  this.options = options;
  // root suite
  this.suite = new exports.Suite('', new exports.Context(), true);

  if ('useColors' in options) {
    utils.deprecate(
      'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
    );
    options.color = 'color' in options ? options.color : options.useColors;
  }

  this.grep(options.grep)
    .fgrep(options.fgrep)
    .ui(options.ui)
    .bail(options.bail)
    .reporter(options.reporter, options.reporterOptions)
    .useColors(options.color)
    .slow(options.slow)
    .useInlineDiffs(options.inlineDiffs)
    .globals(options.globals);

  if ('enableTimeouts' in options) {
    utils.deprecate(
      'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
    );
    if (options.enableTimeouts === false) {
      this.timeout(0);
    }
  }

  // this guard exists because Suite#timeout does not consider `undefined` to be valid input
  if (typeof options.timeout !== 'undefined') {
    this.timeout(options.timeout === false ? 0 : options.timeout);
  }

  if ('retries' in options) {
    this.retries(options.retries);
  }

  if ('diff' in options) {
    this.hideDiff(!options.diff);
  }

  [
    'allowUncaught',
    'asyncOnly',
    'checkLeaks',
    'delay',
    'forbidOnly',
    'forbidPending',
    'fullTrace',
    'growl',
    'invert'
  ].forEach(function(opt) {
    if (options[opt]) {
      this[opt]();
    }
  }, this);
}
function Mocha ( options ) { options = utils . assign ( { } , mocharc , options || { } ) ; this . files = [ ] ; this . options = options ; // root suite this . suite = new exports . Suite ( '' , new exports . Context ( ) , true ) ; if ( 'useColors' in options ) { utils . deprecate ( 'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option' ) ; options . color = 'color' in options ? options . color : options . useColors ; } this . grep ( options . grep ) . fgrep ( options . fgrep ) . ui ( options . ui ) . bail ( options . bail ) . reporter ( options . reporter , options . reporterOptions ) . useColors ( options . color ) . slow ( options . slow ) . useInlineDiffs ( options . inlineDiffs ) . globals ( options . globals ) ; if ( 'enableTimeouts' in options ) { utils . deprecate ( 'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.' ) ; if ( options . enableTimeouts === false ) { this . timeout ( 0 ) ; } } // this guard exists because Suite#timeout does not consider `undefined` to be valid input if ( typeof options . timeout !== 'undefined' ) { this . timeout ( options . timeout === false ? 0 : options . timeout ) ; } if ( 'retries' in options ) { this . retries ( options . retries ) ; } if ( 'diff' in options ) { this . hideDiff ( ! options . diff ) ; } [ 'allowUncaught' , 'asyncOnly' , 'checkLeaks' , 'delay' , 'forbidOnly' , 'forbidPending' , 'fullTrace' , 'growl' , 'invert' ] . forEach ( function ( opt ) { if ( options [ opt ] ) { this [ opt ] ( ) ; } } , this ) ; }
Constructs a new Mocha instance with `options`.

@public
@class Mocha
@param {Object} [options] - Settings object.
@param {boolean} [options.allowUncaught] - Propagate uncaught errors?
@param {boolean} [options.asyncOnly] - Force `done` callback or promise?
@param {boolean} [options.bail] - Bail after first test failure?
@param {boolean} [options.checkLeaks] - If true, check leaks.
@param {boolean} [options.delay] - Delay root suite execution?
@param {boolean} [options.enableTimeouts] - Enable timeouts?
@param {string} [options.fgrep] - Test filter given string.
@param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
@param {boolean} [options.forbidPending] - Pending tests fail the suite?
@param {boolean} [options.fullStackTrace] - Full stacktrace upon failure?
@param {string[]} [options.global] - Variables expected in global scope.
@param {RegExp|string} [options.grep] - Test filter given regular expression.
@param {boolean} [options.growl] - Enable desktop notifications?
@param {boolean} [options.hideDiff] - Suppress diffs from failures?
@param {boolean} [options.ignoreLeaks] - Ignore global leaks?
@param {boolean} [options.invert] - Invert test filter matches?
@param {boolean} [options.noHighlighting] - Disable syntax highlighting?
@param {string} [options.reporter] - Reporter name.
@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.color] - Color TTY output from reporter?
@param {boolean} [options.useInlineDiffs] - Use inline diffs?
Constructs a new Mocha instance with options .