mocha 5.1.0 → 6.0.0-1
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/CHANGELOG.md +653 -981
- package/README.md +2 -1
- package/{images → assets/growl}/error.png +0 -0
- package/{images → assets/growl}/ok.png +0 -0
- package/bin/_mocha +4 -595
- package/bin/mocha +84 -58
- package/bin/options.js +6 -39
- package/browser-entry.js +21 -17
- package/lib/browser/growl.js +164 -2
- package/lib/browser/progress.js +11 -11
- package/lib/{template.html → browser/template.html} +0 -0
- package/lib/browser/tty.js +2 -2
- package/lib/cli/cli.js +68 -0
- package/lib/cli/commands.js +13 -0
- package/lib/cli/config.js +79 -0
- package/lib/cli/index.js +9 -0
- package/lib/cli/init.js +37 -0
- package/lib/cli/node-flags.js +48 -0
- package/lib/cli/one-and-dones.js +70 -0
- package/lib/cli/options.js +299 -0
- package/lib/cli/run-helpers.js +328 -0
- package/lib/cli/run-option-metadata.js +72 -0
- package/lib/cli/run.js +293 -0
- package/lib/context.js +14 -14
- package/lib/errors.js +139 -0
- package/lib/growl.js +135 -0
- package/lib/hook.js +5 -16
- package/lib/interfaces/bdd.js +14 -13
- package/lib/interfaces/common.js +59 -16
- package/lib/interfaces/exports.js +4 -7
- package/lib/interfaces/qunit.js +8 -10
- package/lib/interfaces/tdd.js +10 -11
- package/lib/mocha.js +442 -255
- package/lib/mocharc.json +10 -0
- package/lib/pending.js +1 -5
- package/lib/reporters/base.js +92 -117
- package/lib/reporters/doc.js +18 -9
- package/lib/reporters/dot.js +13 -13
- package/lib/reporters/html.js +76 -47
- package/lib/reporters/json-stream.js +38 -23
- package/lib/reporters/json.js +26 -23
- package/lib/reporters/landing.js +9 -8
- package/lib/reporters/list.js +11 -10
- package/lib/reporters/markdown.js +13 -12
- package/lib/reporters/min.js +4 -3
- package/lib/reporters/nyan.js +36 -35
- package/lib/reporters/progress.js +8 -7
- package/lib/reporters/spec.js +14 -11
- package/lib/reporters/tap.js +243 -32
- package/lib/reporters/xunit.js +52 -33
- package/lib/runnable.js +103 -90
- package/lib/runner.js +156 -107
- package/lib/stats-collector.js +81 -0
- package/lib/suite.js +57 -51
- package/lib/test.js +13 -13
- package/lib/utils.js +192 -103
- package/mocha.js +3836 -2046
- package/package.json +122 -38
- package/bin/.eslintrc.yml +0 -3
- package/lib/browser/.eslintrc.yml +0 -4
- package/lib/ms.js +0 -94
- package/lib/reporters/base.js.orig +0 -498
- package/lib/reporters/json.js.orig +0 -128
|
@@ -28,32 +28,31 @@ exports = module.exports = Markdown;
|
|
|
28
28
|
* @class
|
|
29
29
|
* @memberof Mocha.reporters
|
|
30
30
|
* @extends Mocha.reporters.Base
|
|
31
|
-
* @api public
|
|
32
31
|
* @param {Runner} runner
|
|
33
32
|
*/
|
|
34
|
-
function Markdown
|
|
33
|
+
function Markdown(runner) {
|
|
35
34
|
Base.call(this, runner);
|
|
36
35
|
|
|
37
36
|
var level = 0;
|
|
38
37
|
var buf = '';
|
|
39
38
|
|
|
40
|
-
function title
|
|
39
|
+
function title(str) {
|
|
41
40
|
return Array(level).join('#') + ' ' + str;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
function mapTOC
|
|
43
|
+
function mapTOC(suite, obj) {
|
|
45
44
|
var ret = obj;
|
|
46
45
|
var key = SUITE_PREFIX + suite.title;
|
|
47
46
|
|
|
48
|
-
obj = obj[key] = obj[key] || {
|
|
49
|
-
suite.suites.forEach(function
|
|
47
|
+
obj = obj[key] = obj[key] || {suite: suite};
|
|
48
|
+
suite.suites.forEach(function(suite) {
|
|
50
49
|
mapTOC(suite, obj);
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
return ret;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
function stringifyTOC
|
|
55
|
+
function stringifyTOC(obj, level) {
|
|
57
56
|
++level;
|
|
58
57
|
var buf = '';
|
|
59
58
|
var link;
|
|
@@ -71,25 +70,25 @@ function Markdown (runner) {
|
|
|
71
70
|
return buf;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
function generateTOC
|
|
73
|
+
function generateTOC(suite) {
|
|
75
74
|
var obj = mapTOC(suite, {});
|
|
76
75
|
return stringifyTOC(obj, 0);
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
generateTOC(runner.suite);
|
|
80
79
|
|
|
81
|
-
runner.on('suite', function
|
|
80
|
+
runner.on('suite', function(suite) {
|
|
82
81
|
++level;
|
|
83
82
|
var slug = utils.slug(suite.fullTitle());
|
|
84
83
|
buf += '<a name="' + slug + '"></a>' + '\n';
|
|
85
84
|
buf += title(suite.title) + '\n';
|
|
86
85
|
});
|
|
87
86
|
|
|
88
|
-
runner.on('suite end', function
|
|
87
|
+
runner.on('suite end', function() {
|
|
89
88
|
--level;
|
|
90
89
|
});
|
|
91
90
|
|
|
92
|
-
runner.on('pass', function
|
|
91
|
+
runner.on('pass', function(test) {
|
|
93
92
|
var code = utils.clean(test.body);
|
|
94
93
|
buf += test.title + '.\n';
|
|
95
94
|
buf += '\n```js\n';
|
|
@@ -97,9 +96,11 @@ function Markdown (runner) {
|
|
|
97
96
|
buf += '```\n\n';
|
|
98
97
|
});
|
|
99
98
|
|
|
100
|
-
runner.once('end', function
|
|
99
|
+
runner.once('end', function() {
|
|
101
100
|
process.stdout.write('# TOC\n');
|
|
102
101
|
process.stdout.write(generateTOC(runner.suite));
|
|
103
102
|
process.stdout.write(buf);
|
|
104
103
|
});
|
|
105
104
|
}
|
|
105
|
+
|
|
106
|
+
Markdown.description = 'GitHub Flavored Markdown';
|
package/lib/reporters/min.js
CHANGED
|
@@ -22,13 +22,12 @@ exports = module.exports = Min;
|
|
|
22
22
|
* @class
|
|
23
23
|
* @memberof Mocha.reporters
|
|
24
24
|
* @extends Mocha.reporters.Base
|
|
25
|
-
* @api public
|
|
26
25
|
* @param {Runner} runner
|
|
27
26
|
*/
|
|
28
|
-
function Min
|
|
27
|
+
function Min(runner) {
|
|
29
28
|
Base.call(this, runner);
|
|
30
29
|
|
|
31
|
-
runner.on('start', function
|
|
30
|
+
runner.on('start', function() {
|
|
32
31
|
// clear screen
|
|
33
32
|
process.stdout.write('\u001b[2J');
|
|
34
33
|
// set cursor position
|
|
@@ -42,3 +41,5 @@ function Min (runner) {
|
|
|
42
41
|
* Inherit from `Base.prototype`.
|
|
43
42
|
*/
|
|
44
43
|
inherits(Min, Base);
|
|
44
|
+
|
|
45
|
+
Min.description = 'essentially just a summary';
|
package/lib/reporters/nyan.js
CHANGED
|
@@ -19,19 +19,18 @@ exports = module.exports = NyanCat;
|
|
|
19
19
|
* Initialize a new `Dot` matrix test reporter.
|
|
20
20
|
*
|
|
21
21
|
* @param {Runner} runner
|
|
22
|
-
* @api public
|
|
23
22
|
* @public
|
|
24
23
|
* @class Nyan
|
|
25
24
|
* @memberof Mocha.reporters
|
|
26
25
|
* @extends Mocha.reporters.Base
|
|
27
26
|
*/
|
|
28
27
|
|
|
29
|
-
function NyanCat
|
|
28
|
+
function NyanCat(runner) {
|
|
30
29
|
Base.call(this, runner);
|
|
31
30
|
|
|
32
31
|
var self = this;
|
|
33
|
-
var width = Base.window.width * 0.75 | 0;
|
|
34
|
-
var nyanCatWidth = this.nyanCatWidth = 11;
|
|
32
|
+
var width = (Base.window.width * 0.75) | 0;
|
|
33
|
+
var nyanCatWidth = (this.nyanCatWidth = 11);
|
|
35
34
|
|
|
36
35
|
this.colorIndex = 0;
|
|
37
36
|
this.numberOfLines = 4;
|
|
@@ -39,26 +38,26 @@ function NyanCat (runner) {
|
|
|
39
38
|
this.scoreboardWidth = 5;
|
|
40
39
|
this.tick = 0;
|
|
41
40
|
this.trajectories = [[], [], [], []];
|
|
42
|
-
this.trajectoryWidthMax =
|
|
41
|
+
this.trajectoryWidthMax = width - nyanCatWidth;
|
|
43
42
|
|
|
44
|
-
runner.on('start', function
|
|
43
|
+
runner.on('start', function() {
|
|
45
44
|
Base.cursor.hide();
|
|
46
45
|
self.draw();
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
runner.on('pending', function
|
|
48
|
+
runner.on('pending', function() {
|
|
50
49
|
self.draw();
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
runner.on('pass', function
|
|
52
|
+
runner.on('pass', function() {
|
|
54
53
|
self.draw();
|
|
55
54
|
});
|
|
56
55
|
|
|
57
|
-
runner.on('fail', function
|
|
56
|
+
runner.on('fail', function() {
|
|
58
57
|
self.draw();
|
|
59
58
|
});
|
|
60
59
|
|
|
61
|
-
runner.once('end', function
|
|
60
|
+
runner.once('end', function() {
|
|
62
61
|
Base.cursor.show();
|
|
63
62
|
for (var i = 0; i < self.numberOfLines; i++) {
|
|
64
63
|
write('\n');
|
|
@@ -75,10 +74,10 @@ inherits(NyanCat, Base);
|
|
|
75
74
|
/**
|
|
76
75
|
* Draw the nyan cat
|
|
77
76
|
*
|
|
78
|
-
* @
|
|
77
|
+
* @private
|
|
79
78
|
*/
|
|
80
79
|
|
|
81
|
-
NyanCat.prototype.draw = function
|
|
80
|
+
NyanCat.prototype.draw = function() {
|
|
82
81
|
this.appendRainbow();
|
|
83
82
|
this.drawScoreboard();
|
|
84
83
|
this.drawRainbow();
|
|
@@ -90,13 +89,13 @@ NyanCat.prototype.draw = function () {
|
|
|
90
89
|
* Draw the "scoreboard" showing the number
|
|
91
90
|
* of passes, failures and pending tests.
|
|
92
91
|
*
|
|
93
|
-
* @
|
|
92
|
+
* @private
|
|
94
93
|
*/
|
|
95
94
|
|
|
96
|
-
NyanCat.prototype.drawScoreboard = function
|
|
95
|
+
NyanCat.prototype.drawScoreboard = function() {
|
|
97
96
|
var stats = this.stats;
|
|
98
97
|
|
|
99
|
-
function draw
|
|
98
|
+
function draw(type, n) {
|
|
100
99
|
write(' ');
|
|
101
100
|
write(Base.color(type, n));
|
|
102
101
|
write('\n');
|
|
@@ -113,10 +112,10 @@ NyanCat.prototype.drawScoreboard = function () {
|
|
|
113
112
|
/**
|
|
114
113
|
* Append the rainbow.
|
|
115
114
|
*
|
|
116
|
-
* @
|
|
115
|
+
* @private
|
|
117
116
|
*/
|
|
118
117
|
|
|
119
|
-
NyanCat.prototype.appendRainbow = function
|
|
118
|
+
NyanCat.prototype.appendRainbow = function() {
|
|
120
119
|
var segment = this.tick ? '_' : '-';
|
|
121
120
|
var rainbowified = this.rainbowify(segment);
|
|
122
121
|
|
|
@@ -132,13 +131,13 @@ NyanCat.prototype.appendRainbow = function () {
|
|
|
132
131
|
/**
|
|
133
132
|
* Draw the rainbow.
|
|
134
133
|
*
|
|
135
|
-
* @
|
|
134
|
+
* @private
|
|
136
135
|
*/
|
|
137
136
|
|
|
138
|
-
NyanCat.prototype.drawRainbow = function
|
|
137
|
+
NyanCat.prototype.drawRainbow = function() {
|
|
139
138
|
var self = this;
|
|
140
139
|
|
|
141
|
-
this.trajectories.forEach(function
|
|
140
|
+
this.trajectories.forEach(function(line) {
|
|
142
141
|
write('\u001b[' + self.scoreboardWidth + 'C');
|
|
143
142
|
write(line.join(''));
|
|
144
143
|
write('\n');
|
|
@@ -150,9 +149,9 @@ NyanCat.prototype.drawRainbow = function () {
|
|
|
150
149
|
/**
|
|
151
150
|
* Draw the nyan cat
|
|
152
151
|
*
|
|
153
|
-
* @
|
|
152
|
+
* @private
|
|
154
153
|
*/
|
|
155
|
-
NyanCat.prototype.drawNyanCat = function
|
|
154
|
+
NyanCat.prototype.drawNyanCat = function() {
|
|
156
155
|
var self = this;
|
|
157
156
|
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
158
157
|
var dist = '\u001b[' + startWidth + 'C';
|
|
@@ -184,11 +183,11 @@ NyanCat.prototype.drawNyanCat = function () {
|
|
|
184
183
|
/**
|
|
185
184
|
* Draw nyan cat face.
|
|
186
185
|
*
|
|
187
|
-
* @
|
|
186
|
+
* @private
|
|
188
187
|
* @return {string}
|
|
189
188
|
*/
|
|
190
189
|
|
|
191
|
-
NyanCat.prototype.face = function
|
|
190
|
+
NyanCat.prototype.face = function() {
|
|
192
191
|
var stats = this.stats;
|
|
193
192
|
if (stats.failures) {
|
|
194
193
|
return '( x .x)';
|
|
@@ -203,37 +202,37 @@ NyanCat.prototype.face = function () {
|
|
|
203
202
|
/**
|
|
204
203
|
* Move cursor up `n`.
|
|
205
204
|
*
|
|
206
|
-
* @
|
|
205
|
+
* @private
|
|
207
206
|
* @param {number} n
|
|
208
207
|
*/
|
|
209
208
|
|
|
210
|
-
NyanCat.prototype.cursorUp = function
|
|
209
|
+
NyanCat.prototype.cursorUp = function(n) {
|
|
211
210
|
write('\u001b[' + n + 'A');
|
|
212
211
|
};
|
|
213
212
|
|
|
214
213
|
/**
|
|
215
214
|
* Move cursor down `n`.
|
|
216
215
|
*
|
|
217
|
-
* @
|
|
216
|
+
* @private
|
|
218
217
|
* @param {number} n
|
|
219
218
|
*/
|
|
220
219
|
|
|
221
|
-
NyanCat.prototype.cursorDown = function
|
|
220
|
+
NyanCat.prototype.cursorDown = function(n) {
|
|
222
221
|
write('\u001b[' + n + 'B');
|
|
223
222
|
};
|
|
224
223
|
|
|
225
224
|
/**
|
|
226
225
|
* Generate rainbow colors.
|
|
227
226
|
*
|
|
228
|
-
* @
|
|
227
|
+
* @private
|
|
229
228
|
* @return {Array}
|
|
230
229
|
*/
|
|
231
|
-
NyanCat.prototype.generateColors = function
|
|
230
|
+
NyanCat.prototype.generateColors = function() {
|
|
232
231
|
var colors = [];
|
|
233
232
|
|
|
234
|
-
for (var i = 0; i <
|
|
233
|
+
for (var i = 0; i < 6 * 7; i++) {
|
|
235
234
|
var pi3 = Math.floor(Math.PI / 3);
|
|
236
|
-
var n =
|
|
235
|
+
var n = i * (1.0 / 6);
|
|
237
236
|
var r = Math.floor(3 * Math.sin(n) + 3);
|
|
238
237
|
var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
|
|
239
238
|
var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
|
|
@@ -246,11 +245,11 @@ NyanCat.prototype.generateColors = function () {
|
|
|
246
245
|
/**
|
|
247
246
|
* Apply rainbow to the given `str`.
|
|
248
247
|
*
|
|
249
|
-
* @
|
|
248
|
+
* @private
|
|
250
249
|
* @param {string} str
|
|
251
250
|
* @return {string}
|
|
252
251
|
*/
|
|
253
|
-
NyanCat.prototype.rainbowify = function
|
|
252
|
+
NyanCat.prototype.rainbowify = function(str) {
|
|
254
253
|
if (!Base.useColors) {
|
|
255
254
|
return str;
|
|
256
255
|
}
|
|
@@ -264,6 +263,8 @@ NyanCat.prototype.rainbowify = function (str) {
|
|
|
264
263
|
*
|
|
265
264
|
* @param {string} string A message to write to stdout.
|
|
266
265
|
*/
|
|
267
|
-
function write
|
|
266
|
+
function write(string) {
|
|
268
267
|
process.stdout.write(string);
|
|
269
268
|
}
|
|
269
|
+
|
|
270
|
+
NyanCat.description = '"nyan cat"';
|
|
@@ -30,15 +30,14 @@ Base.colors.progress = 90;
|
|
|
30
30
|
* @class
|
|
31
31
|
* @memberof Mocha.reporters
|
|
32
32
|
* @extends Mocha.reporters.Base
|
|
33
|
-
* @api public
|
|
34
33
|
* @param {Runner} runner
|
|
35
34
|
* @param {Object} options
|
|
36
35
|
*/
|
|
37
|
-
function Progress
|
|
36
|
+
function Progress(runner, options) {
|
|
38
37
|
Base.call(this, runner);
|
|
39
38
|
|
|
40
39
|
var self = this;
|
|
41
|
-
var width = Base.window.width * 0.
|
|
40
|
+
var width = (Base.window.width * 0.5) | 0;
|
|
42
41
|
var total = runner.total;
|
|
43
42
|
var complete = 0;
|
|
44
43
|
var lastN = -1;
|
|
@@ -54,17 +53,17 @@ function Progress (runner, options) {
|
|
|
54
53
|
options.verbose = reporterOptions.verbose || false;
|
|
55
54
|
|
|
56
55
|
// tests started
|
|
57
|
-
runner.on('start', function
|
|
56
|
+
runner.on('start', function() {
|
|
58
57
|
console.log();
|
|
59
58
|
cursor.hide();
|
|
60
59
|
});
|
|
61
60
|
|
|
62
61
|
// tests complete
|
|
63
|
-
runner.on('test end', function
|
|
62
|
+
runner.on('test end', function() {
|
|
64
63
|
complete++;
|
|
65
64
|
|
|
66
65
|
var percent = complete / total;
|
|
67
|
-
var n = width * percent | 0;
|
|
66
|
+
var n = (width * percent) | 0;
|
|
68
67
|
var i = width - n;
|
|
69
68
|
|
|
70
69
|
if (n === lastN && !options.verbose) {
|
|
@@ -86,7 +85,7 @@ function Progress (runner, options) {
|
|
|
86
85
|
|
|
87
86
|
// tests are complete, output some stats
|
|
88
87
|
// and the failures if any
|
|
89
|
-
runner.once('end', function
|
|
88
|
+
runner.once('end', function() {
|
|
90
89
|
cursor.show();
|
|
91
90
|
console.log();
|
|
92
91
|
self.epilogue();
|
|
@@ -97,3 +96,5 @@ function Progress (runner, options) {
|
|
|
97
96
|
* Inherit from `Base.prototype`.
|
|
98
97
|
*/
|
|
99
98
|
inherits(Progress, Base);
|
|
99
|
+
|
|
100
|
+
Progress.description = 'a progress bar';
|
package/lib/reporters/spec.js
CHANGED
|
@@ -23,50 +23,51 @@ exports = module.exports = Spec;
|
|
|
23
23
|
* @class
|
|
24
24
|
* @memberof Mocha.reporters
|
|
25
25
|
* @extends Mocha.reporters.Base
|
|
26
|
-
* @api public
|
|
27
26
|
* @param {Runner} runner
|
|
28
27
|
*/
|
|
29
|
-
function Spec
|
|
28
|
+
function Spec(runner) {
|
|
30
29
|
Base.call(this, runner);
|
|
31
30
|
|
|
32
31
|
var self = this;
|
|
33
32
|
var indents = 0;
|
|
34
33
|
var n = 0;
|
|
35
34
|
|
|
36
|
-
function indent
|
|
35
|
+
function indent() {
|
|
37
36
|
return Array(indents).join(' ');
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
runner.on('start', function
|
|
39
|
+
runner.on('start', function() {
|
|
41
40
|
console.log();
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
runner.on('suite', function
|
|
43
|
+
runner.on('suite', function(suite) {
|
|
45
44
|
++indents;
|
|
46
45
|
console.log(color('suite', '%s%s'), indent(), suite.title);
|
|
47
46
|
});
|
|
48
47
|
|
|
49
|
-
runner.on('suite end', function
|
|
48
|
+
runner.on('suite end', function() {
|
|
50
49
|
--indents;
|
|
51
50
|
if (indents === 1) {
|
|
52
51
|
console.log();
|
|
53
52
|
}
|
|
54
53
|
});
|
|
55
54
|
|
|
56
|
-
runner.on('pending', function
|
|
55
|
+
runner.on('pending', function(test) {
|
|
57
56
|
var fmt = indent() + color('pending', ' - %s');
|
|
58
57
|
console.log(fmt, test.title);
|
|
59
58
|
});
|
|
60
59
|
|
|
61
|
-
runner.on('pass', function
|
|
60
|
+
runner.on('pass', function(test) {
|
|
62
61
|
var fmt;
|
|
63
62
|
if (test.speed === 'fast') {
|
|
64
|
-
fmt =
|
|
63
|
+
fmt =
|
|
64
|
+
indent() +
|
|
65
65
|
color('checkmark', ' ' + Base.symbols.ok) +
|
|
66
66
|
color('pass', ' %s');
|
|
67
67
|
console.log(fmt, test.title);
|
|
68
68
|
} else {
|
|
69
|
-
fmt =
|
|
69
|
+
fmt =
|
|
70
|
+
indent() +
|
|
70
71
|
color('checkmark', ' ' + Base.symbols.ok) +
|
|
71
72
|
color('pass', ' %s') +
|
|
72
73
|
color(test.speed, ' (%dms)');
|
|
@@ -74,7 +75,7 @@ function Spec (runner) {
|
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
|
|
77
|
-
runner.on('fail', function
|
|
78
|
+
runner.on('fail', function(test) {
|
|
78
79
|
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
|
79
80
|
});
|
|
80
81
|
|
|
@@ -85,3 +86,5 @@ function Spec (runner) {
|
|
|
85
86
|
* Inherit from `Base.prototype`.
|
|
86
87
|
*/
|
|
87
88
|
inherits(Spec, Base);
|
|
89
|
+
|
|
90
|
+
Spec.description = 'hierarchical & verbose [default]';
|