mocha 10.7.3 → 10.8.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/LICENSE +1 -1
- package/README.md +15 -14
- package/lib/reporters/html.js +38 -13
- package/mocha.css +45 -19
- package/mocha.js +40 -15
- 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/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
|
}
|
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.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) :
|
|
@@ -16729,11 +16729,12 @@
|
|
|
16729
16729
|
module.exports = HTML;
|
|
16730
16730
|
|
|
16731
16731
|
/**
|
|
16732
|
-
* Stats template.
|
|
16732
|
+
* Stats template: Result, progress, passes, failures, and duration.
|
|
16733
16733
|
*/
|
|
16734
16734
|
|
|
16735
16735
|
var statsTemplate =
|
|
16736
16736
|
'<ul id="mocha-stats">' +
|
|
16737
|
+
'<li class="result"></li>' +
|
|
16737
16738
|
'<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
16739
|
'<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
|
|
16739
16740
|
'<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
|
|
@@ -16759,18 +16760,35 @@
|
|
|
16759
16760
|
var stats = this.stats;
|
|
16760
16761
|
var stat = fragment(statsTemplate);
|
|
16761
16762
|
var items = stat.getElementsByTagName('li');
|
|
16762
|
-
|
|
16763
|
-
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
|
|
16763
|
+
const resultIndex = 0;
|
|
16764
|
+
const progressIndex = 1;
|
|
16765
|
+
const passesIndex = 2;
|
|
16766
|
+
const failuresIndex = 3;
|
|
16767
|
+
const durationIndex = 4;
|
|
16768
|
+
/** Stat item containing the root suite pass or fail indicator (hasFailures ? '✖' : '✓') */
|
|
16769
|
+
var resultIndicator = items[resultIndex];
|
|
16770
|
+
/** Passes text and count */
|
|
16771
|
+
const passesStat = items[passesIndex];
|
|
16772
|
+
/** Stat item containing the pass count (not the word, just the number) */
|
|
16773
|
+
const passesCount = passesStat.getElementsByTagName('em')[0];
|
|
16774
|
+
/** Stat item linking to filter to show only passing tests */
|
|
16775
|
+
const passesLink = passesStat.getElementsByTagName('a')[0];
|
|
16776
|
+
/** Failures text and count */
|
|
16777
|
+
const failuresStat = items[failuresIndex];
|
|
16778
|
+
/** Stat item containing the failure count (not the word, just the number) */
|
|
16779
|
+
const failuresCount = failuresStat.getElementsByTagName('em')[0];
|
|
16780
|
+
/** Stat item linking to filter to show only failing tests */
|
|
16781
|
+
const failuresLink = failuresStat.getElementsByTagName('a')[0];
|
|
16782
|
+
/** Stat item linking to the duration time (not the word or unit, just the number) */
|
|
16783
|
+
var duration = items[durationIndex].getElementsByTagName('em')[0];
|
|
16767
16784
|
var report = fragment('<ul id="mocha-report"></ul>');
|
|
16768
16785
|
var stack = [report];
|
|
16769
|
-
var progressText = items[
|
|
16770
|
-
var progressBar = items[
|
|
16786
|
+
var progressText = items[progressIndex].getElementsByTagName('div')[0];
|
|
16787
|
+
var progressBar = items[progressIndex].getElementsByTagName('progress')[0];
|
|
16771
16788
|
var progressRing = [
|
|
16772
|
-
items[
|
|
16773
|
-
items[
|
|
16789
|
+
items[progressIndex].getElementsByClassName('ring-flatlight')[0],
|
|
16790
|
+
items[progressIndex].getElementsByClassName('ring-highlight')[0]
|
|
16791
|
+
];
|
|
16774
16792
|
var root = document.getElementById('mocha');
|
|
16775
16793
|
|
|
16776
16794
|
if (!root) {
|
|
@@ -16823,6 +16841,10 @@
|
|
|
16823
16841
|
|
|
16824
16842
|
runner.on(EVENT_SUITE_END, function (suite) {
|
|
16825
16843
|
if (suite.root) {
|
|
16844
|
+
if (stats.failures === 0) {
|
|
16845
|
+
text(resultIndicator, '✓');
|
|
16846
|
+
stat.className += ' pass';
|
|
16847
|
+
}
|
|
16826
16848
|
updateStats();
|
|
16827
16849
|
return;
|
|
16828
16850
|
}
|
|
@@ -16843,6 +16865,10 @@
|
|
|
16843
16865
|
});
|
|
16844
16866
|
|
|
16845
16867
|
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
16868
|
+
// Update stat items
|
|
16869
|
+
text(resultIndicator, '✖');
|
|
16870
|
+
stat.className += ' fail';
|
|
16871
|
+
|
|
16846
16872
|
var el = fragment(
|
|
16847
16873
|
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
|
|
16848
16874
|
playIcon +
|
|
@@ -16915,7 +16941,6 @@
|
|
|
16915
16941
|
}
|
|
16916
16942
|
|
|
16917
16943
|
function updateStats() {
|
|
16918
|
-
// TODO: add to stats
|
|
16919
16944
|
var percent = ((stats.tests / runner.total) * 100) | 0;
|
|
16920
16945
|
progressBar.value = percent;
|
|
16921
16946
|
if (progressText) {
|
|
@@ -16941,8 +16966,8 @@
|
|
|
16941
16966
|
|
|
16942
16967
|
// update stats
|
|
16943
16968
|
var ms = new Date() - stats.start;
|
|
16944
|
-
text(
|
|
16945
|
-
text(
|
|
16969
|
+
text(passesCount, stats.passes);
|
|
16970
|
+
text(failuresCount, stats.failures);
|
|
16946
16971
|
text(duration, (ms / 1000).toFixed(2));
|
|
16947
16972
|
}
|
|
16948
16973
|
}
|
|
@@ -19174,7 +19199,7 @@
|
|
|
19174
19199
|
};
|
|
19175
19200
|
|
|
19176
19201
|
var name = "mocha";
|
|
19177
|
-
var version = "10.
|
|
19202
|
+
var version = "10.8.0";
|
|
19178
19203
|
var homepage = "https://mochajs.org/";
|
|
19179
19204
|
var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
|
|
19180
19205
|
var require$$17 = {
|