mocha 6.2.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,77 @@
1
+ # 7.0.0 / 2020-01-05
2
+
3
+ ## :boom: Breaking Changes
4
+
5
+ - [#3885](https://github.com/mochajs/mocha/issues/3885): **Drop Node.js v6.x support** ([**@mojosoeun**](https://github.com/mojosoeun))
6
+ - [#3890](https://github.com/mochajs/mocha/issues/3890): Remove Node.js debug-related flags `--debug`/`--debug-brk` and deprecate `debug` argument ([**@juergba**](https://github.com/juergba))
7
+ - [#3962](https://github.com/mochajs/mocha/issues/3962): Changes to command-line options ([**@ParkSB**](https://github.com/ParkSB)):
8
+ - `--list-interfaces` replaces `--interfaces`
9
+ - `--list-reporters` replaces `--reporters`
10
+ - Hook pattern of `this.skip()` ([**@juergba**](https://github.com/juergba)):
11
+ - [#3859](https://github.com/mochajs/mocha/issues/3859): When conditionally skipping in a `it` test, related `afterEach` hooks are now executed
12
+ - [#3741](https://github.com/mochajs/mocha/issues/3741): When conditionally skipping in a `beforeEach` hook, subsequent inner `beforeEach` hooks are now skipped and related `afterEach` hooks are executed
13
+ - [#4136](https://github.com/mochajs/mocha/issues/4136): Disallow `this.skip()` within `after` hooks
14
+ - [#3967](https://github.com/mochajs/mocha/issues/3967): Remove deprecated `getOptions()` and `lib/cli/options.js` ([**@juergba**](https://github.com/juergba))
15
+ - [#4083](https://github.com/mochajs/mocha/issues/4083): Uncaught exception in `pending` test: don't swallow, but retrospectively fail the test for correct exit code ([**@juergba**](https://github.com/juergba))
16
+ - [#4004](https://github.com/mochajs/mocha/issues/4004): Align `Mocha` constructor's option names with command-line options ([**@juergba**](https://github.com/juergba))
17
+
18
+ ## :tada: Enhancements
19
+
20
+ - [#3980](https://github.com/mochajs/mocha/issues/3980): Refactor and improve `--watch` mode with chokidar ([**@geigerzaehler**](https://github.com/geigerzaehler)):
21
+ - adds command-line options `--watch-files` and `--watch-ignore`
22
+ - removes `--watch-extensions`
23
+ - [#3979](https://github.com/mochajs/mocha/issues/3979): Type "rs\\n" to restart tests ([**@broofa**](https://github.com/broofa))
24
+
25
+ ## :fax: Deprecations
26
+
27
+ These are _soft_-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha:
28
+
29
+ - [#3968](https://github.com/mochajs/mocha/issues/3968): Deprecate legacy configuration via `mocha.opts` ([**@juergba**](https://github.com/juergba))
30
+
31
+ ## :bug: Fixes
32
+
33
+ - [#4125](https://github.com/mochajs/mocha/issues/4125): Fix timeout handling with `--inspect-brk`/`--inspect` ([**@juergba**](https://github.com/juergba))
34
+ - [#4070](https://github.com/mochajs/mocha/issues/4070): `Mocha` constructor: improve browser setup ([**@juergba**](https://github.com/juergba))
35
+ - [#4068](https://github.com/mochajs/mocha/issues/4068): XUnit reporter should handle exceptions during diff generation ([**@rgroothuijsen**](https://github.com/rgroothuijsen))
36
+ - [#4030](https://github.com/mochajs/mocha/issues/4030): Fix `--allow-uncaught` with `this.skip()` ([**@juergba**](https://github.com/juergba))
37
+
38
+ ## :mag: Coverage
39
+
40
+ - [#4109](https://github.com/mochajs/mocha/issues/4109): Add Node.js v13.x to CI test matrix ([**@juergba**](https://github.com/juergba))
41
+
42
+ ## :book: Documentation
43
+
44
+ - [#4129](https://github.com/mochajs/mocha/issues/4129): Fix broken links ([**@SaeromB**](https://github.com/SaeromB))
45
+ - [#4127](https://github.com/mochajs/mocha/issues/4127): Add reporter alias names to docs ([**@khg0712**](https://github.com/khg0712))
46
+ - [#4101](https://github.com/mochajs/mocha/issues/4101): Clarify invalid usage of `done()` ([**@jgehrcke**](https://github.com/jgehrcke))
47
+ - [#4092](https://github.com/mochajs/mocha/issues/4092): Replace `:coffee:` with emoji ☕️ ([**@pzrq**](https://github.com/pzrq))
48
+ - [#4088](https://github.com/mochajs/mocha/issues/4088): Initial draft of project charter ([**@boneskull**](https://github.com/boneskull))
49
+ - [#4066](https://github.com/mochajs/mocha/issues/4066): Change `sh` to `bash` for code block in docs/index.md ([**@HyunSangHan**](https://github.com/HyunSangHan))
50
+ - [#4045](https://github.com/mochajs/mocha/issues/4045): Update README.md concerning GraphicsMagick installation ([**@HyunSangHan**](https://github.com/HyunSangHan))
51
+ - [#3988](https://github.com/mochajs/mocha/issues/3988): Fix sponsors background color for readability ([**@outsideris**](https://github.com/outsideris))
52
+
53
+ ## :nut_and_bolt: Other
54
+
55
+ - [#4118](https://github.com/mochajs/mocha/issues/4118): Update node-environment-flags to 1.0.6 ([**@kylef**](https://github.com/kylef))
56
+ - [#4097](https://github.com/mochajs/mocha/issues/4097): Add GH Funding Metadata ([**@SheetJSDev**](https://github.com/SheetJSDev))
57
+ - [#4089](https://github.com/mochajs/mocha/issues/4089): Add funding information to `package.json` ([**@Munter**](https://github.com/Munter))
58
+ - [#4077](https://github.com/mochajs/mocha/issues/4077): Improve integration tests ([**@soobing**](https://github.com/soobing))
59
+
60
+ # 6.2.2 / 2019-10-18
61
+
62
+ ## :bug: Fixes
63
+
64
+ - [#4025](https://github.com/mochajs/mocha/issues/4025): Fix duplicate `EVENT_RUN_END` events upon uncaught exception ([**@juergba**](https://github.com/juergba))
65
+ - [#4051](https://github.com/mochajs/mocha/issues/4051): Fix "unhide" function in `html` reporter (browser) ([**@pec9399**](https://github.com/pec9399))
66
+ - [#4063](https://github.com/mochajs/mocha/issues/4063): Fix use of [esm](https://npm.im/esm) in Node.js v8.x ([**@boneskull**](https://github.com/boneskull))
67
+ - [#4033](https://github.com/mochajs/mocha/issues/4033): Fix output when multiple async exceptions are thrown ([**@juergba**](https://github.com/juergba))
68
+
69
+ ## :book: Documentation
70
+
71
+ - [#4046](https://github.com/mochajs/mocha/issues/4046): Site accessibility fixes ([**@Mia-jeong**](https://github.com/Mia-jeong))
72
+ - [#4026](https://github.com/mochajs/mocha/issues/4026): Update docs for custom reporters in browser ([**@Lindsay-Needs-Sleep**](https://github.com/Lindsay-Needs-Sleep))
73
+ - [#3971](https://github.com/mochajs/mocha/issues/3971): Adopt new OpenJS Foundation Code of Conduct ([**@craigtaub**](https://github.com/craigtaub))
74
+
1
75
  # 6.2.1 / 2019-09-29
2
76
 
3
77
  ## :bug: Fixes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://cldup.com/xFVFxOioAU.svg" alt="Mocha test framework"/>
3
3
  </p>
4
4
 
5
- <p align="center">:coffee: Simple, flexible, fun JavaScript test framework for Node.js & The Browser :coffee:</p>
5
+ <p align="center">☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️</p>
6
6
 
7
7
  <p align="center"><a href="http://travis-ci.org/mochajs/mocha"><img src="https://api.travis-ci.org/mochajs/mocha.svg?branch=master" alt="Build Status"></a> <a href="https://coveralls.io/github/mochajs/mocha"><img src="https://coveralls.io/repos/github/mochajs/mocha/badge.svg" alt="Coverage Status"></a> <a href="https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_shield"><img src="https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha.svg?type=shield" alt="FOSSA Status"></a> <a href="https://gitter.im/mochajs/mocha?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter"></a> <a href="https://github.com/mochajs/mocha#backers"><img src="https://opencollective.com/mochajs/backers/badge.svg" alt="OpenCollective"></a> <a href="https://github.com/mochajs/mocha#sponsors"><img src="https://opencollective.com/mochajs/sponsors/badge.svg" alt="OpenCollective"></a>
8
8
  </p>
@@ -56,39 +56,39 @@
56
56
 
57
57
  ## Sponsors
58
58
 
59
- Does your company use Mocha? Ask your manager or marketing team if your company would be interested in supporting our project. Support will allow the maintainers to dedicate more time for maintenance and new features for everyone. Also, your company's logo will show [on GitHub](https://github.com/mochajs/mocha#readme) and on [our site](https://mochajs.org) - who doesn't want a little extra exposure? [Here's the info](https://opencollective.com/mochajs#sponsor).
60
-
61
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/0/avatar)](https://opencollective.com/mochajs/sponsor/0/website)
62
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/1/avatar)](https://opencollective.com/mochajs/sponsor/1/website)
63
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/2/avatar)](https://opencollective.com/mochajs/sponsor/2/website)
64
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/3/avatar)](https://opencollective.com/mochajs/sponsor/3/website)
65
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/4/avatar)](https://opencollective.com/mochajs/sponsor/4/website)
66
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/5/avatar)](https://opencollective.com/mochajs/sponsor/5/website)
67
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/6/avatar)](https://opencollective.com/mochajs/sponsor/6/website)
68
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/7/avatar)](https://opencollective.com/mochajs/sponsor/7/website)
69
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/8/avatar)](https://opencollective.com/mochajs/sponsor/8/website)
70
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/9/avatar)](https://opencollective.com/mochajs/sponsor/9/website)
71
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/10/avatar)](https://opencollective.com/mochajs/sponsor/10/website)
72
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/11/avatar)](https://opencollective.com/mochajs/sponsor/11/website)
73
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/12/avatar)](https://opencollective.com/mochajs/sponsor/12/website)
74
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/13/avatar)](https://opencollective.com/mochajs/sponsor/13/website)
75
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/14/avatar)](https://opencollective.com/mochajs/sponsor/14/website)
76
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/15/avatar)](https://opencollective.com/mochajs/sponsor/15/website)
77
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/16/avatar)](https://opencollective.com/mochajs/sponsor/16/website)
78
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/17/avatar)](https://opencollective.com/mochajs/sponsor/17/website)
79
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/18/avatar)](https://opencollective.com/mochajs/sponsor/18/website)
80
- [![MochaJS Backer](https://opencollective.com/mochajs/sponsor/19/avatar)](https://opencollective.com/mochajs/sponsor/19/website)
59
+ Does your company use Mocha? Ask your manager or marketing team if your company would be interested in supporting our project. Support will allow the maintainers to dedicate more time for maintenance and new features for everyone. Also, your company's logo will show [on GitHub](https://github.com/mochajs/mocha#readme) and on [our site](https://mochajs.org) - who doesn't want a little extra exposure? [Here's the info](https://opencollective.com/mochajs#sponsor).
60
+
61
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/0/avatar)](https://opencollective.com/mochajs/sponsor/0/website)
62
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/1/avatar)](https://opencollective.com/mochajs/sponsor/1/website)
63
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/2/avatar)](https://opencollective.com/mochajs/sponsor/2/website)
64
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/3/avatar)](https://opencollective.com/mochajs/sponsor/3/website)
65
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/4/avatar)](https://opencollective.com/mochajs/sponsor/4/website)
66
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/5/avatar)](https://opencollective.com/mochajs/sponsor/5/website)
67
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/6/avatar)](https://opencollective.com/mochajs/sponsor/6/website)
68
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/7/avatar)](https://opencollective.com/mochajs/sponsor/7/website)
69
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/8/avatar)](https://opencollective.com/mochajs/sponsor/8/website)
70
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/9/avatar)](https://opencollective.com/mochajs/sponsor/9/website)
71
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/10/avatar)](https://opencollective.com/mochajs/sponsor/10/website)
72
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/11/avatar)](https://opencollective.com/mochajs/sponsor/11/website)
73
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/12/avatar)](https://opencollective.com/mochajs/sponsor/12/website)
74
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/13/avatar)](https://opencollective.com/mochajs/sponsor/13/website)
75
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/14/avatar)](https://opencollective.com/mochajs/sponsor/14/website)
76
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/15/avatar)](https://opencollective.com/mochajs/sponsor/15/website)
77
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/16/avatar)](https://opencollective.com/mochajs/sponsor/16/website)
78
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/17/avatar)](https://opencollective.com/mochajs/sponsor/17/website)
79
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/18/avatar)](https://opencollective.com/mochajs/sponsor/18/website)
80
+ [![MochaJS Sponsor](https://opencollective.com/mochajs/sponsor/19/avatar)](https://opencollective.com/mochajs/sponsor/19/website)
81
81
 
82
82
  ## Development
83
83
 
84
84
  You might want to know that:
85
85
 
86
- - Mocha is the *most-depended-upon* module on npm (source: [libraries.io](https://libraries.io/search?order=desc&platforms=NPM&sort=dependents_count)), and
87
- - Mocha is an *independent* open-source project, maintained exclusively by volunteers.
86
+ - Mocha is the _most-depended-upon_ module on npm (source: [libraries.io](https://libraries.io/search?order=desc&platforms=NPM&sort=dependents_count)), and
87
+ - Mocha is an _independent_ open-source project, maintained exclusively by volunteers.
88
88
 
89
89
  You might want to help:
90
90
 
91
- - New to contributing to Mocha? Check out this list of [good first issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue)
91
+ - New to contributing to Mocha? Check out this list of [good first issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-issue)
92
92
  - Mocha could use a hand with [these issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
93
93
  - The [maintainer's handbook](https://github.com/mochajs/mocha/blob/master/MAINTAINERS.md) explains how things get done
94
94
 
package/bin/mocha CHANGED
@@ -10,7 +10,7 @@
10
10
  * @private
11
11
  */
12
12
 
13
- const {deprecate, warn} = require('../lib/utils');
13
+ const {deprecate} = require('../lib/utils');
14
14
  const {loadOptions} = require('../lib/cli/options');
15
15
  const {
16
16
  unparseNodeFlags,
@@ -20,7 +20,6 @@ const {
20
20
  const unparse = require('yargs-unparser');
21
21
  const debug = require('debug')('mocha:cli:mocha');
22
22
  const {aliases} = require('../lib/cli/run-option-metadata');
23
- const nodeEnv = require('node-environment-flags');
24
23
 
25
24
  const mochaArgs = {};
26
25
  const nodeArgs = {};
@@ -55,59 +54,29 @@ const trimV8Option = value =>
55
54
  Object.keys(opts).forEach(opt => {
56
55
  if (isNodeFlag(opt)) {
57
56
  nodeArgs[trimV8Option(opt)] = opts[opt];
58
- disableTimeouts(opt);
59
57
  } else {
60
58
  mochaArgs[opt] = opts[opt];
61
59
  }
62
60
  });
63
61
 
62
+ // disable 'timeout' for debugFlags
63
+ Object.keys(nodeArgs).forEach(opt => disableTimeouts(opt));
64
+
64
65
  // Native debugger handling
65
66
  // see https://nodejs.org/api/debugger.html#debugger_debugger
66
- // look for 'debug' or 'inspect' that would launch this debugger,
67
+ // look for 'inspect' or 'debug' that would launch this debugger,
67
68
  // remove it from Mocha's opts and prepend it to Node's opts.
68
- // also coerce depending on Node.js version.
69
69
  // A deprecation warning will be printed by node, if applicable.
70
70
  // (mochaArgs._ are "positional" arguments, not prefixed with - or --)
71
- if (/^(debug|inspect)$/.test(mochaArgs._[0])) {
72
- const command = mochaArgs._.shift();
73
- disableTimeouts(command);
74
- // don't conflict with inspector
75
- ['debug', 'inspect', 'debug-brk', 'inspect-brk']
76
- .filter(opt => opt in nodeArgs || opt in mochaArgs)
77
- .forEach(opt => {
78
- warn(`command "${command}" provided; --${opt} ignored`);
79
- delete nodeArgs[opt];
80
- delete mochaArgs[opt];
81
- });
82
- nodeArgs._ = [
83
- parseInt(
84
- process.version
85
- .slice(1)
86
- .split('.')
87
- .shift(),
88
- 10
89
- ) >= 8
90
- ? 'inspect'
91
- : 'debug'
92
- ];
71
+ if (mochaArgs._) {
72
+ const i = mochaArgs._.findIndex(val => val === 'inspect' || val === 'debug');
73
+ if (i > -1) {
74
+ const [command] = mochaArgs._.splice(i, 1);
75
+ disableTimeouts('inspect');
76
+ nodeArgs._ = [command];
77
+ }
93
78
  }
94
79
 
95
- // allow --debug to invoke --inspect on Node.js v8 or newer.
96
- ['debug', 'debug-brk']
97
- .filter(opt => opt in nodeArgs && !nodeEnv.has(opt))
98
- .forEach(opt => {
99
- const newOpt = opt === 'debug' ? 'inspect' : 'inspect-brk';
100
- warn(
101
- `"--${opt}" is not available in Node.js ${
102
- process.version
103
- }; use "--${newOpt}" instead.`
104
- );
105
- nodeArgs[newOpt] = nodeArgs[opt];
106
- mochaArgs.timeout = false;
107
- debug(`--${opt} -> ${newOpt}`);
108
- delete nodeArgs[opt];
109
- });
110
-
111
80
  // historical
112
81
  if (nodeArgs.gc) {
113
82
  deprecate(
@@ -14,7 +14,7 @@ const unparse = require('yargs-unparser');
14
14
  * @see {@link impliesNoTimeouts}
15
15
  * @private
16
16
  */
17
- const debugFlags = new Set(['debug', 'debug-brk', 'inspect', 'inspect-brk']);
17
+ const debugFlags = new Set(['inspect', 'inspect-brk']);
18
18
 
19
19
  /**
20
20
  * Mocha has historical support for various `node` and V8 flags which might not
@@ -68,6 +68,7 @@ exports.impliesNoTimeouts = flag => debugFlags.has(flag);
68
68
  /**
69
69
  * All non-strictly-boolean arguments to node--those with values--must specify those values using `=`, e.g., `--inspect=0.0.0.0`.
70
70
  * Unparse these arguments using `yargs-unparser` (which would result in `--inspect 0.0.0.0`), then supply `=` where we have values.
71
+ * Apparently --require in Node.js v8 does NOT want `=`.
71
72
  * There's probably an easier or more robust way to do this; fixes welcome
72
73
  * @param {Object} opts - Arguments object
73
74
  * @returns {string[]} Unparsed arguments using `=` to specify values
@@ -79,7 +80,9 @@ exports.unparseNodeFlags = opts => {
79
80
  ? args
80
81
  .join(' ')
81
82
  .split(/\b/)
82
- .map(arg => (arg === ' ' ? '=' : arg))
83
+ .map((arg, index, args) =>
84
+ arg === ' ' && args[index - 1] !== 'require' ? '=' : arg
85
+ )
83
86
  .join('')
84
87
  .split(' ')
85
88
  : [];
@@ -48,14 +48,14 @@ exports.ONE_AND_DONES = {
48
48
  * Dump list of built-in interfaces
49
49
  * @private
50
50
  */
51
- interfaces: () => {
51
+ 'list-interfaces': () => {
52
52
  showKeys(Mocha.interfaces);
53
53
  },
54
54
  /**
55
55
  * Dump list of built-in reporters
56
56
  * @private
57
57
  */
58
- reporters: () => {
58
+ 'list-reporters': () => {
59
59
  showKeys(Mocha.reporters);
60
60
  }
61
61
  };
@@ -163,46 +163,13 @@ const parseMochaOpts = content =>
163
163
  .filter(Boolean)
164
164
  .map(value => value.replace(/%20/g, ' '));
165
165
 
166
- /**
167
- * Prepends options from run-control file to the command line arguments.
168
- *
169
- * @deprecated Deprecated in v6.0.0; This function is no longer used internally and will be removed in a future version.
170
- * @public
171
- * @alias module:lib/cli/options
172
- * @see {@link https://mochajs.org/#mochaopts|mocha.opts}
173
- */
174
- module.exports = function getOptions() {
175
- deprecate(
176
- 'getOptions() is DEPRECATED and will be removed from a future version of Mocha. Use loadOptions() instead'
177
- );
178
- if (process.argv.length === 3 && ONE_AND_DONE_ARGS.has(process.argv[2])) {
179
- return;
180
- }
181
-
182
- const optsPath =
183
- process.argv.indexOf('--opts') === -1
184
- ? mocharc.opts
185
- : process.argv[process.argv.indexOf('--opts') + 1];
186
-
187
- try {
188
- const options = parseMochaOpts(fs.readFileSync(optsPath, 'utf8'));
189
-
190
- process.argv = process.argv
191
- .slice(0, 2)
192
- .concat(options.concat(process.argv.slice(2)));
193
- } catch (ignore) {
194
- // NOTE: should console.error() and throw the error
195
- }
196
-
197
- process.env.LOADED_MOCHA_OPTS = true;
198
- };
199
-
200
166
  /**
201
167
  * Given filepath in `args.opts`, attempt to load and parse a `mocha.opts` file.
202
168
  * @param {Object} [args] - Arguments object
203
169
  * @param {string|boolean} [args.opts] - Filepath to mocha.opts; defaults to whatever's in `mocharc.opts`, or `false` to skip
204
170
  * @returns {external:yargsParser.Arguments|void} If read, object containing parsed arguments
205
171
  * @memberof module:lib/cli/options
172
+ * @see {@link /#mochaopts|mocha.opts}
206
173
  * @public
207
174
  */
208
175
  const loadMochaOpts = (args = {}) => {
@@ -230,6 +197,9 @@ const loadMochaOpts = (args = {}) => {
230
197
  // if there's an exception to catch here, I'm not sure what it is.
231
198
  // by attaching the `no-opts` arg, we avoid re-parsing of `mocha.opts`.
232
199
  if (mochaOpts) {
200
+ deprecate(
201
+ 'Configuration via mocha.opts is DEPRECATED and will be removed from a future version of Mocha. Use RC files or package.json instead.'
202
+ );
233
203
  result = parse(parseMochaOpts(mochaOpts));
234
204
  debug(`${filepath} parsed succesfully`);
235
205
  }
@@ -118,13 +118,14 @@ exports.runMocha = (mocha, options) => {
118
118
  const {
119
119
  watch = false,
120
120
  extension = [],
121
- ui = 'bdd',
122
121
  exit = false,
123
122
  ignore = [],
124
123
  file = [],
125
124
  recursive = false,
126
125
  sort = false,
127
- spec = []
126
+ spec = [],
127
+ watchFiles,
128
+ watchIgnore
128
129
  } = options;
129
130
 
130
131
  const fileCollectParams = {
@@ -137,7 +138,7 @@ exports.runMocha = (mocha, options) => {
137
138
  };
138
139
 
139
140
  if (watch) {
140
- watchRun(mocha, {ui}, fileCollectParams);
141
+ watchRun(mocha, {watchFiles, watchIgnore}, fileCollectParams);
141
142
  } else {
142
143
  exports.singleRun(mocha, {exit}, fileCollectParams);
143
144
  }
@@ -18,9 +18,11 @@ exports.types = {
18
18
  'file',
19
19
  'global',
20
20
  'ignore',
21
- 'require',
22
21
  'reporter-option',
23
- 'spec'
22
+ 'require',
23
+ 'spec',
24
+ 'watch-files',
25
+ 'watch-ignore'
24
26
  ],
25
27
  boolean: [
26
28
  'allow-uncaught',
@@ -36,11 +38,11 @@ exports.types = {
36
38
  'full-trace',
37
39
  'growl',
38
40
  'inline-diffs',
39
- 'interfaces',
40
41
  'invert',
42
+ 'list-interfaces',
43
+ 'list-reporters',
41
44
  'no-colors',
42
45
  'recursive',
43
- 'reporters',
44
46
  'sort',
45
47
  'watch'
46
48
  ],
@@ -68,7 +70,6 @@ exports.aliases = {
68
70
  'async-only': ['A'],
69
71
  bail: ['b'],
70
72
  color: ['c', 'colors'],
71
- extension: ['watch-extensions'],
72
73
  fgrep: ['f'],
73
74
  global: ['globals'],
74
75
  grep: ['g'],
package/lib/cli/run.js CHANGED
@@ -38,7 +38,7 @@ const GROUPS = {
38
38
  CONFIG: 'Configuration'
39
39
  };
40
40
 
41
- exports.command = ['$0 [spec..]', 'debug [spec..]'];
41
+ exports.command = ['$0 [spec..]', 'inspect'];
42
42
 
43
43
  exports.describe = 'Run tests with Mocha';
44
44
 
@@ -88,7 +88,7 @@ exports.builder = yargs =>
88
88
  extension: {
89
89
  default: defaults.extension,
90
90
  defaultDescription: 'js',
91
- description: 'File extension(s) to load and/or watch',
91
+ description: 'File extension(s) to load',
92
92
  group: GROUPS.FILES,
93
93
  requiresArg: true,
94
94
  coerce: list
@@ -147,14 +147,18 @@ exports.builder = yargs =>
147
147
  'Display actual/expected differences inline within each string',
148
148
  group: GROUPS.OUTPUT
149
149
  },
150
- interfaces: {
151
- conflicts: Array.from(ONE_AND_DONE_ARGS),
152
- description: 'List built-in user interfaces & exit'
153
- },
154
150
  invert: {
155
151
  description: 'Inverts --grep and --fgrep matches',
156
152
  group: GROUPS.FILTERS
157
153
  },
154
+ 'list-interfaces': {
155
+ conflicts: Array.from(ONE_AND_DONE_ARGS),
156
+ description: 'List built-in user interfaces & exit'
157
+ },
158
+ 'list-reporters': {
159
+ conflicts: Array.from(ONE_AND_DONE_ARGS),
160
+ description: 'List built-in reporters & exit'
161
+ },
158
162
  'no-colors': {
159
163
  description: 'Force-disable color output',
160
164
  group: GROUPS.OUTPUT,
@@ -162,7 +166,7 @@ exports.builder = yargs =>
162
166
  },
163
167
  opts: {
164
168
  default: defaults.opts,
165
- description: 'Path to `mocha.opts`',
169
+ description: 'Path to `mocha.opts` (DEPRECATED)',
166
170
  group: GROUPS.CONFIG,
167
171
  normalize: true,
168
172
  requiresArg: true
@@ -183,10 +187,6 @@ exports.builder = yargs =>
183
187
  group: GROUPS.OUTPUT,
184
188
  requiresArg: true
185
189
  },
186
- reporters: {
187
- conflicts: Array.from(ONE_AND_DONE_ARGS),
188
- description: 'List built-in reporters & exit'
189
- },
190
190
  'reporter-option': {
191
191
  coerce: opts =>
192
192
  list(opts).reduce((acc, opt) => {
@@ -241,6 +241,19 @@ exports.builder = yargs =>
241
241
  watch: {
242
242
  description: 'Watch files in the current working directory for changes',
243
243
  group: GROUPS.FILES
244
+ },
245
+ 'watch-files': {
246
+ description: 'List of paths or globs to watch',
247
+ group: GROUPS.FILES,
248
+ requiresArg: true,
249
+ coerce: list
250
+ },
251
+ 'watch-ignore': {
252
+ description: 'List of paths or globs to exclude from watching',
253
+ group: GROUPS.FILES,
254
+ requiresArg: true,
255
+ coerce: list,
256
+ default: defaults['watch-ignore']
244
257
  }
245
258
  })
246
259
  .positional('spec', {