mocha 10.7.3 → 10.8.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/LICENSE +1 -1
- package/README.md +15 -14
- package/lib/cli/options.js +22 -8
- package/lib/nodejs/serializer.js +7 -1
- package/lib/reporters/html.js +43 -18
- package/lib/utils.js +3 -1
- package/mocha.css +45 -19
- package/mocha.js +48 -21
- package/mocha.js.map +1 -1
- package/package.json +8 -8
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2011-
|
|
3
|
+
Copyright (c) 2011-2024 OpenJS Foundation and contributors, https://openjsf.org
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="
|
|
2
|
+
<img src="assets/mocha-logo.svg" alt="Mocha test framework logo"/>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️</p>
|
|
6
6
|
|
|
7
|
-
<
|
|
8
|
-
<a href="https://github.com/mochajs/mocha/actions?query=workflow%3ATests+branch%3Amain"><img src="https://github.com/mochajs/mocha/workflows/Tests/badge.svg?branch=main" alt="GitHub Actions Build Status"></a>
|
|
9
|
-
<a href="https://coveralls.io/github/mochajs/mocha"><img src="https://coveralls.io/repos/github/mochajs/mocha/badge.svg" alt="Coverage Status"></a>
|
|
10
|
-
<a href="https://discord.gg/KeDn2uXhER"><img alt="Chat - Discord" src="https://img.shields.io/badge/chat-Discord-5765F2.svg" /></a>
|
|
11
|
-
<a href="https://github.com/mochajs/mocha#sponsors"><img src="https://opencollective.com/mochajs/tiers/sponsors/badge.svg" alt="OpenCollective Sponsors"></a>
|
|
12
|
-
<a href="https://github.com/mochajs/mocha#backers"><img src="https://opencollective.com/mochajs/tiers/backers/badge.svg" alt="OpenCollective Backers"></a>
|
|
13
|
-
</p>
|
|
7
|
+
<div align="center">
|
|
14
8
|
|
|
15
|
-
<p align="center">
|
|
16
9
|
<a href="https://www.npmjs.com/package/mocha"><img src="https://img.shields.io/npm/v/mocha.svg" alt="NPM Version"></a>
|
|
17
10
|
<a href="https://github.com/mochajs/mocha"><img src="https://img.shields.io/node/v/mocha.svg" alt="Node Version"></a>
|
|
18
|
-
|
|
11
|
+
[](https://github.com/mochajs/mocha/actions/workflows/mocha.yml)
|
|
12
|
+
<a href="https://coveralls.io/github/mochajs/mocha"><img src="https://coveralls.io/repos/github/mochajs/mocha/badge.svg" alt="Coverage Status"></a>
|
|
13
|
+
|
|
14
|
+
</div>
|
|
19
15
|
|
|
20
|
-
<
|
|
16
|
+
<div align="center">
|
|
17
|
+
|
|
18
|
+
<a href="https://discord.gg/KeDn2uXhER"><img alt="Chat - Discord" src="https://img.shields.io/badge/Chat-Discord-5765F2.svg" /></a>
|
|
19
|
+
<a href="https://github.com/mochajs/mocha#sponsors"><img src="https://opencollective.com/mochajs/tiers/sponsors/badge.svg" alt="OpenCollective Sponsors"></a>
|
|
20
|
+
<a href="https://github.com/mochajs/mocha#backers"><img src="https://opencollective.com/mochajs/tiers/backers/badge.svg" alt="OpenCollective Backers"></a>
|
|
21
|
+
[](https://github.com/collective-funds/guidelines)
|
|
22
|
+
|
|
23
|
+
</div>
|
|
21
24
|
|
|
22
25
|
## Links
|
|
23
26
|
|
|
@@ -68,6 +71,4 @@ Finally, come [chat with the maintainers on Discord](https://discord.gg/KeDn2uXh
|
|
|
68
71
|
|
|
69
72
|
## License
|
|
70
73
|
|
|
71
|
-
Copyright 2011-
|
|
72
|
-
|
|
73
|
-
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large)
|
|
74
|
+
Copyright 2011-2024 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/main/LICENSE).
|
package/lib/cli/options.js
CHANGED
|
@@ -181,8 +181,24 @@ const loadPkgRc = (args = {}) => {
|
|
|
181
181
|
result = {};
|
|
182
182
|
const filepath = args.package || findUp.sync(mocharc.package);
|
|
183
183
|
if (filepath) {
|
|
184
|
+
let configData;
|
|
184
185
|
try {
|
|
185
|
-
|
|
186
|
+
configData = fs.readFileSync(filepath, 'utf8');
|
|
187
|
+
} catch (err) {
|
|
188
|
+
// If `args.package` was explicitly specified, throw an error
|
|
189
|
+
if (filepath == args.package) {
|
|
190
|
+
throw createUnparsableFileError(
|
|
191
|
+
`Unable to read ${filepath}: ${err}`,
|
|
192
|
+
filepath
|
|
193
|
+
);
|
|
194
|
+
} else {
|
|
195
|
+
debug('failed to read default package.json at %s; ignoring',
|
|
196
|
+
filepath);
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
const pkg = JSON.parse(configData);
|
|
186
202
|
if (pkg.mocha) {
|
|
187
203
|
debug('`mocha` prop of package.json parsed: %O', pkg.mocha);
|
|
188
204
|
result = pkg.mocha;
|
|
@@ -190,13 +206,11 @@ const loadPkgRc = (args = {}) => {
|
|
|
190
206
|
debug('no config found in %s', filepath);
|
|
191
207
|
}
|
|
192
208
|
} catch (err) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
debug('failed to read default package.json at %s; ignoring', filepath);
|
|
209
|
+
// If JSON failed to parse, throw an error.
|
|
210
|
+
throw createUnparsableFileError(
|
|
211
|
+
`Unable to parse ${filepath}: ${err}`,
|
|
212
|
+
filepath
|
|
213
|
+
);
|
|
200
214
|
}
|
|
201
215
|
}
|
|
202
216
|
return result;
|
package/lib/nodejs/serializer.js
CHANGED
|
@@ -262,9 +262,15 @@ class SerializableEvent {
|
|
|
262
262
|
breakCircularDeps(result.error);
|
|
263
263
|
|
|
264
264
|
const pairs = Object.keys(result).map(key => [result, key]);
|
|
265
|
-
|
|
265
|
+
const seenPairs = new Set();
|
|
266
266
|
let pair;
|
|
267
|
+
|
|
267
268
|
while ((pair = pairs.shift())) {
|
|
269
|
+
if (seenPairs.has(pair[1])) {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
seenPairs.add(pair[1]);
|
|
268
274
|
SerializableEvent._serialize(pairs, ...pair);
|
|
269
275
|
}
|
|
270
276
|
|
package/lib/reporters/html.js
CHANGED
|
@@ -32,11 +32,12 @@ var Date = global.Date;
|
|
|
32
32
|
exports = module.exports = HTML;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Stats template.
|
|
35
|
+
* Stats template: Result, progress, passes, failures, and duration.
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
var statsTemplate =
|
|
39
39
|
'<ul id="mocha-stats">' +
|
|
40
|
+
'<li class="result"></li>' +
|
|
40
41
|
'<li class="progress-contain"><progress class="progress-element" max="100" value="0"></progress><svg class="progress-ring"><circle class="ring-flatlight" stroke-dasharray="100%,0%"/><circle class="ring-highlight" stroke-dasharray="0%,100%"/></svg><div class="progress-text">0%</div></li>' +
|
|
41
42
|
'<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
|
|
42
43
|
'<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
|
|
@@ -62,18 +63,35 @@ function HTML(runner, options) {
|
|
|
62
63
|
var stats = this.stats;
|
|
63
64
|
var stat = fragment(statsTemplate);
|
|
64
65
|
var items = stat.getElementsByTagName('li');
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
const resultIndex = 0;
|
|
67
|
+
const progressIndex = 1;
|
|
68
|
+
const passesIndex = 2;
|
|
69
|
+
const failuresIndex = 3;
|
|
70
|
+
const durationIndex = 4;
|
|
71
|
+
/** Stat item containing the root suite pass or fail indicator (hasFailures ? '✖' : '✓') */
|
|
72
|
+
var resultIndicator = items[resultIndex];
|
|
73
|
+
/** Passes text and count */
|
|
74
|
+
const passesStat = items[passesIndex];
|
|
75
|
+
/** Stat item containing the pass count (not the word, just the number) */
|
|
76
|
+
const passesCount = passesStat.getElementsByTagName('em')[0];
|
|
77
|
+
/** Stat item linking to filter to show only passing tests */
|
|
78
|
+
const passesLink = passesStat.getElementsByTagName('a')[0];
|
|
79
|
+
/** Failures text and count */
|
|
80
|
+
const failuresStat = items[failuresIndex];
|
|
81
|
+
/** Stat item containing the failure count (not the word, just the number) */
|
|
82
|
+
const failuresCount = failuresStat.getElementsByTagName('em')[0];
|
|
83
|
+
/** Stat item linking to filter to show only failing tests */
|
|
84
|
+
const failuresLink = failuresStat.getElementsByTagName('a')[0];
|
|
85
|
+
/** Stat item linking to the duration time (not the word or unit, just the number) */
|
|
86
|
+
var duration = items[durationIndex].getElementsByTagName('em')[0];
|
|
70
87
|
var report = fragment('<ul id="mocha-report"></ul>');
|
|
71
88
|
var stack = [report];
|
|
72
|
-
var progressText = items[
|
|
73
|
-
var progressBar = items[
|
|
89
|
+
var progressText = items[progressIndex].getElementsByTagName('div')[0];
|
|
90
|
+
var progressBar = items[progressIndex].getElementsByTagName('progress')[0];
|
|
74
91
|
var progressRing = [
|
|
75
|
-
items[
|
|
76
|
-
items[
|
|
92
|
+
items[progressIndex].getElementsByClassName('ring-flatlight')[0],
|
|
93
|
+
items[progressIndex].getElementsByClassName('ring-highlight')[0]
|
|
94
|
+
];
|
|
77
95
|
var progressRingRadius = null; // computed CSS unavailable now, so set later
|
|
78
96
|
var root = document.getElementById('mocha');
|
|
79
97
|
|
|
@@ -127,6 +145,10 @@ function HTML(runner, options) {
|
|
|
127
145
|
|
|
128
146
|
runner.on(EVENT_SUITE_END, function (suite) {
|
|
129
147
|
if (suite.root) {
|
|
148
|
+
if (stats.failures === 0) {
|
|
149
|
+
text(resultIndicator, '✓');
|
|
150
|
+
stat.className += ' pass';
|
|
151
|
+
}
|
|
130
152
|
updateStats();
|
|
131
153
|
return;
|
|
132
154
|
}
|
|
@@ -147,6 +169,10 @@ function HTML(runner, options) {
|
|
|
147
169
|
});
|
|
148
170
|
|
|
149
171
|
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
172
|
+
// Update stat items
|
|
173
|
+
text(resultIndicator, '✖');
|
|
174
|
+
stat.className += ' fail';
|
|
175
|
+
|
|
150
176
|
var el = fragment(
|
|
151
177
|
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
|
|
152
178
|
playIcon +
|
|
@@ -219,7 +245,6 @@ function HTML(runner, options) {
|
|
|
219
245
|
}
|
|
220
246
|
|
|
221
247
|
function updateStats() {
|
|
222
|
-
// TODO: add to stats
|
|
223
248
|
var percent = ((stats.tests / runner.total) * 100) | 0;
|
|
224
249
|
progressBar.value = percent;
|
|
225
250
|
if (progressText) {
|
|
@@ -245,8 +270,8 @@ function HTML(runner, options) {
|
|
|
245
270
|
|
|
246
271
|
// update stats
|
|
247
272
|
var ms = new Date() - stats.start;
|
|
248
|
-
text(
|
|
249
|
-
text(
|
|
273
|
+
text(passesCount, stats.passes);
|
|
274
|
+
text(failuresCount, stats.failures);
|
|
250
275
|
text(duration, (ms / 1000).toFixed(2));
|
|
251
276
|
}
|
|
252
277
|
}
|
|
@@ -260,16 +285,16 @@ function HTML(runner, options) {
|
|
|
260
285
|
function makeUrl(s) {
|
|
261
286
|
var search = window.location.search;
|
|
262
287
|
|
|
263
|
-
// Remove previous grep query
|
|
288
|
+
// Remove previous {grep, fgrep, invert} query parameters if present
|
|
264
289
|
if (search) {
|
|
265
|
-
search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
|
|
290
|
+
search = search.replace(/[?&](?:f?grep|invert)=[^&\s]*/g, '').replace(/^&/, '?');
|
|
266
291
|
}
|
|
267
292
|
|
|
268
293
|
return (
|
|
269
294
|
window.location.pathname +
|
|
270
295
|
(search ? search + '&' : '?') +
|
|
271
296
|
'grep=' +
|
|
272
|
-
encodeURIComponent(
|
|
297
|
+
encodeURIComponent(s)
|
|
273
298
|
);
|
|
274
299
|
}
|
|
275
300
|
|
|
@@ -279,7 +304,7 @@ function makeUrl(s) {
|
|
|
279
304
|
* @param {Object} [suite]
|
|
280
305
|
*/
|
|
281
306
|
HTML.prototype.suiteURL = function (suite) {
|
|
282
|
-
return makeUrl(suite.fullTitle());
|
|
307
|
+
return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
|
|
283
308
|
};
|
|
284
309
|
|
|
285
310
|
/**
|
|
@@ -288,7 +313,7 @@ HTML.prototype.suiteURL = function (suite) {
|
|
|
288
313
|
* @param {Object} [test]
|
|
289
314
|
*/
|
|
290
315
|
HTML.prototype.testURL = function (test) {
|
|
291
|
-
return makeUrl(test.fullTitle());
|
|
316
|
+
return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
|
|
292
317
|
};
|
|
293
318
|
|
|
294
319
|
/**
|
package/lib/utils.js
CHANGED
|
@@ -675,7 +675,9 @@ exports.breakCircularDeps = inputObj => {
|
|
|
675
675
|
|
|
676
676
|
seen.add(obj);
|
|
677
677
|
for (const k in obj) {
|
|
678
|
-
|
|
678
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, k);
|
|
679
|
+
|
|
680
|
+
if (descriptor && descriptor.writable) {
|
|
679
681
|
obj[k] = _breakCircularDeps(obj[k], k);
|
|
680
682
|
}
|
|
681
683
|
}
|
package/mocha.css
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
:root {
|
|
4
4
|
--mocha-color: #000;
|
|
5
5
|
--mocha-bg-color: #fff;
|
|
6
|
-
--mocha-pass-
|
|
7
|
-
--mocha-pass-color: #fff;
|
|
8
|
-
--mocha-pass-shadow-color: rgba(0,0,0
|
|
9
|
-
--mocha-pass-mediump-color: #c09853;
|
|
10
|
-
--mocha-pass-slow-color: #b94a48;
|
|
6
|
+
--mocha-test-pass-color: #007f6a;
|
|
7
|
+
--mocha-test-pass-duration-color: #fff;
|
|
8
|
+
--mocha-test-pass-shadow-color: rgba(0,0,0, 0.2);
|
|
9
|
+
--mocha-test-pass-mediump-color: #c09853;
|
|
10
|
+
--mocha-test-pass-slow-color: #b94a48;
|
|
11
11
|
--mocha-test-pending-color: #0b97c4;
|
|
12
12
|
--mocha-test-pending-icon-color: #0b97c4;
|
|
13
13
|
--mocha-test-fail-color: #c00;
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
:root {
|
|
39
39
|
--mocha-color: #fff;
|
|
40
40
|
--mocha-bg-color: #222;
|
|
41
|
-
--mocha-pass-
|
|
42
|
-
--mocha-pass-color: #222;
|
|
43
|
-
--mocha-pass-shadow-color: rgba(255,255,255
|
|
44
|
-
--mocha-pass-mediump-color: #f1be67;
|
|
45
|
-
--mocha-pass-slow-color: #f49896;
|
|
41
|
+
--mocha-test-pass-color: #00d6b2;
|
|
42
|
+
--mocha-test-pass-duration-color: #222;
|
|
43
|
+
--mocha-test-pass-shadow-color: rgba(255, 255, 255, 0.2);
|
|
44
|
+
--mocha-test-pass-mediump-color: #f1be67;
|
|
45
|
+
--mocha-test-pass-slow-color: #f49896;
|
|
46
46
|
--mocha-test-pending-color: #0b97c4;
|
|
47
47
|
--mocha-test-pending-icon-color: #0b97c4;
|
|
48
48
|
--mocha-test-fail-color: #f44;
|
|
@@ -141,11 +141,11 @@ body {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
#mocha .test.pass.medium .duration {
|
|
144
|
-
background: var(--mocha-pass-mediump-color);
|
|
144
|
+
background: var(--mocha-test-pass-mediump-color);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
#mocha .test.pass.slow .duration {
|
|
148
|
-
background: var(--mocha-pass-slow-color);
|
|
148
|
+
background: var(--mocha-test-pass-slow-color);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
#mocha .test.pass::before {
|
|
@@ -154,17 +154,17 @@ body {
|
|
|
154
154
|
display: block;
|
|
155
155
|
float: left;
|
|
156
156
|
margin-right: 5px;
|
|
157
|
-
color: var(--mocha-pass-
|
|
157
|
+
color: var(--mocha-test-pass-color);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
#mocha .test.pass .duration {
|
|
161
161
|
font-size: 9px;
|
|
162
162
|
margin-left: 5px;
|
|
163
163
|
padding: 2px 5px;
|
|
164
|
-
color: var(--mocha-pass-color);
|
|
165
|
-
-webkit-box-shadow: inset 0 1px 1px var(--mocha-pass-shadow-color);
|
|
166
|
-
-moz-box-shadow: inset 0 1px 1px var(--mocha-pass-shadow-color);
|
|
167
|
-
box-shadow: inset 0 1px 1px var(--mocha-pass-shadow-color);
|
|
164
|
+
color: var(--mocha-test-pass-duration-color);
|
|
165
|
+
-webkit-box-shadow: inset 0 1px 1px var(--mocha-test-pass-shadow-color);
|
|
166
|
+
-moz-box-shadow: inset 0 1px 1px var(--mocha-test-pass-shadow-color);
|
|
167
|
+
box-shadow: inset 0 1px 1px var(--mocha-test-pass-shadow-color);
|
|
168
168
|
-webkit-border-radius: 5px;
|
|
169
169
|
-moz-border-radius: 5px;
|
|
170
170
|
-ms-border-radius: 5px;
|
|
@@ -344,12 +344,37 @@ body {
|
|
|
344
344
|
z-index: 1;
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
#mocha-stats.fail li.result {
|
|
348
|
+
color: var(--mocha-test-fail-color);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#mocha-stats.fail li.failures {
|
|
352
|
+
color: var(--mocha-test-fail-color);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
#mocha-stats.fail li.failures em {
|
|
356
|
+
color: var(--mocha-test-fail-color);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
#mocha-stats.pass li.result {
|
|
360
|
+
color: var(--mocha-test-pass-color);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#mocha-stats.pass li.passes {
|
|
364
|
+
color: var(--mocha-test-pass-color);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
#mocha-stats.pass li.passes em {
|
|
368
|
+
color: var(--mocha-test-pass-color);
|
|
369
|
+
}
|
|
370
|
+
|
|
347
371
|
#mocha-stats .progress-contain {
|
|
348
372
|
float: right;
|
|
349
373
|
padding: 0;
|
|
350
374
|
}
|
|
351
375
|
|
|
352
|
-
#mocha-stats
|
|
376
|
+
#mocha-stats .progress-element,
|
|
377
|
+
#mocha-stats .progress-text {
|
|
353
378
|
width: var(--ring-container-size);
|
|
354
379
|
display: block;
|
|
355
380
|
top: 12px;
|
|
@@ -374,7 +399,8 @@ body {
|
|
|
374
399
|
height: var(--ring-container-size);
|
|
375
400
|
}
|
|
376
401
|
|
|
377
|
-
#mocha-stats
|
|
402
|
+
#mocha-stats .ring-flatlight,
|
|
403
|
+
#mocha-stats .ring-highlight {
|
|
378
404
|
--stroke-thickness: 1.65px;
|
|
379
405
|
--center: calc(var(--ring-container-size) / 2);
|
|
380
406
|
cx: var(--center);
|
package/mocha.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// mocha@10.
|
|
1
|
+
// mocha@10.8.2 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) :
|
|
@@ -11638,7 +11638,9 @@
|
|
|
11638
11638
|
|
|
11639
11639
|
seen.add(obj);
|
|
11640
11640
|
for (const k in obj) {
|
|
11641
|
-
|
|
11641
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, k);
|
|
11642
|
+
|
|
11643
|
+
if (descriptor && descriptor.writable) {
|
|
11642
11644
|
obj[k] = _breakCircularDeps(obj[k]);
|
|
11643
11645
|
}
|
|
11644
11646
|
}
|
|
@@ -16729,11 +16731,12 @@
|
|
|
16729
16731
|
module.exports = HTML;
|
|
16730
16732
|
|
|
16731
16733
|
/**
|
|
16732
|
-
* Stats template.
|
|
16734
|
+
* Stats template: Result, progress, passes, failures, and duration.
|
|
16733
16735
|
*/
|
|
16734
16736
|
|
|
16735
16737
|
var statsTemplate =
|
|
16736
16738
|
'<ul id="mocha-stats">' +
|
|
16739
|
+
'<li class="result"></li>' +
|
|
16737
16740
|
'<li class="progress-contain"><progress class="progress-element" max="100" value="0"></progress><svg class="progress-ring"><circle class="ring-flatlight" stroke-dasharray="100%,0%"/><circle class="ring-highlight" stroke-dasharray="0%,100%"/></svg><div class="progress-text">0%</div></li>' +
|
|
16738
16741
|
'<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
|
|
16739
16742
|
'<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
|
|
@@ -16759,18 +16762,35 @@
|
|
|
16759
16762
|
var stats = this.stats;
|
|
16760
16763
|
var stat = fragment(statsTemplate);
|
|
16761
16764
|
var items = stat.getElementsByTagName('li');
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
|
|
16765
|
+
const resultIndex = 0;
|
|
16766
|
+
const progressIndex = 1;
|
|
16767
|
+
const passesIndex = 2;
|
|
16768
|
+
const failuresIndex = 3;
|
|
16769
|
+
const durationIndex = 4;
|
|
16770
|
+
/** Stat item containing the root suite pass or fail indicator (hasFailures ? '✖' : '✓') */
|
|
16771
|
+
var resultIndicator = items[resultIndex];
|
|
16772
|
+
/** Passes text and count */
|
|
16773
|
+
const passesStat = items[passesIndex];
|
|
16774
|
+
/** Stat item containing the pass count (not the word, just the number) */
|
|
16775
|
+
const passesCount = passesStat.getElementsByTagName('em')[0];
|
|
16776
|
+
/** Stat item linking to filter to show only passing tests */
|
|
16777
|
+
const passesLink = passesStat.getElementsByTagName('a')[0];
|
|
16778
|
+
/** Failures text and count */
|
|
16779
|
+
const failuresStat = items[failuresIndex];
|
|
16780
|
+
/** Stat item containing the failure count (not the word, just the number) */
|
|
16781
|
+
const failuresCount = failuresStat.getElementsByTagName('em')[0];
|
|
16782
|
+
/** Stat item linking to filter to show only failing tests */
|
|
16783
|
+
const failuresLink = failuresStat.getElementsByTagName('a')[0];
|
|
16784
|
+
/** Stat item linking to the duration time (not the word or unit, just the number) */
|
|
16785
|
+
var duration = items[durationIndex].getElementsByTagName('em')[0];
|
|
16767
16786
|
var report = fragment('<ul id="mocha-report"></ul>');
|
|
16768
16787
|
var stack = [report];
|
|
16769
|
-
var progressText = items[
|
|
16770
|
-
var progressBar = items[
|
|
16788
|
+
var progressText = items[progressIndex].getElementsByTagName('div')[0];
|
|
16789
|
+
var progressBar = items[progressIndex].getElementsByTagName('progress')[0];
|
|
16771
16790
|
var progressRing = [
|
|
16772
|
-
items[
|
|
16773
|
-
items[
|
|
16791
|
+
items[progressIndex].getElementsByClassName('ring-flatlight')[0],
|
|
16792
|
+
items[progressIndex].getElementsByClassName('ring-highlight')[0]
|
|
16793
|
+
];
|
|
16774
16794
|
var root = document.getElementById('mocha');
|
|
16775
16795
|
|
|
16776
16796
|
if (!root) {
|
|
@@ -16823,6 +16843,10 @@
|
|
|
16823
16843
|
|
|
16824
16844
|
runner.on(EVENT_SUITE_END, function (suite) {
|
|
16825
16845
|
if (suite.root) {
|
|
16846
|
+
if (stats.failures === 0) {
|
|
16847
|
+
text(resultIndicator, '✓');
|
|
16848
|
+
stat.className += ' pass';
|
|
16849
|
+
}
|
|
16826
16850
|
updateStats();
|
|
16827
16851
|
return;
|
|
16828
16852
|
}
|
|
@@ -16843,6 +16867,10 @@
|
|
|
16843
16867
|
});
|
|
16844
16868
|
|
|
16845
16869
|
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
16870
|
+
// Update stat items
|
|
16871
|
+
text(resultIndicator, '✖');
|
|
16872
|
+
stat.className += ' fail';
|
|
16873
|
+
|
|
16846
16874
|
var el = fragment(
|
|
16847
16875
|
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
|
|
16848
16876
|
playIcon +
|
|
@@ -16915,7 +16943,6 @@
|
|
|
16915
16943
|
}
|
|
16916
16944
|
|
|
16917
16945
|
function updateStats() {
|
|
16918
|
-
// TODO: add to stats
|
|
16919
16946
|
var percent = ((stats.tests / runner.total) * 100) | 0;
|
|
16920
16947
|
progressBar.value = percent;
|
|
16921
16948
|
if (progressText) {
|
|
@@ -16941,8 +16968,8 @@
|
|
|
16941
16968
|
|
|
16942
16969
|
// update stats
|
|
16943
16970
|
var ms = new Date() - stats.start;
|
|
16944
|
-
text(
|
|
16945
|
-
text(
|
|
16971
|
+
text(passesCount, stats.passes);
|
|
16972
|
+
text(failuresCount, stats.failures);
|
|
16946
16973
|
text(duration, (ms / 1000).toFixed(2));
|
|
16947
16974
|
}
|
|
16948
16975
|
}
|
|
@@ -16956,16 +16983,16 @@
|
|
|
16956
16983
|
function makeUrl(s) {
|
|
16957
16984
|
var search = window.location.search;
|
|
16958
16985
|
|
|
16959
|
-
// Remove previous grep query
|
|
16986
|
+
// Remove previous {grep, fgrep, invert} query parameters if present
|
|
16960
16987
|
if (search) {
|
|
16961
|
-
search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
|
|
16988
|
+
search = search.replace(/[?&](?:f?grep|invert)=[^&\s]*/g, '').replace(/^&/, '?');
|
|
16962
16989
|
}
|
|
16963
16990
|
|
|
16964
16991
|
return (
|
|
16965
16992
|
window.location.pathname +
|
|
16966
16993
|
(search ? search + '&' : '?') +
|
|
16967
16994
|
'grep=' +
|
|
16968
|
-
encodeURIComponent(
|
|
16995
|
+
encodeURIComponent(s)
|
|
16969
16996
|
);
|
|
16970
16997
|
}
|
|
16971
16998
|
|
|
@@ -16975,7 +17002,7 @@
|
|
|
16975
17002
|
* @param {Object} [suite]
|
|
16976
17003
|
*/
|
|
16977
17004
|
HTML.prototype.suiteURL = function (suite) {
|
|
16978
|
-
return makeUrl(suite.fullTitle());
|
|
17005
|
+
return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
|
|
16979
17006
|
};
|
|
16980
17007
|
|
|
16981
17008
|
/**
|
|
@@ -16984,7 +17011,7 @@
|
|
|
16984
17011
|
* @param {Object} [test]
|
|
16985
17012
|
*/
|
|
16986
17013
|
HTML.prototype.testURL = function (test) {
|
|
16987
|
-
return makeUrl(test.fullTitle());
|
|
17014
|
+
return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
|
|
16988
17015
|
};
|
|
16989
17016
|
|
|
16990
17017
|
/**
|
|
@@ -19174,7 +19201,7 @@
|
|
|
19174
19201
|
};
|
|
19175
19202
|
|
|
19176
19203
|
var name = "mocha";
|
|
19177
|
-
var version = "10.
|
|
19204
|
+
var version = "10.8.2";
|
|
19178
19205
|
var homepage = "https://mochajs.org/";
|
|
19179
19206
|
var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
|
|
19180
19207
|
var require$$17 = {
|