☕️ Classic, reliable, trusted test framework for Node.js and the browser
Remove configuration via 'mocha.opts' (#4175)
Juerg B2f264784d222
diff --git a/docs/index.md b/docs/index.mdindex 1ef8793f..898d8f1d 100644--- a/docs/index.md+++ b/docs/index.md@@ -36,7 +36,6 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in- [auto-exit to prevent "hanging" with an active loop](#-exit)- [easily meta-generate suites](#markdown) & [test-cases](#list)- [config file support](#-config-path)-- [mocha.opts file support](#-opts-path)- clickable suite titles to filter test execution- [node debugger support](#-inspect-inspect-brk-inspect)- [node native ES modules support](#nodejs-native-esm-support)@@ -75,7 +74,6 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in- [Running Mocha in the Browser](#running-mocha-in-the-browser)- [Desktop Notification Support](#desktop-notification-support)- [Configuring Mocha (Node.js)](#configuring-mocha-nodejs)-- [`mocha.opts`](#mochaopts)- [The `test/` Directory](#the-test-directory)- [Error Codes](#error-codes)- [Editor Plugins](#editor-plugins)@@ -865,8 +863,6 @@ Reporting & OutputConfiguration--config Path to config file [string] [default: (nearest rc file)]- --opts Path to `mocha.opts` (DEPRECATED)- [string] [default: "./test/mocha.opts"]--package Path to package.json for config [string]File Handling@@ -1070,11 +1066,7 @@ By default, Mocha will search for a config file if `--config` is not specified;### `--opts <path>`-> _Deprecated in v7.0.0._--Specify a path to [`mocha.opts`](#mochaopts).--By default, Mocha looks for a `mocha.opts` in `test/mocha.opts`; use `--no-opts` to suppress this behavior.+> _Removed in v8.0.0. Please use [configuration file](#configuring-mocha-nodejs) instead._### `--package <path>`@@ -1738,7 +1730,7 @@ tests as shown below:> _New in v6.0.0_-In addition to supporting the deprecated [`mocha.opts`](#mochaopts) run-control format, Mocha now supports configuration files, typical of modern command-line tools, in several formats:+Mocha supports configuration files, typical of modern command-line tools, in several formats:- **JavaScript**: Create a `.mocharc.js` (or `mocharc.cjs` when using [`"type"="module"`](#nodejs-native-esm-support) in your `package.json`)in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration.@@ -1746,8 +1738,6 @@ In addition to supporting the deprecated [`mocha.opts`](#mochaopts) run-control- **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory. Comments — while not valid JSON — are allowed in this file, and will be ignored by Mocha.- **package.json**: Create a `mocha` property in your project's `package.json`.-Mocha suggests using one of the above strategies for configuration instead of the deprecated `mocha.opts` format.-### Custom LocationsYou can specify a custom location for your configuration file with the `--config <path>` option. Mocha will use the file's extension to determine how to parse the file, and will assume JSON if unknown.@@ -1770,12 +1760,11 @@ If no custom path was given, and if there are multiple configuration files in th### Merging-Mocha will also _merge_ any options found in `package.json` _and_ `mocha.opts` into its run-time configuration. In case of conflict, the priority is:+Mocha will also _merge_ any options found in `package.json` into its run-time configuration. In case of conflict, the priority is:1. Arguments specified on command-line1. Configuration file (`.mocharc.js`, `.mocharc.yml`, etc.)1. `mocha` property of `package.json`-1. `mocha.opts`Options which can safely be repeated (e.g., `--require`) will be _concatenated_, with higher-priorty configuration sources appearing earlier in the list. For example, a `.mocharc.json` containing `"require": "bar"`, coupled with execution of `mocha --require foo`, would cause Mocha to require `foo`, then `bar`, in that order.@@ -1790,45 +1779,10 @@ Configurations can inherit from other modules using the `extends` keyword. See [- For options containing a dash (`-`), the option name can be specified using camelCase.- Aliases are valid names, e.g., `R` instead of `reporter`.- Test files can be specified using `spec`, e.g., `"spec": "test/**/*.spec.js"`.-- Flags to `node` are _also_ supported in configuration files, like in `mocha.opts`. Use caution, as these can vary between versions of Node.js!+- Flags to `node` are _also_ supported in configuration files. Use caution, as these can vary between versions of Node.js!**For more configuration examples, see the [`example/config`][example-mocha-config] directory on GitHub.**-## `mocha.opts`--> _`mocha.opts` file support is DEPRECATED and will be removed from a future version of Mocha. We recommend using a configuration file instead._--Mocha will attempt to load `"./test/mocha.opts"` as a run-control file of sorts.--Beginning-of-line comment support is available; any line _starting_ with a-hash (`#`) symbol will be considered a comment. Blank lines may also be used.-Any other line will be treated as a command-line argument (along with any-associated option value) to be used as a default setting. Settings should be-specified one per line.--The lines in this file are prepended to any actual command-line arguments.-As such, actual command-line arguments will take precedence over the defaults.--For example, suppose you have the following `mocha.opts` file:--```bash-# mocha.opts- --require should- --reporter dot- --ui bdd-```--The settings above will default the reporter to `dot`, require the `should`-library, and use `bdd` as the interface. With this, you may then invoke `mocha`-with additional arguments, here changing the reporter to `list` and setting the-slow threshold to half a second:--```bash-$ mocha --reporter list --slow 500-```--To ignore your `mocha.opts`, use the `--no-opts` option.-## The `test/` DirectoryBy default, `mocha` looks for the glob `"./test/*.js"`, so you may want to putdiff --git a/example/config/.mocharc.js b/example/config/.mocharc.jsindex 671520cd..46d4e9de 100644--- a/example/config/.mocharc.js+++ b/example/config/.mocharc.js@@ -7,7 +7,6 @@module.exports = {diff: true,extension: ['js'],- opts: false,package: './package.json',reporter: 'spec',slow: 75,diff --git a/example/config/.mocharc.json b/example/config/.mocharc.jsonindex 43a83e6b..fd71460f 100644--- a/example/config/.mocharc.json+++ b/example/config/.mocharc.json@@ -5,7 +5,6 @@{"diff": true,"extension": ["js"],- "opts": false,"package": "./package.json","reporter": "spec","slow": 75,diff --git a/example/config/.mocharc.jsonc b/example/config/.mocharc.jsoncindex 25a40b68..590bf096 100644--- a/example/config/.mocharc.jsonc+++ b/example/config/.mocharc.jsonc@@ -5,7 +5,6 @@{"diff": true,"extension": ["js"],- "opts": false,"package": /* 📦 */ "./package.json","reporter": /* 📋 */ "spec","slow": 75,diff --git a/example/config/.mocharc.yml b/example/config/.mocharc.ymlindex 226f8184..da5a0a0c 100644--- a/example/config/.mocharc.yml+++ b/example/config/.mocharc.yml@@ -28,7 +28,6 @@ ignore:inline-diffs: false# needs to be used with grep or fgrep# invert: false-opts: falserecursive: falsereporter: specreporter-option:diff --git a/lib/cli/config.js b/lib/cli/config.jsindex 24de6cd4..1be9f9c4 100644--- a/lib/cli/config.js+++ b/lib/cli/config.js@@ -2,7 +2,6 @@/*** Responsible for loading / finding Mocha's "rc" files.- * This doesn't have anything to do with `mocha.opts`.** @private* @modulediff --git a/lib/cli/options.js b/lib/cli/options.jsindex 9fbc22ca..9f9f988e 100644--- a/lib/cli/options.js+++ b/lib/cli/options.js@@ -2,7 +2,7 @@/*** Main entry point for handling filesystem-based configuration,- * whether that's `mocha.opts` or a config file or `package.json` or whatever.+ * whether that's a config file or `package.json` or whatever.* @module*/@@ -15,7 +15,6 @@ const mocharc = require('../mocharc.json');const {list} = require('./run-helpers');const {loadConfig, findConfig} = require('./config');const findUp = require('find-up');-const {deprecate} = require('../utils');const debug = require('debug')('mocha:cli:options');const {isNodeFlag} = require('./node-flags');@@ -143,71 +142,6 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => {return result.argv;};-/**- * - Replaces comments with empty strings- * - Replaces escaped spaces (e.g., 'xxx\ yyy') with HTML space- * - Splits on whitespace, creating array of substrings- * - Filters empty string elements from array- * - Replaces any HTML space with space- * @summary Parses options read from run-control file.- * @private- * @param {string} content - Content read from run-control file.- * @returns {string[]} cmdline options (and associated arguments)- * @ignore- */-const parseMochaOpts = content =>- content- .replace(/^#.*$/gm, '')- .replace(/\\\s/g, '%20')- .split(/\s/)- .filter(Boolean)- .map(value => value.replace(/%20/g, ' '));--/**- * Given filepath in `args.opts`, attempt to load and parse a `mocha.opts` file.- * @param {Object} [args] - Arguments object- * @param {string|boolean} [args.opts] - Filepath to mocha.opts; defaults to whatever's in `mocharc.opts`, or `false` to skip- * @returns {external:yargsParser.Arguments|void} If read, object containing parsed arguments- * @memberof module:lib/cli/options- * @see {@link /#mochaopts|mocha.opts}- * @public- */-const loadMochaOpts = (args = {}) => {- let result;- let filepath = args.opts;- // /dev/null is backwards compat- if (filepath === false || filepath === '/dev/null') {- return result;- }- filepath = filepath || mocharc.opts;- result = {};- let mochaOpts;- try {- mochaOpts = fs.readFileSync(filepath, 'utf8');- debug(`read ${filepath}`);- } catch (err) {- if (args.opts) {- throw new Error(`Unable to read ${filepath}: ${err}`);- }- // ignore otherwise. we tried- debug(`No mocha.opts found at ${filepath}`);- }-- // real args should override `mocha.opts` which should override defaults.- // if there's an exception to catch here, I'm not sure what it is.- // by attaching the `no-opts` arg, we avoid re-parsing of `mocha.opts`.- if (mochaOpts) {- deprecate(- 'Configuration via mocha.opts is DEPRECATED and will be removed from a future version of Mocha. Use RC files or package.json instead.'- );- result = parse(parseMochaOpts(mochaOpts));- debug(`${filepath} parsed succesfully`);- }- return result;-};--module.exports.loadMochaOpts = loadMochaOpts;-/*** Given path to config file in `args.config`, attempt to load & parse config file.* @param {Object} [args] - Arguments object@@ -267,11 +201,10 @@ module.exports.loadPkgRc = loadPkgRc;* 1. Command-line args* 2. RC file (`.mocharc.c?js`, `.mocharc.ya?ml`, `mocharc.json`)* 3. `mocha` prop of `package.json`- * 4. `mocha.opts`- * 5. default configuration (`lib/mocharc.json`)+ * 4. default configuration (`lib/mocharc.json`)** If a {@link module:lib/cli/one-and-dones.ONE_AND_DONE_ARGS "one-and-done" option} is present in the `argv` array, no external config files will be read.- * @summary Parses options read from `mocha.opts`, `.mocharc.*` and `package.json`.+ * @summary Parses options read from `.mocharc.*` and `package.json`.* @param {string|string[]} [argv] - Arguments to parse* @public* @memberof module:lib/cli/options@@ -279,7 +212,7 @@ module.exports.loadPkgRc = loadPkgRc;*/const loadOptions = (argv = []) => {let args = parse(argv);- // short-circuit: look for a flag that would abort loading of mocha.opts+ // short-circuit: look for a flag that would abort loading of optionsif (Array.from(ONE_AND_DONE_ARGS).reduce((acc, arg) => acc || arg in args,@@ -291,7 +224,6 @@ const loadOptions = (argv = []) => {const rcConfig = loadRc(args);const pkgConfig = loadPkgRc(args);- const optsConfig = loadMochaOpts(args);if (rcConfig) {args.config = false;@@ -301,19 +233,8 @@ const loadOptions = (argv = []) => {args.package = false;args._ = args._.concat(pkgConfig._ || []);}- if (optsConfig) {- args.opts = false;- args._ = args._.concat(optsConfig._ || []);- }- args = parse(- args._,- mocharc,- args,- rcConfig || {},- pkgConfig || {},- optsConfig || {}- );+ args = parse(args._, mocharc, args, rcConfig || {}, pkgConfig || {});// recombine positional arguments and "spec"if (args.spec) {diff --git a/lib/cli/run-option-metadata.js b/lib/cli/run-option-metadata.jsindex d0bc92ff..4648d9fb 100644--- a/lib/cli/run-option-metadata.js+++ b/lib/cli/run-option-metadata.js@@ -51,7 +51,6 @@ exports.types = {'config','fgrep','grep',- 'opts','package','reporter','ui',diff --git a/lib/cli/run.js b/lib/cli/run.jsindex 014227d5..d024cbb0 100644--- a/lib/cli/run.js+++ b/lib/cli/run.js@@ -163,13 +163,6 @@ exports.builder = yargs =>group: GROUPS.OUTPUT,hidden: true},- opts: {- default: defaults.opts,- description: 'Path to `mocha.opts` (DEPRECATED)',- group: GROUPS.CONFIG,- normalize: true,- requiresArg: true- },package: {description: 'Path to package.json for config',group: GROUPS.CONFIG,@@ -285,6 +278,13 @@ exports.builder = yargs =>);}+ if (argv.opts) {+ throw createUnsupportedError(+ `--opts: configuring Mocha via 'mocha.opts' is DEPRECATED and no longer supported.+ Please use a configuration file instead.`+ );+ }+// load requires first, because it can impact "plugin" validationhandleRequires(argv.require);validatePlugin(argv, 'reporter', Mocha.reporters);diff --git a/lib/mocharc.json b/lib/mocharc.jsonindex 1ed91576..51c3fce6 100644--- a/lib/mocharc.json+++ b/lib/mocharc.json@@ -1,7 +1,6 @@{"diff": true,"extension": ["js", "cjs", "mjs"],- "opts": "./test/mocha.opts","package": "./package.json","reporter": "spec","slow": 75,diff --git a/package-scripts.js b/package-scripts.jsindex a94de98e..5e0b1736 100644--- a/package-scripts.js+++ b/package-scripts.js@@ -80,8 +80,7 @@ module.exports = {'test.node.jsapi','test.node.requires','test.node.reporters',- 'test.node.only',- 'test.node.opts'+ 'test.node.only'].join(' ')}`,description: 'Run Node.js tests'},@@ -120,14 +119,6 @@ module.exports = {description: 'Run Node.js integration tests',hiddenFromHelp: true},- opts: {- script: test(- 'opts',- '--opts test/opts/mocha.opts test/opts/opts.spec.js --no-config'- ),- description: 'Run tests concerning mocha.opts',- hiddenFromHelp: true- },jsapi: {script: 'node test/jsapi',description: 'Run Node.js Mocha JavaScript API tests',diff --git a/test/integration/fixtures/options/help/test/mocha.opts b/test/integration/fixtures/options/help/test/mocha.optsdeleted file mode 100644index 257cc564..00000000--- a/test/integration/fixtures/options/help/test/mocha.opts+++ /dev/null@@ -1 +0,0 @@-foodiff --git a/test/integration/fixtures/options/opts.fixture.js b/test/integration/fixtures/options/opts.fixture.jsdeleted file mode 100644index 359dc130..00000000--- a/test/integration/fixtures/options/opts.fixture.js+++ /dev/null@@ -1,5 +0,0 @@-'use strict';--describe('opts', function () {- it('should display this spec', function () {});-});diff --git a/test/integration/options/help.spec.js b/test/integration/options/help.spec.jsdeleted file mode 100644index fe182bce..00000000--- a/test/integration/options/help.spec.js+++ /dev/null@@ -1,26 +0,0 @@-'use strict';--var path = require('path');-var helpers = require('../helpers');-var invokeMocha = helpers.invokeMocha;--describe('--help', function() {- it('should work despite the presence of "mocha.opts"', function(done) {- var args = ['-h'];- // :NOTE: Must use platform-specific `path.join` for `spawnOpts.cwd`- var fixtureDir = path.join(__dirname, '..', 'fixtures', 'options', 'help');- var spawnOpts = {cwd: fixtureDir};-- invokeMocha(- args,- function(err, res) {- if (err) {- return done(err);- }- expect(res.output, 'to contain', 'Run tests with Mocha');- done();- },- spawnOpts- );- });-});diff --git a/test/integration/options/opts.spec.js b/test/integration/options/opts.spec.jsindex e3d98581..30b129f3 100644--- a/test/integration/options/opts.spec.js+++ b/test/integration/options/opts.spec.js@@ -1,64 +1,23 @@'use strict';-var path = require('path').posix;-var helpers = require('../helpers');-var runMochaJSON = helpers.runMochaJSON;-var invokeMocha = helpers.invokeMocha;-var resolvePath = helpers.resolveFixturePath;+var invokeMocha = require('../helpers').invokeMocha;describe('--opts', function() {- var args = [];- var fixture = path.join('options', 'opts');-- it('should print a deprecation warning', function(done) {- var mochaOpts = path.join('test', 'opts', 'mocha.opts');- args = [resolvePath(fixture), '--opts', mochaOpts];+ it('should report deprecation', function(done) {invokeMocha(- args,+ ['--opts', './test/mocha.opts'],function(err, res) {if (err) {return done(err);}-- expect(res, 'to have passed');- expect(res.output, 'to contain', 'mocha.opts is DEPRECATED');+ expect(+ res,+ 'to have failed with output',+ /'mocha.opts' is DEPRECATED/i+ );done();},'pipe');});-- it('should work despite nonexistent default options file', function(done) {- args = [];- runMochaJSON(fixture, args, function(err, res) {- if (err) {- return done(err);- }-- expect(res, 'to have passed').and('to have passed test count', 1);- done();- });- });-- it('should throw an error due to nonexistent options file', function(done) {- var spawnOpts = {stdio: 'pipe'};- var nonexistentFile = 'nosuchoptionsfile';- args = ['--opts', nonexistentFile, resolvePath(fixture)];- invokeMocha(- args,- function(err, res) {- if (err) {- return done(err);- }-- var pattern = 'unable to read ' + nonexistentFile;- expect(res, 'to satisfy', {- code: 1,- output: new RegExp(pattern, 'i')- });- done();- },- spawnOpts- );- });});diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.jsindex 84723baf..d60de8e2 100644--- a/test/node-unit/cli/options.spec.js+++ b/test/node-unit/cli/options.spec.js@@ -27,7 +27,6 @@ const defaults = {timeout: 1000,timeouts: 1000,t: 1000,- opts: '/default/path/to/mocha.opts',extension: ['js']};@@ -54,8 +53,7 @@ describe('options', function() {* 1. Command-line args* 2. RC file (`.mocharc.js`, `.mocharc.ya?ml`, `mocharc.json`)* 3. `mocha` prop of `package.json`- * 4. `mocha.opts`- * 5. default rc+ * 4. default rc*/describe('loadOptions()', function() {describe('when no parameter provided', function() {@@ -63,7 +61,6 @@ describe('options', function() {this.timeout(500);readFileSync = sandbox.stub();readFileSync.onFirstCall().returns('{}');- readFileSync.onSecondCall().returns('--retries 3');findConfig = sandbox.stub().returns('/some/.mocharc.json');loadConfig = sandbox.stub().returns({});findupSync = sandbox.stub().returns('/some/package.json');@@ -83,192 +80,13 @@ describe('options', function() {Object.assign({}, defaults, {_: [],config: false,- opts: false,- package: false,- retries: '3'+ package: false}));});});describe('when parameter provided', function() {- describe('mocha.opts', function() {- describe('when path to mocha.opts (`--opts <path>`) is invalid', function() {- describe('when path is not default', function() {- let opts;-- beforeEach(function() {- opts = '/some/other/path/to/mocha.opts';- readFileSync = sandbox.stub();- readFileSync.onFirstCall().returns('{}');- readFileSync.onSecondCall().throws();- findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({});- findupSync = sandbox.stub().returns('/some/package.json');-- loadOptions = proxyLoadOptions({- readFileSync,- findConfig,- loadConfig,- findupSync- });- });-- it('should attempt to load file at path', function() {- try {- loadOptions(`--opts ${opts}`);- } catch (ignored) {}- expect(readFileSync, 'to have a call satisfying', [opts, 'utf8']);- });-- it('should throw', function() {- expect(- () => {- loadOptions(`--opts ${opts}`);- },- 'to throw',- /unable to read/i- );- });- });-- describe('when path to mocha.opts is unspecified', function() {- let result;-- beforeEach(function() {- readFileSync = sandbox.stub();- readFileSync.onFirstCall().returns('{}');- readFileSync.onSecondCall().returns('{}');- readFileSync.onThirdCall().throws();- findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({});- findupSync = sandbox.stub().returns('/some/package.json');-- loadOptions = proxyLoadOptions({- readFileSync,- findConfig,- loadConfig,- findupSync- });-- result = loadOptions();- });-- it('should attempt to load default mocha.opts', function() {- expect(readFileSync, 'to have a call satisfying', [- defaults.opts,- 'utf8'- ]);- });-- it('should set opts = false', function() {- expect(result, 'to have property', 'opts', false);- });- });- });-- describe('when path to mocha.opts (`--opts <path>`) is valid', function() {- let result;- beforeEach(function() {- const filepath = '/path/to/mocha.opts';- readFileSync = sandbox.stub();- // package.json- readFileSync.onFirstCall().throws();- // mocha.opts- readFileSync.onSecondCall().returns('--retries 3 foobar.spec.js');- findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({});- findupSync = sandbox.stub().returns('/some/package.json');- loadOptions = proxyLoadOptions({- readFileSync,- findConfig,- loadConfig,- findupSync- });- result = loadOptions(['--opts', filepath]);- });-- it('should return merged options incl. mocha.opts', function() {- expect(- result,- 'to equal',- Object.assign(- {- _: ['foobar.spec.js']- },- defaults,- {- config: false,- opts: false,- package: false,- retries: '3'- }- )- );- });-- it('should have attempted to load two files', function() {- expect(readFileSync, 'was called times', 2).and(- 'to have calls satisfying',- [- {args: ['/some/package.json', 'utf8']},- {args: ['/path/to/mocha.opts', 'utf8']}- ]- );- });-- it('should set opts = false', function() {- expect(result, 'to have property', 'opts', false);- });- });-- describe('when called with opts = false (`--no-opts`)', function() {- let result;- beforeEach(function() {- readFileSync = sandbox- .stub()- .returns('{"mocha": {"check-leaks": false}}');- findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({retries: 3});- findupSync = sandbox.stub().returns('/some/package.json');-- loadOptions = proxyLoadOptions({- readFileSync,- findConfig,- loadConfig,- findupSync- });-- result = loadOptions('--no-opts');- });-- it('should return parsed args, default config, config file, and package.json', function() {- expect(- result,- 'to equal',- Object.assign({_: []}, defaults, {- 'check-leaks': false,- config: false,- opts: false,- package: false,- retries: 3- })- );- });-- it('should not attempt to read any mocha.opts', function() {- expect(readFileSync, 'was called times', 1).and(- 'to have all calls satisfying',- ['/some/package.json', 'utf8']- );- });-- it('should set opts = false', function() {- expect(result, 'to have property', 'opts', false);- });- });- });-describe('package.json', function() {describe('when path to package.json (`--package <path>`) is valid', function() {let result;@@ -278,8 +96,6 @@ describe('options', function() {readFileSync = sandbox.stub();// package.jsonreadFileSync.onFirstCall().returns('{"mocha": {"retries": 3}}');- // mocha.opts- readFileSync.onSecondCall().throws();findConfig = sandbox.stub().returns('/some/.mocharc.json');loadConfig = sandbox.stub().returns({});findupSync = sandbox.stub();@@ -303,7 +119,6 @@ describe('options', function() {defaults,{config: false,- opts: false,package: false,retries: 3}@@ -325,8 +140,6 @@ describe('options', function() {readFileSync = sandbox.stub();// package.jsonreadFileSync.onFirstCall().throws('yikes');- // mocha.opts- readFileSync.onSecondCall().throws();findConfig = sandbox.stub().returns('/some/.mocharc.json');loadConfig = sandbox.stub().returns({});findupSync = sandbox.stub();@@ -359,8 +172,6 @@ describe('options', function() {readFileSync.onFirstCall().returns('{"mocha": {"retries": 3, "_": ["foobar.spec.js"]}}');- // mocha.opts- readFileSync.onSecondCall().throws();findConfig = sandbox.stub().returns('/some/.mocharc.json');loadConfig = sandbox.stub().returns({});findupSync = sandbox.stub().returns(filepath);@@ -384,7 +195,6 @@ describe('options', function() {defaults,{config: false,- opts: false,package: false,retries: 3}@@ -401,8 +211,7 @@ describe('options', function() {let result;beforeEach(function() {readFileSync = sandbox.stub();-- readFileSync.onFirstCall().returns('--retries 3');+ readFileSync.onFirstCall().returns('{}');findConfig = sandbox.stub().returns('/some/path/to/.mocharc.json');loadConfig = sandbox.stub().returns({'check-leaks': true});findupSync = sandbox.stub().returns('/some/package.json');@@ -414,19 +223,18 @@ describe('options', function() {findupSync});- result = loadOptions('--no-package');+ result = loadOptions('--no-diff --no-package');});- it('should return parsed args, default config, package.json and mocha.opts', function() {+ it('should return parsed args and default config', function() {expect(result,'to equal',Object.assign({_: []}, defaults, {+ diff: false,'check-leaks': true,config: false,- opts: false,- package: false,- retries: '3'+ package: false}));});@@ -451,7 +259,6 @@ describe('options', function() {.returns('{"mocha": {"check-leaks": true, "_": ["foobar.spec.js"]}}');- readFileSync.onSecondCall().returns('--retries 3 foobar.spec.js');findConfig = sandbox.stub();loadConfig = sandbox.stub();findupSync = sandbox.stub().returns('/some/package.json');@@ -463,19 +270,18 @@ describe('options', function() {findupSync});- result = loadOptions('--no-config');+ result = loadOptions('--no-diff --no-config');});- it('should return parsed args, default config, package.json and mocha.opts', function() {+ it('should return parsed args, default config and package.json', function() {expect(result,'to equal',Object.assign({_: ['foobar.spec.js']}, defaults, {+ diff: false,'check-leaks': true,config: false,- opts: false,- package: false,- retries: '3'+ package: false}));});@@ -500,7 +306,6 @@ describe('options', function() {readFileSync = sandbox.stub();config = '/some/.mocharc.json';readFileSync.onFirstCall().returns('{}');- readFileSync.onSecondCall().returns('--retries 3');findConfig = sandbox.stub();loadConfig = sandbox.stub().throws('Error', 'failed to parse');findupSync = sandbox.stub().returns('/some/package.json');@@ -613,30 +418,13 @@ describe('options', function() {});describe('config priority', function() {- it('should prioritize mocha.opts over defaults', function() {- readFileSync = sandbox.stub();- readFileSync.onFirstCall().returns('{}');- readFileSync.onSecondCall().returns('--timeout 800 --require foo');- findConfig = sandbox.stub().returns('/some/.mocharc.json');- loadConfig = sandbox.stub().returns({});- findupSync = sandbox.stub().returns('/some/package.json');-- loadOptions = proxyLoadOptions({- readFileSync,- findConfig,- loadConfig,- findupSync- });-- expect(loadOptions(), 'to satisfy', {timeout: '800', require: ['foo']});- });-- it('should prioritize package.json over mocha.opts', function() {+ it('should prioritize package.json over defaults', function() {readFileSync = sandbox.stub();readFileSync.onFirstCall()- .returns('{"mocha": {"timeout": 700, "require": "bar"}}');- readFileSync.onSecondCall().returns('--timeout 800 --require foo');+ .returns(+ '{"mocha": {"timeout": 700, "require": "bar", "extension": "ts"}}'+ );findConfig = sandbox.stub().returns('/some/.mocharc.json');loadConfig = sandbox.stub().returns({});findupSync = sandbox.stub().returns('/some/package.json');@@ -650,7 +438,8 @@ describe('options', function() {expect(loadOptions(), 'to satisfy', {timeout: 700,- require: ['bar', 'foo']+ require: ['bar'],+ extension: ['ts']});});diff --git a/test/opts/mocha.opts b/test/opts/mocha.optsdeleted file mode 100644index c212a5b0..00000000--- a/test/opts/mocha.opts+++ /dev/null@@ -1,10 +0,0 @@-###-### mocha.opts-###----require test/setup---ui bdd---globals okGlobalA,okGlobalB---globals okGlobalC---globals callback*---timeout 300diff --git a/test/opts/opts.spec.js b/test/opts/opts.spec.jsdeleted file mode 100644index 74860421..00000000--- a/test/opts/opts.spec.js+++ /dev/null@@ -1,11 +0,0 @@-'use strict';--// as of this writing we're using a config file instead of mocha.opts,-// so to run this test, we must use `--opts test/opts/mocha.opts`-// and `--no-config`.-describe('--opts', function() {- it('should use options present in test `mocha.opts`', function() {- // this will fail if config file was used and/or mocha.opts didn't load.- expect(this.timeout(), 'to be', 300);- });-});