mocha 11.2.2 → 11.3.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/bin/mocha.js +8 -2
- package/lib/cli/run-helpers.js +3 -1
- package/lib/cli/run-option-metadata.js +1 -0
- package/lib/cli/run.js +4 -0
- package/mocha.js +2 -2
- package/package.json +6 -3
package/bin/mocha.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @private
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
const os = require('node:os');
|
|
13
14
|
const {loadOptions} = require('../lib/cli/options');
|
|
14
15
|
const {
|
|
15
16
|
unparseNodeFlags,
|
|
@@ -22,6 +23,7 @@ const {aliases} = require('../lib/cli/run-option-metadata');
|
|
|
22
23
|
|
|
23
24
|
const mochaArgs = {};
|
|
24
25
|
const nodeArgs = {};
|
|
26
|
+
const SIGNAL_OFFSET = 128;
|
|
25
27
|
let hasInspect = false;
|
|
26
28
|
|
|
27
29
|
const opts = loadOptions(process.argv.slice(2));
|
|
@@ -109,9 +111,13 @@ if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) {
|
|
|
109
111
|
proc.on('exit', (code, signal) => {
|
|
110
112
|
process.on('exit', () => {
|
|
111
113
|
if (signal) {
|
|
114
|
+
signal = typeof signal === 'string' ? os.constants.signals[signal] : signal;
|
|
115
|
+
if (mochaArgs['posix-exit-codes'] === true) {
|
|
116
|
+
process.exitCode = SIGNAL_OFFSET + signal;
|
|
117
|
+
}
|
|
112
118
|
process.kill(process.pid, signal);
|
|
113
119
|
} else {
|
|
114
|
-
process.exit(code);
|
|
120
|
+
process.exit(Math.min(code, mochaArgs['posix-exit-codes'] ? 1 : 255));
|
|
115
121
|
}
|
|
116
122
|
});
|
|
117
123
|
});
|
|
@@ -126,7 +132,7 @@ if (mochaArgs['node-option'] || Object.keys(nodeArgs).length || hasInspect) {
|
|
|
126
132
|
// be needed.
|
|
127
133
|
if (!args.parallel || args.jobs < 2) {
|
|
128
134
|
// win32 does not support SIGTERM, so use next best thing.
|
|
129
|
-
if (
|
|
135
|
+
if (os.platform() === 'win32') {
|
|
130
136
|
proc.kill('SIGKILL');
|
|
131
137
|
} else {
|
|
132
138
|
// using SIGKILL won't cleanly close the output streams, which can result
|
package/lib/cli/run-helpers.js
CHANGED
|
@@ -27,7 +27,7 @@ const {UnmatchedFile} = require('./collect-files');
|
|
|
27
27
|
*/
|
|
28
28
|
const exitMochaLater = clampedCode => {
|
|
29
29
|
process.on('exit', () => {
|
|
30
|
-
process.exitCode = clampedCode;
|
|
30
|
+
process.exitCode = Math.min(clampedCode, process.argv.includes('--posix-exit-codes') ? 1 : 255);
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -39,6 +39,8 @@ const exitMochaLater = clampedCode => {
|
|
|
39
39
|
* @private
|
|
40
40
|
*/
|
|
41
41
|
const exitMocha = clampedCode => {
|
|
42
|
+
const usePosixExitCodes = process.argv.includes('--posix-exit-codes');
|
|
43
|
+
clampedCode = Math.min(clampedCode, usePosixExitCodes ? 1 : 255);
|
|
42
44
|
let draining = 0;
|
|
43
45
|
|
|
44
46
|
// Eagerly set the process's exit code in case stream.write doesn't
|
package/lib/cli/run.js
CHANGED
|
@@ -195,6 +195,10 @@ exports.builder = yargs =>
|
|
|
195
195
|
description: 'Run tests in parallel',
|
|
196
196
|
group: GROUPS.RULES
|
|
197
197
|
},
|
|
198
|
+
'posix-exit-codes': {
|
|
199
|
+
description: 'Use POSIX and UNIX shell exit codes as Mocha\'s return value',
|
|
200
|
+
group: GROUPS.RULES
|
|
201
|
+
},
|
|
198
202
|
recursive: {
|
|
199
203
|
description: 'Look for tests in subdirectories',
|
|
200
204
|
group: GROUPS.FILES
|
package/mocha.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// mocha@11.
|
|
1
|
+
// mocha@11.3.0 in javascript ES2018
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -19256,7 +19256,7 @@
|
|
|
19256
19256
|
};
|
|
19257
19257
|
|
|
19258
19258
|
var name = "mocha";
|
|
19259
|
-
var version = "11.
|
|
19259
|
+
var version = "11.3.0";
|
|
19260
19260
|
var homepage = "https://mochajs.org/";
|
|
19261
19261
|
var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
|
|
19262
19262
|
var require$$17 = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "simple, flexible, fun test framework",
|
|
6
6
|
"keywords": [
|
|
@@ -48,8 +48,10 @@
|
|
|
48
48
|
"docs-clean": "rimraf docs/_site docs/api",
|
|
49
49
|
"docs-watch": "eleventy --serve",
|
|
50
50
|
"docs:api": "jsdoc -c jsdoc.conf.json",
|
|
51
|
-
"docs:
|
|
52
|
-
"docs": "
|
|
51
|
+
"docs:build": "eleventy",
|
|
52
|
+
"docs:build-new": "cd docs-next && npm i && npm run build-with-old",
|
|
53
|
+
"docs:preview": "http-server docs/_site -o",
|
|
54
|
+
"docs": "run-s docs-clean docs:api docs:build docs:build-new",
|
|
53
55
|
"format:eslint": "eslint --fix . \"bin/*\"",
|
|
54
56
|
"format:prettier": "prettier --write \"!(package*).json\" \".*.json\" \"lib/**/*.json\" \"*.yml\"",
|
|
55
57
|
"format": "run-s format:*",
|
|
@@ -132,6 +134,7 @@
|
|
|
132
134
|
"eslint-plugin-n": "^17.15.1",
|
|
133
135
|
"fail-on-errors-webpack-plugin": "^3.0.0",
|
|
134
136
|
"globals": "^13.24.0",
|
|
137
|
+
"http-server": "^14.1.1",
|
|
135
138
|
"installed-check": "^9.3.0",
|
|
136
139
|
"jsdoc": "^3.6.7",
|
|
137
140
|
"jsdoc-ts-utils": "^2.0.1",
|