Update Mocha to 8.0.1
Breaking changes here https://github.com/mochajs/mocha/releases/tag/v8.0.0
seem fine.
DISABLE_THIRD_PARTY_CHECK=Update Mocha
Bug: chromium:1101784
Change-Id: Idc75c94f9a923e2b0ca13d1d1331540cb1c5d3a3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2279830
Reviewed-by: Tim van der Lippe <[email protected]>
Commit-Queue: Peter Marshall <[email protected]>
diff --git a/node_modules/mocha/lib/cli/run.js b/node_modules/mocha/lib/cli/run.js
index 014227d..6582a4e 100644
--- a/node_modules/mocha/lib/cli/run.js
+++ b/node_modules/mocha/lib/cli/run.js
@@ -7,6 +7,8 @@
* @private
*/
+const symbols = require('log-symbols');
+const ansi = require('ansi-colors');
const Mocha = require('../mocha');
const {
createUnsupportedError,
@@ -18,6 +20,7 @@
list,
handleRequires,
validatePlugin,
+ loadRootHooks,
runMocha
} = require('./run-helpers');
const {ONE_AND_DONES, ONE_AND_DONE_ARGS} = require('./one-and-dones');
@@ -150,6 +153,13 @@
description: 'Inverts --grep and --fgrep matches',
group: GROUPS.FILTERS
},
+ jobs: {
+ description:
+ 'Number of concurrent jobs for --parallel; use 1 to run in serial',
+ defaultDescription: '(number of CPU cores - 1)',
+ requiresArg: true,
+ group: GROUPS.RULES
+ },
'list-interfaces': {
conflicts: Array.from(ONE_AND_DONE_ARGS),
description: 'List built-in user interfaces & exit'
@@ -163,19 +173,16 @@
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,
normalize: true,
requiresArg: true
},
+ parallel: {
+ description: 'Run tests in parallel',
+ group: GROUPS.RULES
+ },
recursive: {
description: 'Look for tests in subdirectories',
group: GROUPS.FILES
@@ -278,6 +285,40 @@
);
}
+ if (argv.parallel) {
+ // yargs.conflicts() can't deal with `--file foo.js --no-parallel`, either
+ if (argv.file) {
+ throw createUnsupportedError(
+ '--parallel runs test files in a non-deterministic order, and is mutually exclusive with --file'
+ );
+ }
+
+ // or this
+ if (argv.sort) {
+ throw createUnsupportedError(
+ '--parallel runs test files in a non-deterministic order, and is mutually exclusive with --sort'
+ );
+ }
+
+ if (argv.reporter === 'progress') {
+ throw createUnsupportedError(
+ '--reporter=progress is mutually exclusive with --parallel'
+ );
+ }
+
+ if (argv.reporter === 'markdown') {
+ throw createUnsupportedError(
+ '--reporter=markdown is mutually exclusive with --parallel'
+ );
+ }
+
+ if (argv.reporter === 'json-stream') {
+ throw createUnsupportedError(
+ '--reporter=json-stream is mutually exclusive with --parallel'
+ );
+ }
+ }
+
if (argv.compilers) {
throw createUnsupportedError(
`--compilers is DEPRECATED and no longer supported.
@@ -285,13 +326,32 @@
);
}
- // load requires first, because it can impact "plugin" validation
- handleRequires(argv.require);
- validatePlugin(argv, 'reporter', Mocha.reporters);
- validatePlugin(argv, 'ui', Mocha.interfaces);
+ if (argv.opts) {
+ throw createUnsupportedError(
+ `--opts: configuring Mocha via 'mocha.opts' is DEPRECATED and no longer supported.
+ Please use a configuration file instead.`
+ );
+ }
return true;
})
+ .middleware(async (argv, yargs) => {
+ // currently a failing middleware does not work nicely with yargs' `fail()`.
+ try {
+ // load requires first, because it can impact "plugin" validation
+ const rawRootHooks = await handleRequires(argv.require);
+ validatePlugin(argv, 'reporter', Mocha.reporters);
+ validatePlugin(argv, 'ui', Mocha.interfaces);
+
+ if (rawRootHooks && rawRootHooks.length) {
+ argv.rootHooks = await loadRootHooks(rawRootHooks);
+ }
+ } catch (err) {
+ // this could be a bad --require, bad reporter, ui, etc.
+ console.error(`\n${symbols.error} ${ansi.red('ERROR:')}`, err);
+ yargs.exit(1);
+ }
+ })
.array(types.array)
.boolean(types.boolean)
.string(types.string)