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