mocha 11.7.4 → 11.7.6
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/bin/_mocha +2 -2
- package/bin/mocha.js +46 -44
- package/browser-entry.js +20 -20
- package/index.js +2 -2
- package/lib/browser/highlight-tags.js +6 -6
- package/lib/browser/parse-query.js +5 -5
- package/lib/browser/template.html +2 -2
- package/lib/cli/cli.js +32 -27
- package/lib/cli/collect-files.js +25 -25
- package/lib/cli/commands.js +4 -4
- package/lib/cli/config.js +26 -25
- package/lib/cli/index.js +2 -2
- package/lib/cli/init.js +19 -19
- package/lib/cli/lookup-files.js +20 -20
- package/lib/cli/node-flags.js +12 -12
- package/lib/cli/one-and-dones.js +12 -11
- package/lib/cli/options.js +49 -49
- package/lib/cli/run-helpers.js +52 -54
- package/lib/cli/run-option-metadata.js +75 -75
- package/lib/cli/run.js +164 -159
- package/lib/cli/watch-run.js +75 -75
- package/lib/context.js +1 -1
- package/lib/error-constants.js +17 -17
- package/lib/errors.js +26 -26
- package/lib/hook.js +9 -9
- package/lib/interfaces/bdd.js +8 -8
- package/lib/interfaces/common.js +12 -12
- package/lib/interfaces/exports.js +8 -8
- package/lib/interfaces/index.js +5 -5
- package/lib/interfaces/qunit.js +7 -7
- package/lib/interfaces/tdd.js +7 -7
- package/lib/mocha.js +97 -97
- package/lib/nodejs/buffered-worker-pool.js +30 -30
- package/lib/nodejs/esm-utils.js +24 -21
- package/lib/nodejs/file-unloader.js +2 -2
- package/lib/nodejs/parallel-buffered-runner.js +67 -67
- package/lib/nodejs/reporters/parallel-buffered.js +13 -10
- package/lib/nodejs/serializer.js +47 -47
- package/lib/nodejs/worker.js +38 -38
- package/lib/pending.js +1 -1
- package/lib/plugin-loader.js +48 -48
- package/lib/reporters/base.js +97 -94
- package/lib/reporters/doc.js +17 -17
- package/lib/reporters/dot.js +14 -14
- package/lib/reporters/html.js +73 -67
- package/lib/reporters/index.js +16 -16
- package/lib/reporters/json-stream.js +10 -10
- package/lib/reporters/json.js +16 -16
- package/lib/reporters/landing.js +20 -20
- package/lib/reporters/list.js +10 -10
- package/lib/reporters/markdown.js +21 -21
- package/lib/reporters/min.js +7 -7
- package/lib/reporters/nyan.js +35 -35
- package/lib/reporters/progress.js +14 -14
- package/lib/reporters/spec.js +15 -15
- package/lib/reporters/tap.js +26 -26
- package/lib/reporters/xunit.js +38 -34
- package/lib/runnable.js +41 -41
- package/lib/runner.js +105 -105
- package/lib/stats-collector.js +4 -4
- package/lib/suite.js +56 -46
- package/lib/test.js +10 -10
- package/lib/utils.js +122 -122
- package/mocha.css +68 -50
- package/mocha.js +826 -803
- package/mocha.js.map +1 -1
- package/package.json +8 -13
package/lib/cli/watch-run.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const logSymbols = require(
|
|
4
|
-
const debug = require(
|
|
5
|
-
const path = require(
|
|
6
|
-
const chokidar = require(
|
|
7
|
-
const glob = require(
|
|
8
|
-
const isPathInside = require(
|
|
9
|
-
const {minimatch} = require(
|
|
10
|
-
const Context = require(
|
|
11
|
-
const collectFiles = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const logSymbols = require("log-symbols");
|
|
4
|
+
const debug = require("debug")("mocha:cli:watch");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const chokidar = require("chokidar");
|
|
7
|
+
const glob = require("glob");
|
|
8
|
+
const isPathInside = require("is-path-inside");
|
|
9
|
+
const { minimatch } = require("minimatch");
|
|
10
|
+
const Context = require("../context");
|
|
11
|
+
const collectFiles = require("./collect-files");
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import('chokidar').FSWatcher} FSWatcher
|
|
@@ -46,15 +46,15 @@ const collectFiles = require('./collect-files');
|
|
|
46
46
|
*/
|
|
47
47
|
exports.watchParallelRun = (
|
|
48
48
|
mocha,
|
|
49
|
-
{watchFiles, watchIgnore},
|
|
50
|
-
fileCollectParams
|
|
49
|
+
{ watchFiles, watchIgnore },
|
|
50
|
+
fileCollectParams,
|
|
51
51
|
) => {
|
|
52
|
-
debug(
|
|
52
|
+
debug("creating parallel watcher");
|
|
53
53
|
|
|
54
54
|
return createWatcher(mocha, {
|
|
55
55
|
watchFiles,
|
|
56
56
|
watchIgnore,
|
|
57
|
-
beforeRun({mocha}) {
|
|
57
|
+
beforeRun({ mocha }) {
|
|
58
58
|
// I don't know why we're cloning the root suite.
|
|
59
59
|
const rootSuite = mocha.suite.clone();
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ exports.watchParallelRun = (
|
|
|
64
64
|
// this `require` is needed because the require cache has been cleared. the dynamic
|
|
65
65
|
// exports set via the below call to `mocha.ui()` won't work properly if a
|
|
66
66
|
// test depends on this module.
|
|
67
|
-
const Mocha = require(
|
|
67
|
+
const Mocha = require("../mocha");
|
|
68
68
|
|
|
69
69
|
// ... and now that we've gotten a new module, we need to use it again due
|
|
70
70
|
// to `mocha.ui()` call
|
|
@@ -90,7 +90,7 @@ exports.watchParallelRun = (
|
|
|
90
90
|
newMocha.lazyLoadFiles(true);
|
|
91
91
|
return newMocha;
|
|
92
92
|
},
|
|
93
|
-
fileCollectParams
|
|
93
|
+
fileCollectParams,
|
|
94
94
|
});
|
|
95
95
|
};
|
|
96
96
|
|
|
@@ -108,13 +108,13 @@ exports.watchParallelRun = (
|
|
|
108
108
|
* file collection. See `lib/cli/collect-files.js`.
|
|
109
109
|
* @private
|
|
110
110
|
*/
|
|
111
|
-
exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
|
|
112
|
-
debug(
|
|
111
|
+
exports.watchRun = (mocha, { watchFiles, watchIgnore }, fileCollectParams) => {
|
|
112
|
+
debug("creating serial watcher");
|
|
113
113
|
|
|
114
114
|
return createWatcher(mocha, {
|
|
115
115
|
watchFiles,
|
|
116
116
|
watchIgnore,
|
|
117
|
-
beforeRun({mocha}) {
|
|
117
|
+
beforeRun({ mocha }) {
|
|
118
118
|
mocha.unloadFiles();
|
|
119
119
|
|
|
120
120
|
// I don't know why we're cloning the root suite.
|
|
@@ -126,7 +126,7 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
|
|
|
126
126
|
// this `require` is needed because the require cache has been cleared. the dynamic
|
|
127
127
|
// exports set via the below call to `mocha.ui()` won't work properly if a
|
|
128
128
|
// test depends on this module.
|
|
129
|
-
const Mocha = require(
|
|
129
|
+
const Mocha = require("../mocha");
|
|
130
130
|
|
|
131
131
|
// ... and now that we've gotten a new module, we need to use it again due
|
|
132
132
|
// to `mocha.ui()` call
|
|
@@ -149,7 +149,7 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
|
|
|
149
149
|
|
|
150
150
|
return newMocha;
|
|
151
151
|
},
|
|
152
|
-
fileCollectParams
|
|
152
|
+
fileCollectParams,
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
155
|
|
|
@@ -163,35 +163,35 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
|
|
|
163
163
|
* @private
|
|
164
164
|
*/
|
|
165
165
|
function createPathFilter(globPaths, basePath) {
|
|
166
|
-
debug(
|
|
166
|
+
debug("creating path filter from glob paths: %s", globPaths);
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* The resulting object to filter paths.
|
|
170
170
|
* @type {PathFilter}
|
|
171
171
|
*/
|
|
172
172
|
const res = {
|
|
173
|
-
dir: {paths: new Set(), globs: new Set()},
|
|
174
|
-
match: {paths: new Set(), globs: new Set()}
|
|
173
|
+
dir: { paths: new Set(), globs: new Set() },
|
|
174
|
+
match: { paths: new Set(), globs: new Set() },
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
// for checking if a path ends with `/**/*`
|
|
178
|
-
const globEnd = path.join(path.sep,
|
|
178
|
+
const globEnd = path.join(path.sep, "**", "*");
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* The current glob pattern to check.
|
|
182
182
|
* @type {Pattern[]}
|
|
183
183
|
*/
|
|
184
|
-
const patterns = globPaths.flatMap(globPath => {
|
|
184
|
+
const patterns = globPaths.flatMap((globPath) => {
|
|
185
185
|
return new glob.Glob(globPath, {
|
|
186
186
|
dot: true,
|
|
187
187
|
magicalBraces: true,
|
|
188
|
-
windowsPathsNoEscape: true
|
|
188
|
+
windowsPathsNoEscape: true,
|
|
189
189
|
}).patterns;
|
|
190
190
|
}, []);
|
|
191
191
|
|
|
192
192
|
// each pattern will have its own path because of the `magicalBraces` option
|
|
193
193
|
for (const pattern of patterns) {
|
|
194
|
-
debug(
|
|
194
|
+
debug("processing glob pattern: %s", pattern.globString());
|
|
195
195
|
|
|
196
196
|
/**
|
|
197
197
|
* Path segments before the glob pattern.
|
|
@@ -209,11 +209,11 @@ function createPathFilter(globPaths, basePath) {
|
|
|
209
209
|
do {
|
|
210
210
|
// save string patterns until a non-string (glob or regexp) is matched
|
|
211
211
|
const entry = currentPattern.pattern();
|
|
212
|
-
const isString = typeof entry ===
|
|
212
|
+
const isString = typeof entry === "string";
|
|
213
213
|
debug(
|
|
214
|
-
|
|
215
|
-
isString ?
|
|
216
|
-
entry
|
|
214
|
+
"found %s pattern: %s",
|
|
215
|
+
isString ? "string" : "glob or regexp",
|
|
216
|
+
entry,
|
|
217
217
|
);
|
|
218
218
|
if (!isString) {
|
|
219
219
|
// if the entry is a glob
|
|
@@ -226,28 +226,28 @@ function createPathFilter(globPaths, basePath) {
|
|
|
226
226
|
// go to next pattern
|
|
227
227
|
} while ((currentPattern = currentPattern.rest()));
|
|
228
228
|
if (!isGlob) {
|
|
229
|
-
debug(
|
|
229
|
+
debug("all subpatterns of %j processed", pattern.globString());
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
// match `cleanPath` (path without the glob part) and its subdirectories
|
|
233
233
|
const cleanPath = path.resolve(basePath, ...segments);
|
|
234
|
-
debug(
|
|
234
|
+
debug("clean path: %s", cleanPath);
|
|
235
235
|
res.dir.paths.add(cleanPath);
|
|
236
|
-
res.dir.globs.add(path.resolve(cleanPath,
|
|
236
|
+
res.dir.globs.add(path.resolve(cleanPath, "**", "*"));
|
|
237
237
|
|
|
238
238
|
// match `absPath` and all of its contents
|
|
239
239
|
const absPath = path.resolve(basePath, pattern.globString());
|
|
240
|
-
debug(
|
|
240
|
+
debug("absolute path: %s", absPath);
|
|
241
241
|
(isGlob ? res.match.globs : res.match.paths).add(absPath);
|
|
242
242
|
|
|
243
243
|
// always include `/**/*` to the full pattern for matching
|
|
244
244
|
// since it's possible for the last path segment to be a directory
|
|
245
245
|
if (!absPath.endsWith(globEnd)) {
|
|
246
|
-
res.match.globs.add(path.resolve(absPath,
|
|
246
|
+
res.match.globs.add(path.resolve(absPath, "**", "*"));
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
debug(
|
|
250
|
+
debug("returning path filter: %o", res);
|
|
251
251
|
return res;
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -276,7 +276,7 @@ function matchPattern(filePath, pattern, matchParent) {
|
|
|
276
276
|
// loop through the set of glob paths instead of converting it into an array
|
|
277
277
|
for (const globPath of pattern.globs) {
|
|
278
278
|
if (
|
|
279
|
-
minimatch(filePath, globPath, {dot: true, windowsPathsNoEscape: true})
|
|
279
|
+
minimatch(filePath, globPath, { dot: true, windowsPathsNoEscape: true })
|
|
280
280
|
) {
|
|
281
281
|
return true;
|
|
282
282
|
}
|
|
@@ -296,9 +296,9 @@ function matchPattern(filePath, pattern, matchParent) {
|
|
|
296
296
|
*/
|
|
297
297
|
function createPathMatcher(allowed, ignored, basePath) {
|
|
298
298
|
debug(
|
|
299
|
-
|
|
299
|
+
"creating path matcher from allowed: %o, ignored: %o",
|
|
300
300
|
allowed,
|
|
301
|
-
ignored
|
|
301
|
+
ignored,
|
|
302
302
|
);
|
|
303
303
|
|
|
304
304
|
/**
|
|
@@ -379,7 +379,7 @@ function createPathMatcher(allowed, ignored, basePath) {
|
|
|
379
379
|
|
|
380
380
|
cache(ignoreCache, filePath, ignore);
|
|
381
381
|
return ignore;
|
|
382
|
-
}
|
|
382
|
+
},
|
|
383
383
|
};
|
|
384
384
|
|
|
385
385
|
return matcher;
|
|
@@ -404,14 +404,14 @@ function createPathMatcher(allowed, ignored, basePath) {
|
|
|
404
404
|
*/
|
|
405
405
|
const createWatcher = (
|
|
406
406
|
mocha,
|
|
407
|
-
{watchFiles, watchIgnore, beforeRun, fileCollectParams}
|
|
407
|
+
{ watchFiles, watchIgnore, beforeRun, fileCollectParams },
|
|
408
408
|
) => {
|
|
409
409
|
if (!watchFiles) {
|
|
410
|
-
watchFiles = fileCollectParams.extension.map(ext => `**/*.${ext}`);
|
|
410
|
+
watchFiles = fileCollectParams.extension.map((ext) => `**/*.${ext}`);
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
debug(
|
|
414
|
-
debug(
|
|
413
|
+
debug("watching files: %s", watchFiles);
|
|
414
|
+
debug("ignoring files matching: %s", watchIgnore);
|
|
415
415
|
let globalFixtureContext;
|
|
416
416
|
|
|
417
417
|
// we handle global fixtures manually
|
|
@@ -431,23 +431,23 @@ const createWatcher = (
|
|
|
431
431
|
// Chokidar has to watch the directory paths in case new files are created
|
|
432
432
|
const watcher = chokidar.watch(Array.from(allowed.dir.paths), {
|
|
433
433
|
ignoreInitial: true,
|
|
434
|
-
ignored: matcher.ignore
|
|
434
|
+
ignored: matcher.ignore,
|
|
435
435
|
});
|
|
436
436
|
|
|
437
437
|
const rerunner = createRerunner(mocha, watcher, {
|
|
438
|
-
beforeRun
|
|
438
|
+
beforeRun,
|
|
439
439
|
});
|
|
440
440
|
|
|
441
|
-
watcher.on(
|
|
442
|
-
debug(
|
|
441
|
+
watcher.on("ready", async () => {
|
|
442
|
+
debug("watcher ready");
|
|
443
443
|
if (!globalFixtureContext) {
|
|
444
|
-
debug(
|
|
444
|
+
debug("triggering global setup");
|
|
445
445
|
globalFixtureContext = await mocha.runGlobalSetup();
|
|
446
446
|
}
|
|
447
447
|
rerunner.run();
|
|
448
448
|
});
|
|
449
449
|
|
|
450
|
-
watcher.on(
|
|
450
|
+
watcher.on("all", (_event, filePath) => {
|
|
451
451
|
// only allow file paths that match the allowed patterns
|
|
452
452
|
if (matcher.allow(filePath)) {
|
|
453
453
|
rerunner.scheduleRun();
|
|
@@ -455,7 +455,7 @@ const createWatcher = (
|
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
hideCursor();
|
|
458
|
-
process.on(
|
|
458
|
+
process.on("exit", () => {
|
|
459
459
|
showCursor();
|
|
460
460
|
});
|
|
461
461
|
|
|
@@ -468,21 +468,21 @@ const createWatcher = (
|
|
|
468
468
|
// there may be another way to solve this, but it too will be a hack.
|
|
469
469
|
// for our watch tests on win32 we must _fork_ mocha with an IPC channel
|
|
470
470
|
if (process.connected) {
|
|
471
|
-
process.on(
|
|
472
|
-
if (msg ===
|
|
473
|
-
process.emit(
|
|
471
|
+
process.on("message", (msg) => {
|
|
472
|
+
if (msg === "SIGINT") {
|
|
473
|
+
process.emit("SIGINT");
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
let exiting = false;
|
|
479
|
-
process.on(
|
|
479
|
+
process.on("SIGINT", async () => {
|
|
480
480
|
showCursor();
|
|
481
481
|
console.error(`${logSymbols.warning} [mocha] cleaning up, please wait...`);
|
|
482
482
|
if (!exiting) {
|
|
483
483
|
exiting = true;
|
|
484
484
|
if (mocha.hasGlobalTeardownFixtures()) {
|
|
485
|
-
debug(
|
|
485
|
+
debug("running global teardown");
|
|
486
486
|
try {
|
|
487
487
|
await mocha.runGlobalTeardown(globalFixtureContext);
|
|
488
488
|
} catch (err) {
|
|
@@ -495,10 +495,10 @@ const createWatcher = (
|
|
|
495
495
|
|
|
496
496
|
// Keyboard shortcut for restarting when "rs\n" is typed (ala Nodemon)
|
|
497
497
|
process.stdin.resume();
|
|
498
|
-
process.stdin.setEncoding(
|
|
499
|
-
process.stdin.on(
|
|
498
|
+
process.stdin.setEncoding("utf8");
|
|
499
|
+
process.stdin.on("data", (data) => {
|
|
500
500
|
const str = data.toString().trim().toLowerCase();
|
|
501
|
-
if (str ===
|
|
501
|
+
if (str === "rs") rerunner.scheduleRun();
|
|
502
502
|
});
|
|
503
503
|
|
|
504
504
|
return watcher;
|
|
@@ -515,7 +515,7 @@ const createWatcher = (
|
|
|
515
515
|
* @ignore
|
|
516
516
|
* @private
|
|
517
517
|
*/
|
|
518
|
-
const createRerunner = (mocha, watcher, {beforeRun} = {}) => {
|
|
518
|
+
const createRerunner = (mocha, watcher, { beforeRun } = {}) => {
|
|
519
519
|
// Set to a `Runner` when mocha is running. Set to `null` when mocha is not
|
|
520
520
|
// running.
|
|
521
521
|
let runner = null;
|
|
@@ -525,9 +525,9 @@ const createRerunner = (mocha, watcher, {beforeRun} = {}) => {
|
|
|
525
525
|
|
|
526
526
|
const run = () => {
|
|
527
527
|
try {
|
|
528
|
-
mocha = beforeRun ? beforeRun({mocha, watcher}) || mocha : mocha;
|
|
528
|
+
mocha = beforeRun ? beforeRun({ mocha, watcher }) || mocha : mocha;
|
|
529
529
|
runner = mocha.run(() => {
|
|
530
|
-
debug(
|
|
530
|
+
debug("finished watch run");
|
|
531
531
|
runner = null;
|
|
532
532
|
blastCache(watcher);
|
|
533
533
|
if (rerunScheduled) {
|
|
@@ -562,7 +562,7 @@ const createRerunner = (mocha, watcher, {beforeRun} = {}) => {
|
|
|
562
562
|
|
|
563
563
|
return {
|
|
564
564
|
scheduleRun,
|
|
565
|
-
run
|
|
565
|
+
run,
|
|
566
566
|
};
|
|
567
567
|
};
|
|
568
568
|
|
|
@@ -574,14 +574,14 @@ const createRerunner = (mocha, watcher, {beforeRun} = {}) => {
|
|
|
574
574
|
* @ignore
|
|
575
575
|
* @private
|
|
576
576
|
*/
|
|
577
|
-
const getWatchedFiles = watcher => {
|
|
577
|
+
const getWatchedFiles = (watcher) => {
|
|
578
578
|
const watchedDirs = watcher.getWatched();
|
|
579
579
|
return Object.keys(watchedDirs).reduce(
|
|
580
580
|
(acc, dir) => [
|
|
581
581
|
...acc,
|
|
582
|
-
...watchedDirs[dir].map(file => path.join(dir, file))
|
|
582
|
+
...watchedDirs[dir].map((file) => path.join(dir, file)),
|
|
583
583
|
],
|
|
584
|
-
[]
|
|
584
|
+
[],
|
|
585
585
|
);
|
|
586
586
|
};
|
|
587
587
|
|
|
@@ -591,7 +591,7 @@ const getWatchedFiles = watcher => {
|
|
|
591
591
|
* @private
|
|
592
592
|
*/
|
|
593
593
|
const hideCursor = () => {
|
|
594
|
-
process.stdout.write(
|
|
594
|
+
process.stdout.write("\u001b[?25l");
|
|
595
595
|
};
|
|
596
596
|
|
|
597
597
|
/**
|
|
@@ -600,7 +600,7 @@ const hideCursor = () => {
|
|
|
600
600
|
* @private
|
|
601
601
|
*/
|
|
602
602
|
const showCursor = () => {
|
|
603
|
-
process.stdout.write(
|
|
603
|
+
process.stdout.write("\u001b[?25h");
|
|
604
604
|
};
|
|
605
605
|
|
|
606
606
|
/**
|
|
@@ -608,7 +608,7 @@ const showCursor = () => {
|
|
|
608
608
|
* @private
|
|
609
609
|
*/
|
|
610
610
|
const eraseLine = () => {
|
|
611
|
-
process.stdout.write(
|
|
611
|
+
process.stdout.write("\u001b[2K");
|
|
612
612
|
};
|
|
613
613
|
|
|
614
614
|
/**
|
|
@@ -617,10 +617,10 @@ const eraseLine = () => {
|
|
|
617
617
|
* @ignore
|
|
618
618
|
* @private
|
|
619
619
|
*/
|
|
620
|
-
const blastCache = watcher => {
|
|
620
|
+
const blastCache = (watcher) => {
|
|
621
621
|
const files = getWatchedFiles(watcher);
|
|
622
|
-
files.forEach(file => {
|
|
622
|
+
files.forEach((file) => {
|
|
623
623
|
delete require.cache[file];
|
|
624
624
|
});
|
|
625
|
-
debug(
|
|
625
|
+
debug("deleted %d file(s) from the require cache", files.length);
|
|
626
626
|
};
|
package/lib/context.js
CHANGED
package/lib/error-constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* When Mocha throws exceptions (or rejects `Promise`s), it attempts to assign a `code` property to the `Error` object, for easier handling. These are the potential values of `code`.
|
|
@@ -12,112 +12,112 @@ var constants = {
|
|
|
12
12
|
* @constant
|
|
13
13
|
* @default
|
|
14
14
|
*/
|
|
15
|
-
FATAL:
|
|
15
|
+
FATAL: "ERR_MOCHA_FATAL",
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The type of an argument to a function call is invalid
|
|
19
19
|
* @constant
|
|
20
20
|
* @default
|
|
21
21
|
*/
|
|
22
|
-
INVALID_ARG_TYPE:
|
|
22
|
+
INVALID_ARG_TYPE: "ERR_MOCHA_INVALID_ARG_TYPE",
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* The value of an argument to a function call is invalid
|
|
26
26
|
* @constant
|
|
27
27
|
* @default
|
|
28
28
|
*/
|
|
29
|
-
INVALID_ARG_VALUE:
|
|
29
|
+
INVALID_ARG_VALUE: "ERR_MOCHA_INVALID_ARG_VALUE",
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Something was thrown, but it wasn't an `Error`
|
|
33
33
|
* @constant
|
|
34
34
|
* @default
|
|
35
35
|
*/
|
|
36
|
-
INVALID_EXCEPTION:
|
|
36
|
+
INVALID_EXCEPTION: "ERR_MOCHA_INVALID_EXCEPTION",
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* An interface (e.g., `Mocha.interfaces`) is unknown or invalid
|
|
40
40
|
* @constant
|
|
41
41
|
* @default
|
|
42
42
|
*/
|
|
43
|
-
INVALID_INTERFACE:
|
|
43
|
+
INVALID_INTERFACE: "ERR_MOCHA_INVALID_INTERFACE",
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* A reporter (.e.g, `Mocha.reporters`) is unknown or invalid
|
|
47
47
|
* @constant
|
|
48
48
|
* @default
|
|
49
49
|
*/
|
|
50
|
-
INVALID_REPORTER:
|
|
50
|
+
INVALID_REPORTER: "ERR_MOCHA_INVALID_REPORTER",
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* `done()` was called twice in a `Test` or `Hook` callback
|
|
54
54
|
* @constant
|
|
55
55
|
* @default
|
|
56
56
|
*/
|
|
57
|
-
MULTIPLE_DONE:
|
|
57
|
+
MULTIPLE_DONE: "ERR_MOCHA_MULTIPLE_DONE",
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* No files matched the pattern provided by the user
|
|
61
61
|
* @constant
|
|
62
62
|
* @default
|
|
63
63
|
*/
|
|
64
|
-
NO_FILES_MATCH_PATTERN:
|
|
64
|
+
NO_FILES_MATCH_PATTERN: "ERR_MOCHA_NO_FILES_MATCH_PATTERN",
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Known, but unsupported behavior of some kind
|
|
68
68
|
* @constant
|
|
69
69
|
* @default
|
|
70
70
|
*/
|
|
71
|
-
UNSUPPORTED:
|
|
71
|
+
UNSUPPORTED: "ERR_MOCHA_UNSUPPORTED",
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Invalid state transition occurring in `Mocha` instance
|
|
75
75
|
* @constant
|
|
76
76
|
* @default
|
|
77
77
|
*/
|
|
78
|
-
INSTANCE_ALREADY_RUNNING:
|
|
78
|
+
INSTANCE_ALREADY_RUNNING: "ERR_MOCHA_INSTANCE_ALREADY_RUNNING",
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Invalid state transition occurring in `Mocha` instance
|
|
82
82
|
* @constant
|
|
83
83
|
* @default
|
|
84
84
|
*/
|
|
85
|
-
INSTANCE_ALREADY_DISPOSED:
|
|
85
|
+
INSTANCE_ALREADY_DISPOSED: "ERR_MOCHA_INSTANCE_ALREADY_DISPOSED",
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Use of `only()` w/ `--forbid-only` results in this error.
|
|
89
89
|
* @constant
|
|
90
90
|
* @default
|
|
91
91
|
*/
|
|
92
|
-
FORBIDDEN_EXCLUSIVITY:
|
|
92
|
+
FORBIDDEN_EXCLUSIVITY: "ERR_MOCHA_FORBIDDEN_EXCLUSIVITY",
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* To be thrown when a user-defined plugin implementation (e.g., `mochaHooks`) is invalid
|
|
96
96
|
* @constant
|
|
97
97
|
* @default
|
|
98
98
|
*/
|
|
99
|
-
INVALID_PLUGIN_IMPLEMENTATION:
|
|
99
|
+
INVALID_PLUGIN_IMPLEMENTATION: "ERR_MOCHA_INVALID_PLUGIN_IMPLEMENTATION",
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* To be thrown when a builtin or third-party plugin definition (the _definition_ of `mochaHooks`) is invalid
|
|
103
103
|
* @constant
|
|
104
104
|
* @default
|
|
105
105
|
*/
|
|
106
|
-
INVALID_PLUGIN_DEFINITION:
|
|
106
|
+
INVALID_PLUGIN_DEFINITION: "ERR_MOCHA_INVALID_PLUGIN_DEFINITION",
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* When a runnable exceeds its allowed run time.
|
|
110
110
|
* @constant
|
|
111
111
|
* @default
|
|
112
112
|
*/
|
|
113
|
-
TIMEOUT:
|
|
113
|
+
TIMEOUT: "ERR_MOCHA_TIMEOUT",
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* Input file is not able to be parsed
|
|
117
117
|
* @constant
|
|
118
118
|
* @default
|
|
119
119
|
*/
|
|
120
|
-
UNPARSABLE_FILE:
|
|
120
|
+
UNPARSABLE_FILE: "ERR_MOCHA_UNPARSABLE_FILE",
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
module.exports = { constants };
|