function Mocha(options = {}) {
  options = {...mocharc, ...options};
  this.files = [];
  this.options = options;
  // root suite
  this.suite = new exports.Suite('', new exports.Context(), true);
  this._cleanReferencesAfterRun = true;
  this._state = mochaStates.INIT;

  this.grep(options.grep)
    .fgrep(options.fgrep)
    .ui(options.ui)
    .reporter(
      options.reporter,
      options['reporter-option'] ||
        options.reporterOption ||
        options.reporterOptions // for backwards compatibility
    )
    .slow(options.slow)
    .global(options.global);

  // 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);
  }

  [
    'allowUncaught',
    'asyncOnly',
    'bail',
    'checkLeaks',
    'color',
    'delay',
    'diff',
    'dryRun',
    'passOnFailingTestSuite',
    'failZero',
    'forbidOnly',
    'forbidPending',
    'fullTrace',
    'inlineDiffs',
    'invert'
  ].forEach(function (opt) {
    if (options[opt]) {
      this[opt]();
    }
  }, this);

  if (options.rootHooks) {
    this.rootHooks(options.rootHooks);
  }

  /**
   * The class which we'll instantiate in {@link Mocha#run}.  Defaults to
   * {@link Runner} in serial mode; changes in parallel mode.
   * @memberof Mocha
   * @private
   */
  this._runnerClass = exports.Runner;

  /**
   * Whether or not to call {@link Mocha#loadFiles} implicitly when calling
   * {@link Mocha#run}.  If this is `true`, then it's up to the consumer to call
   * {@link Mocha#loadFiles} _or_ {@link Mocha#loadFilesAsync}.
   * @private
   * @memberof Mocha
   */
  this._lazyLoadFiles = false;

  /**
   * It's useful for a Mocha instance to know if it's running in a worker process.
   * We could derive this via other means, but it's helpful to have a flag to refer to.
   * @memberof Mocha
   * @private
   */
  this.isWorker = Boolean(options.isWorker);

  this.globalSetup(options.globalSetup)
    .globalTeardown(options.globalTeardown)
    .enableGlobalSetup(options.enableGlobalSetup)
    .enableGlobalTeardown(options.enableGlobalTeardown);

  if (
    options.parallel &&
    (typeof options.jobs === 'undefined' || options.jobs > 1)
  ) {
    debug('attempting to enable parallel mode');
    this.parallelMode(true);
  }
}
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] - Check for global variable leaks?
@param {boolean} [options.color] - Color TTY output from reporter?
@param {boolean} [options.delay] - Delay root suite execution?
@param {boolean} [options.diff] - Show diff on failure?
@param {boolean} [options.dryRun] - Report tests without running them?
@param {boolean} [options.passOnFailingTestSuite] - Fail test run if tests were failed?
@param {boolean} [options.failZero] - Fail test run if zero tests?
@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.fullTrace] - 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.inlineDiffs] - Display inline diffs?
@param {boolean} [options.invert] - Invert test filter matches?
@param {boolean} [options.noHighlighting] - Disable syntax highlighting?
@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.
@param {number|string} [options.timeout] - Timeout threshold value.
@param {string} [options.ui] - Interface name.
@param {boolean} [options.parallel] - Run jobs in parallel.
@param {number} [options.jobs] - Max number of worker processes for parallel runs.
@param {MochaRootHookObject} [options.rootHooks] - Hooks to bootstrap the root suite with.
@param {string[]} [options.require] - Pathname of `rootHooks` plugin for parallel runs.
@param {boolean} [options.isWorker] - Should be `true` if `Mocha` process is running in a worker process.