mocha 9.2.2 → 10.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/bin/{mocha → mocha.js} +0 -0
- package/lib/cli/commands.js +1 -1
- package/lib/cli/run-option-metadata.js +0 -2
- package/lib/cli/run.js +1 -5
- package/lib/mocha.js +3 -52
- package/lib/nodejs/esm-utils.js +40 -70
- package/lib/nodejs/parallel-buffered-runner.js +3 -2
- package/lib/reporters/html.js +1 -1
- package/lib/runner.js +8 -18
- package/mocha.js +20611 -31247
- package/mocha.js.map +1 -1
- package/package.json +17 -28
- package/assets/growl/error.png +0 -0
- package/assets/growl/ok.png +0 -0
- package/lib/browser/growl.js +0 -169
- package/lib/nodejs/growl.js +0 -137
- package/mocha-es2018.js +0 -19794
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "simple, flexible, fun test framework",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"logo": "https://cldup.com/S9uQ-cOLYz.svg",
|
|
37
37
|
"notifyLogo": "https://ibin.co/4QuRuGjXvl36.png",
|
|
38
38
|
"bin": {
|
|
39
|
-
"mocha": "./bin/mocha",
|
|
39
|
+
"mocha": "./bin/mocha.js",
|
|
40
40
|
"_mocha": "./bin/_mocha"
|
|
41
41
|
},
|
|
42
42
|
"directories": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"test": "./test"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
47
|
+
"node": ">= 14.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"prepublishOnly": "nps test clean build",
|
|
@@ -58,45 +58,40 @@
|
|
|
58
58
|
"ansi-colors": "4.1.1",
|
|
59
59
|
"browser-stdout": "1.3.1",
|
|
60
60
|
"chokidar": "3.5.3",
|
|
61
|
-
"debug": "4.3.
|
|
61
|
+
"debug": "4.3.4",
|
|
62
62
|
"diff": "5.0.0",
|
|
63
63
|
"escape-string-regexp": "4.0.0",
|
|
64
64
|
"find-up": "5.0.0",
|
|
65
65
|
"glob": "7.2.0",
|
|
66
|
-
"growl": "1.10.5",
|
|
67
66
|
"he": "1.2.0",
|
|
68
67
|
"js-yaml": "4.1.0",
|
|
69
68
|
"log-symbols": "4.1.0",
|
|
70
|
-
"minimatch": "
|
|
69
|
+
"minimatch": "5.0.1",
|
|
71
70
|
"ms": "2.1.3",
|
|
72
|
-
"nanoid": "3.3.
|
|
71
|
+
"nanoid": "3.3.3",
|
|
73
72
|
"serialize-javascript": "6.0.0",
|
|
74
73
|
"strip-json-comments": "3.1.1",
|
|
75
74
|
"supports-color": "8.1.1",
|
|
76
|
-
"
|
|
77
|
-
"workerpool": "6.2.0",
|
|
75
|
+
"workerpool": "6.2.1",
|
|
78
76
|
"yargs": "16.2.0",
|
|
79
77
|
"yargs-parser": "20.2.4",
|
|
80
78
|
"yargs-unparser": "2.0.0"
|
|
81
79
|
},
|
|
82
80
|
"devDependencies": {
|
|
83
|
-
"@11ty/eleventy": "^0.
|
|
81
|
+
"@11ty/eleventy": "^1.0.0",
|
|
84
82
|
"@11ty/eleventy-plugin-inclusive-language": "^1.0.3",
|
|
85
83
|
"@babel/eslint-parser": "^7.16.5",
|
|
86
|
-
"@
|
|
87
|
-
"@
|
|
88
|
-
"@rollup/plugin-babel": "^5.1.0",
|
|
89
|
-
"@rollup/plugin-commonjs": "^14.0.0",
|
|
84
|
+
"@mocha/docdash": "^4.0.1",
|
|
85
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
90
86
|
"@rollup/plugin-json": "^4.1.0",
|
|
91
|
-
"@rollup/plugin-multi-entry": "^
|
|
92
|
-
"@rollup/plugin-node-resolve": "^
|
|
87
|
+
"@rollup/plugin-multi-entry": "^4.0.1",
|
|
88
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
93
89
|
"assetgraph-builder": "^9.0.0",
|
|
94
90
|
"autoprefixer": "^9.8.6",
|
|
95
91
|
"canvas": "^2.9.0",
|
|
96
92
|
"chai": "^4.3.4",
|
|
97
|
-
"
|
|
93
|
+
"coffeescript": "^2.6.1",
|
|
98
94
|
"configstore": "^5.0.1",
|
|
99
|
-
"core-js": "^3.20.3",
|
|
100
95
|
"coveralls": "^3.1.1",
|
|
101
96
|
"cross-env": "^7.0.2",
|
|
102
97
|
"eslint": "^7.32.0",
|
|
@@ -117,7 +112,6 @@
|
|
|
117
112
|
"karma-chrome-launcher": "^3.1.0",
|
|
118
113
|
"karma-mocha": "^2.0.1",
|
|
119
114
|
"karma-mocha-reporter": "^2.2.5",
|
|
120
|
-
"karma-requirejs": "^1.1.0",
|
|
121
115
|
"karma-sauce-launcher": "^4.3.6",
|
|
122
116
|
"lint-staged": "^10.2.11",
|
|
123
117
|
"markdown-it": "^12.3.2",
|
|
@@ -132,17 +126,15 @@
|
|
|
132
126
|
"nyc": "^15.1.0",
|
|
133
127
|
"pidtree": "^0.5.0",
|
|
134
128
|
"prettier": "^2.4.1",
|
|
135
|
-
"regenerator-runtime": "0.13.7",
|
|
136
129
|
"remark": "^14.0.2",
|
|
137
130
|
"remark-github": "^11.2.2",
|
|
138
131
|
"remark-inline-links": "^6.0.1",
|
|
139
|
-
"requirejs": "^2.3.6",
|
|
140
132
|
"rewiremock": "^3.14.3",
|
|
141
133
|
"rimraf": "^3.0.2",
|
|
142
|
-
"rollup": "^2.
|
|
134
|
+
"rollup": "^2.70.1",
|
|
143
135
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
144
|
-
"rollup-plugin-node
|
|
145
|
-
"rollup-plugin-visualizer": "^5.
|
|
136
|
+
"rollup-plugin-polyfill-node": "^0.8.0",
|
|
137
|
+
"rollup-plugin-visualizer": "^5.6.0",
|
|
146
138
|
"sinon": "^9.0.3",
|
|
147
139
|
"strip-ansi": "^6.0.0",
|
|
148
140
|
"svgo": "^1.3.2",
|
|
@@ -161,19 +153,16 @@
|
|
|
161
153
|
"webpack-cli": "^4.9.1"
|
|
162
154
|
},
|
|
163
155
|
"files": [
|
|
164
|
-
"bin/*mocha",
|
|
165
|
-
"assets/growl/*.png",
|
|
156
|
+
"bin/*mocha*",
|
|
166
157
|
"lib/**/*.{js,html,json}",
|
|
167
158
|
"index.js",
|
|
168
159
|
"mocha.css",
|
|
169
160
|
"mocha.js",
|
|
170
161
|
"mocha.js.map",
|
|
171
|
-
"mocha-es2018.js",
|
|
172
162
|
"browser-entry.js"
|
|
173
163
|
],
|
|
174
164
|
"browser": {
|
|
175
165
|
"./index.js": "./browser-entry.js",
|
|
176
|
-
"./lib/nodejs/growl.js": "./lib/browser/growl.js",
|
|
177
166
|
"fs": false,
|
|
178
167
|
"path": false,
|
|
179
168
|
"supports-color": false,
|
package/assets/growl/error.png
DELETED
|
Binary file
|
package/assets/growl/ok.png
DELETED
|
Binary file
|
package/lib/browser/growl.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Web Notifications module.
|
|
5
|
-
* @module Growl
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Save timer references to avoid Sinon interfering (see GH-237).
|
|
10
|
-
*/
|
|
11
|
-
var Date = global.Date;
|
|
12
|
-
var setTimeout = global.setTimeout;
|
|
13
|
-
var EVENT_RUN_END = require('../runner').constants.EVENT_RUN_END;
|
|
14
|
-
var isBrowser = require('../utils').isBrowser;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Checks if browser notification support exists.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
* @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)}
|
|
21
|
-
* @see {@link https://caniuse.com/#feat=promises|Browser support (promises)}
|
|
22
|
-
* @see {@link Mocha#growl}
|
|
23
|
-
* @see {@link Mocha#isGrowlCapable}
|
|
24
|
-
* @return {boolean} whether browser notification support exists
|
|
25
|
-
*/
|
|
26
|
-
exports.isCapable = function () {
|
|
27
|
-
var hasNotificationSupport = 'Notification' in window;
|
|
28
|
-
var hasPromiseSupport = typeof Promise === 'function';
|
|
29
|
-
return isBrowser() && hasNotificationSupport && hasPromiseSupport;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Implements browser notifications as a pseudo-reporter.
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API}
|
|
37
|
-
* @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification}
|
|
38
|
-
* @see {@link Growl#isPermitted}
|
|
39
|
-
* @see {@link Mocha#_growl}
|
|
40
|
-
* @param {Runner} runner - Runner instance.
|
|
41
|
-
*/
|
|
42
|
-
exports.notify = function (runner) {
|
|
43
|
-
var promise = isPermitted();
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Attempt notification.
|
|
47
|
-
*/
|
|
48
|
-
var sendNotification = function () {
|
|
49
|
-
// If user hasn't responded yet... "No notification for you!" (Seinfeld)
|
|
50
|
-
Promise.race([promise, Promise.resolve(undefined)])
|
|
51
|
-
.then(canNotify)
|
|
52
|
-
.then(function () {
|
|
53
|
-
display(runner);
|
|
54
|
-
})
|
|
55
|
-
.catch(notPermitted);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
runner.once(EVENT_RUN_END, sendNotification);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Checks if browser notification is permitted by user.
|
|
63
|
-
*
|
|
64
|
-
* @private
|
|
65
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission}
|
|
66
|
-
* @see {@link Mocha#growl}
|
|
67
|
-
* @see {@link Mocha#isGrowlPermitted}
|
|
68
|
-
* @returns {Promise<boolean>} promise determining if browser notification
|
|
69
|
-
* permissible when fulfilled.
|
|
70
|
-
*/
|
|
71
|
-
function isPermitted() {
|
|
72
|
-
var permitted = {
|
|
73
|
-
granted: function allow() {
|
|
74
|
-
return Promise.resolve(true);
|
|
75
|
-
},
|
|
76
|
-
denied: function deny() {
|
|
77
|
-
return Promise.resolve(false);
|
|
78
|
-
},
|
|
79
|
-
default: function ask() {
|
|
80
|
-
return Notification.requestPermission().then(function (permission) {
|
|
81
|
-
return permission === 'granted';
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return permitted[Notification.permission]();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @summary
|
|
91
|
-
* Determines if notification should proceed.
|
|
92
|
-
*
|
|
93
|
-
* @description
|
|
94
|
-
* Notification shall <strong>not</strong> proceed unless `value` is true.
|
|
95
|
-
*
|
|
96
|
-
* `value` will equal one of:
|
|
97
|
-
* <ul>
|
|
98
|
-
* <li><code>true</code> (from `isPermitted`)</li>
|
|
99
|
-
* <li><code>false</code> (from `isPermitted`)</li>
|
|
100
|
-
* <li><code>undefined</code> (from `Promise.race`)</li>
|
|
101
|
-
* </ul>
|
|
102
|
-
*
|
|
103
|
-
* @private
|
|
104
|
-
* @param {boolean|undefined} value - Determines if notification permissible.
|
|
105
|
-
* @returns {Promise<undefined>} Notification can proceed
|
|
106
|
-
*/
|
|
107
|
-
function canNotify(value) {
|
|
108
|
-
if (!value) {
|
|
109
|
-
var why = value === false ? 'blocked' : 'unacknowledged';
|
|
110
|
-
var reason = 'not permitted by user (' + why + ')';
|
|
111
|
-
return Promise.reject(new Error(reason));
|
|
112
|
-
}
|
|
113
|
-
return Promise.resolve();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Displays the notification.
|
|
118
|
-
*
|
|
119
|
-
* @private
|
|
120
|
-
* @param {Runner} runner - Runner instance.
|
|
121
|
-
*/
|
|
122
|
-
function display(runner) {
|
|
123
|
-
var stats = runner.stats;
|
|
124
|
-
var symbol = {
|
|
125
|
-
cross: '\u274C',
|
|
126
|
-
tick: '\u2705'
|
|
127
|
-
};
|
|
128
|
-
var logo = require('../../package.json').notifyLogo;
|
|
129
|
-
var _message;
|
|
130
|
-
var message;
|
|
131
|
-
var title;
|
|
132
|
-
|
|
133
|
-
if (stats.failures) {
|
|
134
|
-
_message = stats.failures + ' of ' + stats.tests + ' tests failed';
|
|
135
|
-
message = symbol.cross + ' ' + _message;
|
|
136
|
-
title = 'Failed';
|
|
137
|
-
} else {
|
|
138
|
-
_message = stats.passes + ' tests passed in ' + stats.duration + 'ms';
|
|
139
|
-
message = symbol.tick + ' ' + _message;
|
|
140
|
-
title = 'Passed';
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Send notification
|
|
144
|
-
var options = {
|
|
145
|
-
badge: logo,
|
|
146
|
-
body: message,
|
|
147
|
-
dir: 'ltr',
|
|
148
|
-
icon: logo,
|
|
149
|
-
lang: 'en-US',
|
|
150
|
-
name: 'mocha',
|
|
151
|
-
requireInteraction: false,
|
|
152
|
-
timestamp: Date.now()
|
|
153
|
-
};
|
|
154
|
-
var notification = new Notification(title, options);
|
|
155
|
-
|
|
156
|
-
// Autoclose after brief delay (makes various browsers act same)
|
|
157
|
-
var FORCE_DURATION = 4000;
|
|
158
|
-
setTimeout(notification.close.bind(notification), FORCE_DURATION);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* As notifications are tangential to our purpose, just log the error.
|
|
163
|
-
*
|
|
164
|
-
* @private
|
|
165
|
-
* @param {Error} err - Why notification didn't happen.
|
|
166
|
-
*/
|
|
167
|
-
function notPermitted(err) {
|
|
168
|
-
console.error('notification error:', err.message);
|
|
169
|
-
}
|
package/lib/nodejs/growl.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Desktop Notifications module.
|
|
5
|
-
* @module Growl
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const os = require('os');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const {sync: which} = require('which');
|
|
11
|
-
const {EVENT_RUN_END} = require('../runner').constants;
|
|
12
|
-
const {isBrowser} = require('../utils');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @summary
|
|
16
|
-
* Checks if Growl notification support seems likely.
|
|
17
|
-
*
|
|
18
|
-
* @description
|
|
19
|
-
* Glosses over the distinction between an unsupported platform
|
|
20
|
-
* and one that lacks prerequisite software installations.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
* @see {@link https://github.com/tj/node-growl/blob/master/README.md|Prerequisite Installs}
|
|
24
|
-
* @see {@link Mocha#growl}
|
|
25
|
-
* @see {@link Mocha#isGrowlCapable}
|
|
26
|
-
* @return {boolean} whether Growl notification support can be expected
|
|
27
|
-
*/
|
|
28
|
-
exports.isCapable = () => {
|
|
29
|
-
if (!isBrowser()) {
|
|
30
|
-
return getSupportBinaries().reduce(
|
|
31
|
-
(acc, binary) => acc || Boolean(which(binary, {nothrow: true})),
|
|
32
|
-
false
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Implements desktop notifications as a pseudo-reporter.
|
|
40
|
-
*
|
|
41
|
-
* @public
|
|
42
|
-
* @see {@link Mocha#_growl}
|
|
43
|
-
* @param {Runner} runner - Runner instance.
|
|
44
|
-
*/
|
|
45
|
-
exports.notify = runner => {
|
|
46
|
-
runner.once(EVENT_RUN_END, () => {
|
|
47
|
-
display(runner);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Displays the notification.
|
|
53
|
-
*
|
|
54
|
-
* @private
|
|
55
|
-
* @param {Runner} runner - Runner instance.
|
|
56
|
-
*/
|
|
57
|
-
const display = runner => {
|
|
58
|
-
const growl = require('growl');
|
|
59
|
-
const stats = runner.stats;
|
|
60
|
-
const symbol = {
|
|
61
|
-
cross: '\u274C',
|
|
62
|
-
tick: '\u2705'
|
|
63
|
-
};
|
|
64
|
-
let _message;
|
|
65
|
-
let message;
|
|
66
|
-
let title;
|
|
67
|
-
|
|
68
|
-
if (stats.failures) {
|
|
69
|
-
_message = `${stats.failures} of ${stats.tests} tests failed`;
|
|
70
|
-
message = `${symbol.cross} ${_message}`;
|
|
71
|
-
title = 'Failed';
|
|
72
|
-
} else {
|
|
73
|
-
_message = `${stats.passes} tests passed in ${stats.duration}ms`;
|
|
74
|
-
message = `${symbol.tick} ${_message}`;
|
|
75
|
-
title = 'Passed';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Send notification
|
|
79
|
-
const options = {
|
|
80
|
-
image: logo(),
|
|
81
|
-
name: 'mocha',
|
|
82
|
-
title
|
|
83
|
-
};
|
|
84
|
-
growl(message, options, onCompletion);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @summary
|
|
89
|
-
* Callback for result of attempted Growl notification.
|
|
90
|
-
*
|
|
91
|
-
* @description
|
|
92
|
-
* Despite its appearance, this is <strong>not</strong> an Error-first
|
|
93
|
-
* callback -- all parameters are populated regardless of success.
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
* @callback Growl~growlCB
|
|
97
|
-
* @param {*} err - Error object, or <code>null</code> if successful.
|
|
98
|
-
*/
|
|
99
|
-
function onCompletion(err) {
|
|
100
|
-
if (err) {
|
|
101
|
-
// As notifications are tangential to our purpose, just log the error.
|
|
102
|
-
const message =
|
|
103
|
-
err.code === 'ENOENT' ? 'prerequisite software not found' : err.message;
|
|
104
|
-
console.error('notification error:', message);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Returns Mocha logo image path.
|
|
110
|
-
*
|
|
111
|
-
* @private
|
|
112
|
-
* @return {string} Pathname of Mocha logo
|
|
113
|
-
*/
|
|
114
|
-
const logo = () => {
|
|
115
|
-
return path.join(__dirname, '..', 'assets', 'mocha-logo-96.png');
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @summary
|
|
120
|
-
* Gets platform-specific Growl support binaries.
|
|
121
|
-
*
|
|
122
|
-
* @description
|
|
123
|
-
* Somewhat brittle dependency on `growl` package implementation, but it
|
|
124
|
-
* rarely changes.
|
|
125
|
-
*
|
|
126
|
-
* @private
|
|
127
|
-
* @see {@link https://github.com/tj/node-growl/blob/master/lib/growl.js#L28-L126|setupCmd}
|
|
128
|
-
* @return {string[]} names of Growl support binaries
|
|
129
|
-
*/
|
|
130
|
-
const getSupportBinaries = () => {
|
|
131
|
-
const binaries = {
|
|
132
|
-
Darwin: ['terminal-notifier', 'growlnotify'],
|
|
133
|
-
Linux: ['notify-send', 'growl'],
|
|
134
|
-
Windows_NT: ['growlnotify.exe']
|
|
135
|
-
};
|
|
136
|
-
return binaries[os.type()] || [];
|
|
137
|
-
};
|