mocha 9.1.2
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 +1015 -0
- package/LICENSE +22 -0
- package/README.md +70 -0
- package/assets/growl/error.png +0 -0
- package/assets/growl/ok.png +0 -0
- package/bin/_mocha +10 -0
- package/bin/mocha +142 -0
- package/browser-entry.js +216 -0
- package/index.js +3 -0
- package/lib/browser/growl.js +169 -0
- package/lib/browser/highlight-tags.js +39 -0
- package/lib/browser/parse-query.js +24 -0
- package/lib/browser/progress.js +123 -0
- package/lib/browser/template.html +20 -0
- package/lib/cli/cli.js +89 -0
- package/lib/cli/collect-files.js +92 -0
- package/lib/cli/commands.js +13 -0
- package/lib/cli/config.js +105 -0
- package/lib/cli/index.js +3 -0
- package/lib/cli/init.js +36 -0
- package/lib/cli/lookup-files.js +145 -0
- package/lib/cli/node-flags.js +85 -0
- package/lib/cli/one-and-dones.js +69 -0
- package/lib/cli/options.js +261 -0
- package/lib/cli/run-helpers.js +243 -0
- package/lib/cli/run-option-metadata.js +117 -0
- package/lib/cli/run.js +379 -0
- package/lib/cli/watch-run.js +380 -0
- package/lib/context.js +86 -0
- package/lib/errors.js +563 -0
- package/lib/hook.js +89 -0
- package/lib/interfaces/bdd.js +111 -0
- package/lib/interfaces/common.js +193 -0
- package/lib/interfaces/exports.js +60 -0
- package/lib/interfaces/index.js +6 -0
- package/lib/interfaces/qunit.js +98 -0
- package/lib/interfaces/tdd.js +106 -0
- package/lib/mocha.js +1374 -0
- package/lib/mocharc.json +10 -0
- package/lib/nodejs/buffered-worker-pool.js +172 -0
- package/lib/nodejs/esm-utils.js +109 -0
- package/lib/nodejs/file-unloader.js +15 -0
- package/lib/nodejs/growl.js +137 -0
- package/lib/nodejs/parallel-buffered-runner.js +433 -0
- package/lib/nodejs/reporters/parallel-buffered.js +165 -0
- package/lib/nodejs/serializer.js +412 -0
- package/lib/nodejs/worker.js +151 -0
- package/lib/pending.js +16 -0
- package/lib/plugin-loader.js +286 -0
- package/lib/reporters/base.js +537 -0
- package/lib/reporters/doc.js +95 -0
- package/lib/reporters/dot.js +81 -0
- package/lib/reporters/html.js +390 -0
- package/lib/reporters/index.js +19 -0
- package/lib/reporters/json-stream.js +92 -0
- package/lib/reporters/json.js +162 -0
- package/lib/reporters/landing.js +116 -0
- package/lib/reporters/list.js +78 -0
- package/lib/reporters/markdown.js +112 -0
- package/lib/reporters/min.js +52 -0
- package/lib/reporters/nyan.js +276 -0
- package/lib/reporters/progress.js +104 -0
- package/lib/reporters/spec.js +99 -0
- package/lib/reporters/tap.js +293 -0
- package/lib/reporters/xunit.js +217 -0
- package/lib/runnable.js +476 -0
- package/lib/runner.js +1269 -0
- package/lib/stats-collector.js +83 -0
- package/lib/suite.js +695 -0
- package/lib/test.js +113 -0
- package/lib/utils.js +641 -0
- package/mocha-es2018.js +19816 -0
- package/mocha.css +325 -0
- package/mocha.js +30844 -0
- package/mocha.js.map +1 -0
- package/package.json +200 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Metadata about various options of the `run` command
|
|
5
|
+
* @see module:lib/cli/run
|
|
6
|
+
* @module
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Dictionary of yargs option types to list of options having said type
|
|
12
|
+
* @type {{string:string[]}}
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
const TYPES = (exports.types = {
|
|
16
|
+
array: [
|
|
17
|
+
'extension',
|
|
18
|
+
'file',
|
|
19
|
+
'global',
|
|
20
|
+
'ignore',
|
|
21
|
+
'node-option',
|
|
22
|
+
'reporter-option',
|
|
23
|
+
'require',
|
|
24
|
+
'spec',
|
|
25
|
+
'watch-files',
|
|
26
|
+
'watch-ignore'
|
|
27
|
+
],
|
|
28
|
+
boolean: [
|
|
29
|
+
'allow-uncaught',
|
|
30
|
+
'async-only',
|
|
31
|
+
'bail',
|
|
32
|
+
'check-leaks',
|
|
33
|
+
'color',
|
|
34
|
+
'delay',
|
|
35
|
+
'diff',
|
|
36
|
+
'dry-run',
|
|
37
|
+
'exit',
|
|
38
|
+
'fail-zero',
|
|
39
|
+
'forbid-only',
|
|
40
|
+
'forbid-pending',
|
|
41
|
+
'full-trace',
|
|
42
|
+
'growl',
|
|
43
|
+
'inline-diffs',
|
|
44
|
+
'invert',
|
|
45
|
+
'list-interfaces',
|
|
46
|
+
'list-reporters',
|
|
47
|
+
'no-colors',
|
|
48
|
+
'parallel',
|
|
49
|
+
'recursive',
|
|
50
|
+
'sort',
|
|
51
|
+
'watch'
|
|
52
|
+
],
|
|
53
|
+
number: ['retries', 'jobs'],
|
|
54
|
+
string: [
|
|
55
|
+
'config',
|
|
56
|
+
'fgrep',
|
|
57
|
+
'grep',
|
|
58
|
+
'package',
|
|
59
|
+
'reporter',
|
|
60
|
+
'ui',
|
|
61
|
+
'slow',
|
|
62
|
+
'timeout'
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Option aliases keyed by canonical option name.
|
|
68
|
+
* Arrays used to reduce
|
|
69
|
+
* @type {{string:string[]}}
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
exports.aliases = {
|
|
73
|
+
'async-only': ['A'],
|
|
74
|
+
bail: ['b'],
|
|
75
|
+
color: ['c', 'colors'],
|
|
76
|
+
fgrep: ['f'],
|
|
77
|
+
global: ['globals'],
|
|
78
|
+
grep: ['g'],
|
|
79
|
+
growl: ['G'],
|
|
80
|
+
ignore: ['exclude'],
|
|
81
|
+
invert: ['i'],
|
|
82
|
+
jobs: ['j'],
|
|
83
|
+
'no-colors': ['C'],
|
|
84
|
+
'node-option': ['n'],
|
|
85
|
+
parallel: ['p'],
|
|
86
|
+
reporter: ['R'],
|
|
87
|
+
'reporter-option': ['reporter-options', 'O'],
|
|
88
|
+
require: ['r'],
|
|
89
|
+
slow: ['s'],
|
|
90
|
+
sort: ['S'],
|
|
91
|
+
timeout: ['t', 'timeouts'],
|
|
92
|
+
ui: ['u'],
|
|
93
|
+
watch: ['w']
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const ALL_MOCHA_FLAGS = Object.keys(TYPES).reduce((acc, key) => {
|
|
97
|
+
// gets all flags from each of the fields in `types`, adds those,
|
|
98
|
+
// then adds aliases of each flag (if any)
|
|
99
|
+
TYPES[key].forEach(flag => {
|
|
100
|
+
acc.add(flag);
|
|
101
|
+
const aliases = exports.aliases[flag] || [];
|
|
102
|
+
aliases.forEach(alias => {
|
|
103
|
+
acc.add(alias);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return acc;
|
|
107
|
+
}, new Set());
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns `true` if the provided `flag` is known to Mocha.
|
|
111
|
+
* @param {string} flag - Flag to check
|
|
112
|
+
* @returns {boolean} If `true`, this is a Mocha flag
|
|
113
|
+
* @private
|
|
114
|
+
*/
|
|
115
|
+
exports.isMochaFlag = flag => {
|
|
116
|
+
return ALL_MOCHA_FLAGS.has(flag.replace(/^--?/, ''));
|
|
117
|
+
};
|
package/lib/cli/run.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Definition for Mocha's default ("run tests") command
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const symbols = require('log-symbols');
|
|
11
|
+
const ansi = require('ansi-colors');
|
|
12
|
+
const Mocha = require('../mocha');
|
|
13
|
+
const {
|
|
14
|
+
createUnsupportedError,
|
|
15
|
+
createInvalidArgumentValueError,
|
|
16
|
+
createMissingArgumentError
|
|
17
|
+
} = require('../errors');
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
list,
|
|
21
|
+
handleRequires,
|
|
22
|
+
validateLegacyPlugin,
|
|
23
|
+
runMocha
|
|
24
|
+
} = require('./run-helpers');
|
|
25
|
+
const {ONE_AND_DONES, ONE_AND_DONE_ARGS} = require('./one-and-dones');
|
|
26
|
+
const debug = require('debug')('mocha:cli:run');
|
|
27
|
+
const defaults = require('../mocharc');
|
|
28
|
+
const {types, aliases} = require('./run-option-metadata');
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Logical option groups
|
|
32
|
+
* @constant
|
|
33
|
+
*/
|
|
34
|
+
const GROUPS = {
|
|
35
|
+
FILES: 'File Handling',
|
|
36
|
+
FILTERS: 'Test Filters',
|
|
37
|
+
NODEJS: 'Node.js & V8',
|
|
38
|
+
OUTPUT: 'Reporting & Output',
|
|
39
|
+
RULES: 'Rules & Behavior',
|
|
40
|
+
CONFIG: 'Configuration'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.command = ['$0 [spec..]', 'inspect'];
|
|
44
|
+
|
|
45
|
+
exports.describe = 'Run tests with Mocha';
|
|
46
|
+
|
|
47
|
+
exports.builder = yargs =>
|
|
48
|
+
yargs
|
|
49
|
+
.options({
|
|
50
|
+
'allow-uncaught': {
|
|
51
|
+
description: 'Allow uncaught errors to propagate',
|
|
52
|
+
group: GROUPS.RULES
|
|
53
|
+
},
|
|
54
|
+
'async-only': {
|
|
55
|
+
description:
|
|
56
|
+
'Require all tests to use a callback (async) or return a Promise',
|
|
57
|
+
group: GROUPS.RULES
|
|
58
|
+
},
|
|
59
|
+
bail: {
|
|
60
|
+
description: 'Abort ("bail") after first test failure',
|
|
61
|
+
group: GROUPS.RULES
|
|
62
|
+
},
|
|
63
|
+
'check-leaks': {
|
|
64
|
+
description: 'Check for global variable leaks',
|
|
65
|
+
group: GROUPS.RULES
|
|
66
|
+
},
|
|
67
|
+
color: {
|
|
68
|
+
description: 'Force-enable color output',
|
|
69
|
+
group: GROUPS.OUTPUT
|
|
70
|
+
},
|
|
71
|
+
config: {
|
|
72
|
+
config: true,
|
|
73
|
+
defaultDescription: '(nearest rc file)',
|
|
74
|
+
description: 'Path to config file',
|
|
75
|
+
group: GROUPS.CONFIG
|
|
76
|
+
},
|
|
77
|
+
delay: {
|
|
78
|
+
description: 'Delay initial execution of root suite',
|
|
79
|
+
group: GROUPS.RULES
|
|
80
|
+
},
|
|
81
|
+
diff: {
|
|
82
|
+
default: true,
|
|
83
|
+
description: 'Show diff on failure',
|
|
84
|
+
group: GROUPS.OUTPUT
|
|
85
|
+
},
|
|
86
|
+
'dry-run': {
|
|
87
|
+
description: 'Report tests without executing them',
|
|
88
|
+
group: GROUPS.RULES
|
|
89
|
+
},
|
|
90
|
+
exit: {
|
|
91
|
+
description: 'Force Mocha to quit after tests complete',
|
|
92
|
+
group: GROUPS.RULES
|
|
93
|
+
},
|
|
94
|
+
extension: {
|
|
95
|
+
default: defaults.extension,
|
|
96
|
+
description: 'File extension(s) to load',
|
|
97
|
+
group: GROUPS.FILES,
|
|
98
|
+
requiresArg: true,
|
|
99
|
+
coerce: list
|
|
100
|
+
},
|
|
101
|
+
'fail-zero': {
|
|
102
|
+
description: 'Fail test run if no test(s) encountered',
|
|
103
|
+
group: GROUPS.RULES
|
|
104
|
+
},
|
|
105
|
+
fgrep: {
|
|
106
|
+
conflicts: 'grep',
|
|
107
|
+
description: 'Only run tests containing this string',
|
|
108
|
+
group: GROUPS.FILTERS,
|
|
109
|
+
requiresArg: true
|
|
110
|
+
},
|
|
111
|
+
file: {
|
|
112
|
+
defaultDescription: '(none)',
|
|
113
|
+
description:
|
|
114
|
+
'Specify file(s) to be loaded prior to root suite execution',
|
|
115
|
+
group: GROUPS.FILES,
|
|
116
|
+
normalize: true,
|
|
117
|
+
requiresArg: true
|
|
118
|
+
},
|
|
119
|
+
'forbid-only': {
|
|
120
|
+
description: 'Fail if exclusive test(s) encountered',
|
|
121
|
+
group: GROUPS.RULES
|
|
122
|
+
},
|
|
123
|
+
'forbid-pending': {
|
|
124
|
+
description: 'Fail if pending test(s) encountered',
|
|
125
|
+
group: GROUPS.RULES
|
|
126
|
+
},
|
|
127
|
+
'full-trace': {
|
|
128
|
+
description: 'Display full stack traces',
|
|
129
|
+
group: GROUPS.OUTPUT
|
|
130
|
+
},
|
|
131
|
+
global: {
|
|
132
|
+
coerce: list,
|
|
133
|
+
description: 'List of allowed global variables',
|
|
134
|
+
group: GROUPS.RULES,
|
|
135
|
+
requiresArg: true
|
|
136
|
+
},
|
|
137
|
+
grep: {
|
|
138
|
+
coerce: value => (!value ? null : value),
|
|
139
|
+
conflicts: 'fgrep',
|
|
140
|
+
description: 'Only run tests matching this string or regexp',
|
|
141
|
+
group: GROUPS.FILTERS,
|
|
142
|
+
requiresArg: true
|
|
143
|
+
},
|
|
144
|
+
growl: {
|
|
145
|
+
description: 'Enable Growl notifications',
|
|
146
|
+
group: GROUPS.OUTPUT
|
|
147
|
+
},
|
|
148
|
+
ignore: {
|
|
149
|
+
defaultDescription: '(none)',
|
|
150
|
+
description: 'Ignore file(s) or glob pattern(s)',
|
|
151
|
+
group: GROUPS.FILES,
|
|
152
|
+
requiresArg: true
|
|
153
|
+
},
|
|
154
|
+
'inline-diffs': {
|
|
155
|
+
description:
|
|
156
|
+
'Display actual/expected differences inline within each string',
|
|
157
|
+
group: GROUPS.OUTPUT
|
|
158
|
+
},
|
|
159
|
+
invert: {
|
|
160
|
+
description: 'Inverts --grep and --fgrep matches',
|
|
161
|
+
group: GROUPS.FILTERS
|
|
162
|
+
},
|
|
163
|
+
jobs: {
|
|
164
|
+
description:
|
|
165
|
+
'Number of concurrent jobs for --parallel; use 1 to run in serial',
|
|
166
|
+
defaultDescription: '(number of CPU cores - 1)',
|
|
167
|
+
requiresArg: true,
|
|
168
|
+
group: GROUPS.RULES
|
|
169
|
+
},
|
|
170
|
+
'list-interfaces': {
|
|
171
|
+
conflicts: Array.from(ONE_AND_DONE_ARGS),
|
|
172
|
+
description: 'List built-in user interfaces & exit'
|
|
173
|
+
},
|
|
174
|
+
'list-reporters': {
|
|
175
|
+
conflicts: Array.from(ONE_AND_DONE_ARGS),
|
|
176
|
+
description: 'List built-in reporters & exit'
|
|
177
|
+
},
|
|
178
|
+
'no-colors': {
|
|
179
|
+
description: 'Force-disable color output',
|
|
180
|
+
group: GROUPS.OUTPUT,
|
|
181
|
+
hidden: true
|
|
182
|
+
},
|
|
183
|
+
'node-option': {
|
|
184
|
+
description: 'Node or V8 option (no leading "--")',
|
|
185
|
+
group: GROUPS.CONFIG
|
|
186
|
+
},
|
|
187
|
+
package: {
|
|
188
|
+
description: 'Path to package.json for config',
|
|
189
|
+
group: GROUPS.CONFIG,
|
|
190
|
+
normalize: true,
|
|
191
|
+
requiresArg: true
|
|
192
|
+
},
|
|
193
|
+
parallel: {
|
|
194
|
+
description: 'Run tests in parallel',
|
|
195
|
+
group: GROUPS.RULES
|
|
196
|
+
},
|
|
197
|
+
recursive: {
|
|
198
|
+
description: 'Look for tests in subdirectories',
|
|
199
|
+
group: GROUPS.FILES
|
|
200
|
+
},
|
|
201
|
+
reporter: {
|
|
202
|
+
default: defaults.reporter,
|
|
203
|
+
description: 'Specify reporter to use',
|
|
204
|
+
group: GROUPS.OUTPUT,
|
|
205
|
+
requiresArg: true
|
|
206
|
+
},
|
|
207
|
+
'reporter-option': {
|
|
208
|
+
coerce: opts =>
|
|
209
|
+
list(opts).reduce((acc, opt) => {
|
|
210
|
+
const pair = opt.split('=');
|
|
211
|
+
|
|
212
|
+
if (pair.length > 2 || !pair.length) {
|
|
213
|
+
throw createInvalidArgumentValueError(
|
|
214
|
+
`invalid reporter option '${opt}'`,
|
|
215
|
+
'--reporter-option',
|
|
216
|
+
opt,
|
|
217
|
+
'expected "key=value" format'
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
acc[pair[0]] = pair.length === 2 ? pair[1] : true;
|
|
222
|
+
return acc;
|
|
223
|
+
}, {}),
|
|
224
|
+
description: 'Reporter-specific options (<k=v,[k1=v1,..]>)',
|
|
225
|
+
group: GROUPS.OUTPUT,
|
|
226
|
+
requiresArg: true
|
|
227
|
+
},
|
|
228
|
+
require: {
|
|
229
|
+
defaultDescription: '(none)',
|
|
230
|
+
description: 'Require module',
|
|
231
|
+
group: GROUPS.FILES,
|
|
232
|
+
requiresArg: true
|
|
233
|
+
},
|
|
234
|
+
retries: {
|
|
235
|
+
description: 'Retry failed tests this many times',
|
|
236
|
+
group: GROUPS.RULES
|
|
237
|
+
},
|
|
238
|
+
slow: {
|
|
239
|
+
default: defaults.slow,
|
|
240
|
+
description: 'Specify "slow" test threshold (in milliseconds)',
|
|
241
|
+
group: GROUPS.RULES
|
|
242
|
+
},
|
|
243
|
+
sort: {
|
|
244
|
+
description: 'Sort test files',
|
|
245
|
+
group: GROUPS.FILES
|
|
246
|
+
},
|
|
247
|
+
timeout: {
|
|
248
|
+
default: defaults.timeout,
|
|
249
|
+
description: 'Specify test timeout threshold (in milliseconds)',
|
|
250
|
+
group: GROUPS.RULES
|
|
251
|
+
},
|
|
252
|
+
ui: {
|
|
253
|
+
default: defaults.ui,
|
|
254
|
+
description: 'Specify user interface',
|
|
255
|
+
group: GROUPS.RULES,
|
|
256
|
+
requiresArg: true
|
|
257
|
+
},
|
|
258
|
+
watch: {
|
|
259
|
+
description: 'Watch files in the current working directory for changes',
|
|
260
|
+
group: GROUPS.FILES
|
|
261
|
+
},
|
|
262
|
+
'watch-files': {
|
|
263
|
+
description: 'List of paths or globs to watch',
|
|
264
|
+
group: GROUPS.FILES,
|
|
265
|
+
requiresArg: true,
|
|
266
|
+
coerce: list
|
|
267
|
+
},
|
|
268
|
+
'watch-ignore': {
|
|
269
|
+
description: 'List of paths or globs to exclude from watching',
|
|
270
|
+
group: GROUPS.FILES,
|
|
271
|
+
requiresArg: true,
|
|
272
|
+
coerce: list,
|
|
273
|
+
default: defaults['watch-ignore']
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
.positional('spec', {
|
|
277
|
+
default: ['test'],
|
|
278
|
+
description: 'One or more files, directories, or globs to test',
|
|
279
|
+
type: 'array'
|
|
280
|
+
})
|
|
281
|
+
.check(argv => {
|
|
282
|
+
// "one-and-dones"; let yargs handle help and version
|
|
283
|
+
Object.keys(ONE_AND_DONES).forEach(opt => {
|
|
284
|
+
if (argv[opt]) {
|
|
285
|
+
ONE_AND_DONES[opt].call(null, yargs);
|
|
286
|
+
process.exit();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// yargs.implies() isn't flexible enough to handle this
|
|
291
|
+
if (argv.invert && !('fgrep' in argv || 'grep' in argv)) {
|
|
292
|
+
throw createMissingArgumentError(
|
|
293
|
+
'"--invert" requires one of "--fgrep <str>" or "--grep <regexp>"',
|
|
294
|
+
'--fgrep|--grep',
|
|
295
|
+
'string|regexp'
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (argv.parallel) {
|
|
300
|
+
// yargs.conflicts() can't deal with `--file foo.js --no-parallel`, either
|
|
301
|
+
if (argv.file) {
|
|
302
|
+
throw createUnsupportedError(
|
|
303
|
+
'--parallel runs test files in a non-deterministic order, and is mutually exclusive with --file'
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// or this
|
|
308
|
+
if (argv.sort) {
|
|
309
|
+
throw createUnsupportedError(
|
|
310
|
+
'--parallel runs test files in a non-deterministic order, and is mutually exclusive with --sort'
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (argv.reporter === 'progress') {
|
|
315
|
+
throw createUnsupportedError(
|
|
316
|
+
'--reporter=progress is mutually exclusive with --parallel'
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (argv.reporter === 'markdown') {
|
|
321
|
+
throw createUnsupportedError(
|
|
322
|
+
'--reporter=markdown is mutually exclusive with --parallel'
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (argv.reporter === 'json-stream') {
|
|
327
|
+
throw createUnsupportedError(
|
|
328
|
+
'--reporter=json-stream is mutually exclusive with --parallel'
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if (argv.compilers) {
|
|
334
|
+
throw createUnsupportedError(
|
|
335
|
+
`--compilers is DEPRECATED and no longer supported.
|
|
336
|
+
See https://git.io/vdcSr for migration information.`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (argv.opts) {
|
|
341
|
+
throw createUnsupportedError(
|
|
342
|
+
`--opts: configuring Mocha via 'mocha.opts' is DEPRECATED and no longer supported.
|
|
343
|
+
Please use a configuration file instead.`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return true;
|
|
348
|
+
})
|
|
349
|
+
.middleware(async (argv, yargs) => {
|
|
350
|
+
// currently a failing middleware does not work nicely with yargs' `fail()`.
|
|
351
|
+
try {
|
|
352
|
+
// load requires first, because it can impact "plugin" validation
|
|
353
|
+
const plugins = await handleRequires(argv.require);
|
|
354
|
+
validateLegacyPlugin(argv, 'reporter', Mocha.reporters);
|
|
355
|
+
validateLegacyPlugin(argv, 'ui', Mocha.interfaces);
|
|
356
|
+
Object.assign(argv, plugins);
|
|
357
|
+
} catch (err) {
|
|
358
|
+
// this could be a bad --require, bad reporter, ui, etc.
|
|
359
|
+
console.error(`\n${symbols.error} ${ansi.red('ERROR:')}`, err);
|
|
360
|
+
yargs.exit(1);
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
.array(types.array)
|
|
364
|
+
.boolean(types.boolean)
|
|
365
|
+
.string(types.string)
|
|
366
|
+
.number(types.number)
|
|
367
|
+
.alias(aliases);
|
|
368
|
+
|
|
369
|
+
exports.handler = async function(argv) {
|
|
370
|
+
debug('post-yargs config', argv);
|
|
371
|
+
const mocha = new Mocha(argv);
|
|
372
|
+
|
|
373
|
+
try {
|
|
374
|
+
await runMocha(mocha, argv);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
console.error('\n' + (err.stack || `Error: ${err.message || err}`));
|
|
377
|
+
process.exit(1);
|
|
378
|
+
}
|
|
379
|
+
};
|