mocha 9.1.2 → 9.2.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/LICENSE +1 -1
- package/README.md +1 -1
- package/browser-entry.js +26 -16
- package/lib/browser/growl.js +5 -5
- package/lib/browser/parse-query.js +1 -1
- package/lib/browser/progress.js +6 -6
- package/lib/cli/config.js +7 -12
- package/lib/cli/run.js +1 -1
- package/lib/cli/watch-run.js +1 -4
- package/lib/context.js +5 -5
- package/lib/errors.js +1 -1
- package/lib/hook.js +2 -2
- package/lib/interfaces/bdd.js +23 -20
- package/lib/interfaces/common.js +7 -7
- package/lib/interfaces/exports.js +1 -1
- package/lib/interfaces/qunit.js +7 -7
- package/lib/interfaces/tdd.js +9 -9
- package/lib/mocha.js +56 -58
- package/lib/nodejs/buffered-worker-pool.js +17 -1
- package/lib/nodejs/esm-utils.js +18 -3
- package/lib/reporters/base.js +41 -28
- package/lib/reporters/doc.js +4 -4
- package/lib/reporters/dot.js +5 -5
- package/lib/reporters/html.js +12 -12
- package/lib/reporters/json-stream.js +4 -4
- package/lib/reporters/json.js +7 -7
- package/lib/reporters/landing.js +5 -5
- package/lib/reporters/list.js +5 -5
- package/lib/reporters/markdown.js +5 -5
- package/lib/reporters/min.js +1 -1
- package/lib/reporters/nyan.js +16 -16
- package/lib/reporters/progress.js +3 -3
- package/lib/reporters/spec.js +6 -6
- package/lib/reporters/tap.js +17 -17
- package/lib/reporters/xunit.js +9 -9
- package/lib/runnable.js +21 -21
- package/lib/runner.js +44 -47
- package/lib/stats-collector.js +7 -7
- package/lib/suite.js +44 -73
- package/lib/test.js +4 -4
- package/lib/utils.js +18 -19
- package/mocha-es2018.js +432 -449
- package/mocha.js +1246 -851
- package/mocha.js.map +1 -1
- package/package.json +38 -38
- package/CHANGELOG.md +0 -1015
package/lib/reporters/dot.js
CHANGED
|
@@ -38,18 +38,18 @@ function Dot(runner, options) {
|
|
|
38
38
|
var width = (Base.window.width * 0.75) | 0;
|
|
39
39
|
var n = -1;
|
|
40
40
|
|
|
41
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
41
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
42
42
|
process.stdout.write('\n');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
runner.on(EVENT_TEST_PENDING, function() {
|
|
45
|
+
runner.on(EVENT_TEST_PENDING, function () {
|
|
46
46
|
if (++n % width === 0) {
|
|
47
47
|
process.stdout.write('\n ');
|
|
48
48
|
}
|
|
49
49
|
process.stdout.write(Base.color('pending', Base.symbols.comma));
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
52
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
53
53
|
if (++n % width === 0) {
|
|
54
54
|
process.stdout.write('\n ');
|
|
55
55
|
}
|
|
@@ -60,14 +60,14 @@ function Dot(runner, options) {
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
runner.on(EVENT_TEST_FAIL, function() {
|
|
63
|
+
runner.on(EVENT_TEST_FAIL, function () {
|
|
64
64
|
if (++n % width === 0) {
|
|
65
65
|
process.stdout.write('\n ');
|
|
66
66
|
}
|
|
67
67
|
process.stdout.write(Base.color('fail', Base.symbols.bang));
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
runner.once(EVENT_RUN_END, function() {
|
|
70
|
+
runner.once(EVENT_RUN_END, function () {
|
|
71
71
|
process.stdout.write('\n');
|
|
72
72
|
self.epilogue();
|
|
73
73
|
});
|
package/lib/reporters/html.js
CHANGED
|
@@ -91,7 +91,7 @@ function HTML(runner, options) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// pass toggle
|
|
94
|
-
on(passesLink, 'click', function(evt) {
|
|
94
|
+
on(passesLink, 'click', function (evt) {
|
|
95
95
|
evt.preventDefault();
|
|
96
96
|
unhide();
|
|
97
97
|
var name = /pass/.test(report.className) ? '' : ' pass';
|
|
@@ -102,7 +102,7 @@ function HTML(runner, options) {
|
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
// failure toggle
|
|
105
|
-
on(failuresLink, 'click', function(evt) {
|
|
105
|
+
on(failuresLink, 'click', function (evt) {
|
|
106
106
|
evt.preventDefault();
|
|
107
107
|
unhide();
|
|
108
108
|
var name = /fail/.test(report.className) ? '' : ' fail';
|
|
@@ -119,7 +119,7 @@ function HTML(runner, options) {
|
|
|
119
119
|
progress.size(40);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
122
|
+
runner.on(EVENT_SUITE_BEGIN, function (suite) {
|
|
123
123
|
if (suite.root) {
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
@@ -138,7 +138,7 @@ function HTML(runner, options) {
|
|
|
138
138
|
el.appendChild(stack[0]);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
runner.on(EVENT_SUITE_END, function(suite) {
|
|
141
|
+
runner.on(EVENT_SUITE_END, function (suite) {
|
|
142
142
|
if (suite.root) {
|
|
143
143
|
updateStats();
|
|
144
144
|
return;
|
|
@@ -146,7 +146,7 @@ function HTML(runner, options) {
|
|
|
146
146
|
stack.shift();
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
149
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
150
150
|
var url = self.testURL(test);
|
|
151
151
|
var markup =
|
|
152
152
|
'<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
|
|
@@ -159,7 +159,7 @@ function HTML(runner, options) {
|
|
|
159
159
|
updateStats();
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
162
|
+
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
163
163
|
var el = fragment(
|
|
164
164
|
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
|
|
165
165
|
playIcon +
|
|
@@ -215,7 +215,7 @@ function HTML(runner, options) {
|
|
|
215
215
|
updateStats();
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
218
|
+
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
219
219
|
var el = fragment(
|
|
220
220
|
'<li class="test pass pending"><h2>%e</h2></li>',
|
|
221
221
|
test.title
|
|
@@ -273,7 +273,7 @@ function makeUrl(s) {
|
|
|
273
273
|
*
|
|
274
274
|
* @param {Object} [suite]
|
|
275
275
|
*/
|
|
276
|
-
HTML.prototype.suiteURL = function(suite) {
|
|
276
|
+
HTML.prototype.suiteURL = function (suite) {
|
|
277
277
|
return makeUrl(suite.fullTitle());
|
|
278
278
|
};
|
|
279
279
|
|
|
@@ -282,7 +282,7 @@ HTML.prototype.suiteURL = function(suite) {
|
|
|
282
282
|
*
|
|
283
283
|
* @param {Object} [test]
|
|
284
284
|
*/
|
|
285
|
-
HTML.prototype.testURL = function(test) {
|
|
285
|
+
HTML.prototype.testURL = function (test) {
|
|
286
286
|
return makeUrl(test.fullTitle());
|
|
287
287
|
};
|
|
288
288
|
|
|
@@ -292,10 +292,10 @@ HTML.prototype.testURL = function(test) {
|
|
|
292
292
|
* @param {HTMLLIElement} el
|
|
293
293
|
* @param {string} contents
|
|
294
294
|
*/
|
|
295
|
-
HTML.prototype.addCodeToggle = function(el, contents) {
|
|
295
|
+
HTML.prototype.addCodeToggle = function (el, contents) {
|
|
296
296
|
var h2 = el.getElementsByTagName('h2')[0];
|
|
297
297
|
|
|
298
|
-
on(h2, 'click', function() {
|
|
298
|
+
on(h2, 'click', function () {
|
|
299
299
|
pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
|
|
300
300
|
});
|
|
301
301
|
|
|
@@ -323,7 +323,7 @@ function fragment(html) {
|
|
|
323
323
|
var div = document.createElement('div');
|
|
324
324
|
var i = 1;
|
|
325
325
|
|
|
326
|
-
div.innerHTML = html.replace(/%([se])/g, function(_, type) {
|
|
326
|
+
div.innerHTML = html.replace(/%([se])/g, function (_, type) {
|
|
327
327
|
switch (type) {
|
|
328
328
|
case 's':
|
|
329
329
|
return String(args[i++]);
|
|
@@ -35,22 +35,22 @@ function JSONStream(runner, options) {
|
|
|
35
35
|
var self = this;
|
|
36
36
|
var total = runner.total;
|
|
37
37
|
|
|
38
|
-
runner.once(EVENT_RUN_BEGIN, function() {
|
|
38
|
+
runner.once(EVENT_RUN_BEGIN, function () {
|
|
39
39
|
writeEvent(['start', {total: total}]);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
42
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
43
43
|
writeEvent(['pass', clean(test)]);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
runner.on(EVENT_TEST_FAIL, function(test, err) {
|
|
46
|
+
runner.on(EVENT_TEST_FAIL, function (test, err) {
|
|
47
47
|
test = clean(test);
|
|
48
48
|
test.err = err.message;
|
|
49
49
|
test.stack = err.stack || null;
|
|
50
50
|
writeEvent(['fail', test]);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
runner.once(EVENT_RUN_END, function() {
|
|
53
|
+
runner.once(EVENT_RUN_END, function () {
|
|
54
54
|
writeEvent(['end', self.stats]);
|
|
55
55
|
});
|
|
56
56
|
}
|
package/lib/reporters/json.js
CHANGED
|
@@ -51,23 +51,23 @@ function JSONReporter(runner, options = {}) {
|
|
|
51
51
|
output = options.reporterOption.output;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
runner.on(EVENT_TEST_END, function(test) {
|
|
54
|
+
runner.on(EVENT_TEST_END, function (test) {
|
|
55
55
|
tests.push(test);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
58
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
59
59
|
passes.push(test);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
62
|
+
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
63
63
|
failures.push(test);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
66
|
+
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
67
67
|
pending.push(test);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
runner.once(EVENT_RUN_END, function() {
|
|
70
|
+
runner.once(EVENT_RUN_END, function () {
|
|
71
71
|
var obj = {
|
|
72
72
|
stats: self.stats,
|
|
73
73
|
tests: tests.map(clean),
|
|
@@ -130,7 +130,7 @@ function clean(test) {
|
|
|
130
130
|
function cleanCycles(obj) {
|
|
131
131
|
var cache = [];
|
|
132
132
|
return JSON.parse(
|
|
133
|
-
JSON.stringify(obj, function(key, value) {
|
|
133
|
+
JSON.stringify(obj, function (key, value) {
|
|
134
134
|
if (typeof value === 'object' && value !== null) {
|
|
135
135
|
if (cache.indexOf(value) !== -1) {
|
|
136
136
|
// Instead of going in a circle, we'll print [object Object]
|
|
@@ -153,7 +153,7 @@ function cleanCycles(obj) {
|
|
|
153
153
|
*/
|
|
154
154
|
function errorJSON(err) {
|
|
155
155
|
var res = {};
|
|
156
|
-
Object.getOwnPropertyNames(err).forEach(function(key) {
|
|
156
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
157
157
|
res[key] = err[key];
|
|
158
158
|
}, err);
|
|
159
159
|
return res;
|
package/lib/reporters/landing.js
CHANGED
|
@@ -68,12 +68,12 @@ function Landing(runner, options) {
|
|
|
68
68
|
return ' ' + color('runway', buf);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
71
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
72
72
|
stream.write('\n\n\n ');
|
|
73
73
|
cursor.hide();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
runner.on(EVENT_TEST_END, function(test) {
|
|
76
|
+
runner.on(EVENT_TEST_END, function (test) {
|
|
77
77
|
// check if the plane crashed
|
|
78
78
|
var col = crashed === -1 ? ((width * ++n) / ++total) | 0 : crashed;
|
|
79
79
|
// show the crash
|
|
@@ -93,16 +93,16 @@ function Landing(runner, options) {
|
|
|
93
93
|
stream.write('\u001b[0m');
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
runner.once(EVENT_RUN_END, function() {
|
|
96
|
+
runner.once(EVENT_RUN_END, function () {
|
|
97
97
|
cursor.show();
|
|
98
98
|
process.stdout.write('\n');
|
|
99
99
|
self.epilogue();
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
// if cursor is hidden when we ctrl-C, then it will remain hidden unless...
|
|
103
|
-
process.once('SIGINT', function() {
|
|
103
|
+
process.once('SIGINT', function () {
|
|
104
104
|
cursor.show();
|
|
105
|
-
process.nextTick(function() {
|
|
105
|
+
process.nextTick(function () {
|
|
106
106
|
process.kill(process.pid, 'SIGINT');
|
|
107
107
|
});
|
|
108
108
|
});
|
package/lib/reporters/list.js
CHANGED
|
@@ -40,20 +40,20 @@ function List(runner, options) {
|
|
|
40
40
|
var self = this;
|
|
41
41
|
var n = 0;
|
|
42
42
|
|
|
43
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
43
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
44
44
|
Base.consoleLog();
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
runner.on(EVENT_TEST_BEGIN, function(test) {
|
|
47
|
+
runner.on(EVENT_TEST_BEGIN, function (test) {
|
|
48
48
|
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
51
|
+
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
52
52
|
var fmt = color('checkmark', ' -') + color('pending', ' %s');
|
|
53
53
|
Base.consoleLog(fmt, test.fullTitle());
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
56
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
57
57
|
var fmt =
|
|
58
58
|
color('checkmark', ' ' + Base.symbols.ok) +
|
|
59
59
|
color('pass', ' %s: ') +
|
|
@@ -62,7 +62,7 @@ function List(runner, options) {
|
|
|
62
62
|
Base.consoleLog(fmt, test.fullTitle(), test.duration);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
65
|
+
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
66
66
|
cursor.CR();
|
|
67
67
|
Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle());
|
|
68
68
|
});
|
|
@@ -51,7 +51,7 @@ function Markdown(runner, options) {
|
|
|
51
51
|
var key = SUITE_PREFIX + suite.title;
|
|
52
52
|
|
|
53
53
|
obj = obj[key] = obj[key] || {suite: suite};
|
|
54
|
-
suite.suites.forEach(function(suite) {
|
|
54
|
+
suite.suites.forEach(function (suite) {
|
|
55
55
|
mapTOC(suite, obj);
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -83,18 +83,18 @@ function Markdown(runner, options) {
|
|
|
83
83
|
|
|
84
84
|
generateTOC(runner.suite);
|
|
85
85
|
|
|
86
|
-
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
86
|
+
runner.on(EVENT_SUITE_BEGIN, function (suite) {
|
|
87
87
|
++level;
|
|
88
88
|
var slug = utils.slug(suite.fullTitle());
|
|
89
89
|
buf += '<a name="' + slug + '"></a>' + '\n';
|
|
90
90
|
buf += title(suite.title) + '\n';
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
runner.on(EVENT_SUITE_END, function() {
|
|
93
|
+
runner.on(EVENT_SUITE_END, function () {
|
|
94
94
|
--level;
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
97
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
98
98
|
var code = utils.clean(test.body);
|
|
99
99
|
buf += test.title + '.\n';
|
|
100
100
|
buf += '\n```js\n';
|
|
@@ -102,7 +102,7 @@ function Markdown(runner, options) {
|
|
|
102
102
|
buf += '```\n\n';
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
runner.once(EVENT_RUN_END, function() {
|
|
105
|
+
runner.once(EVENT_RUN_END, function () {
|
|
106
106
|
process.stdout.write('# TOC\n');
|
|
107
107
|
process.stdout.write(generateTOC(runner.suite));
|
|
108
108
|
process.stdout.write(buf);
|
package/lib/reporters/min.js
CHANGED
|
@@ -34,7 +34,7 @@ exports = module.exports = Min;
|
|
|
34
34
|
function Min(runner, options) {
|
|
35
35
|
Base.call(this, runner, options);
|
|
36
36
|
|
|
37
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
37
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
38
38
|
// clear screen
|
|
39
39
|
process.stdout.write('\u001b[2J');
|
|
40
40
|
// set cursor position
|
package/lib/reporters/nyan.js
CHANGED
|
@@ -46,24 +46,24 @@ function NyanCat(runner, options) {
|
|
|
46
46
|
this.trajectories = [[], [], [], []];
|
|
47
47
|
this.trajectoryWidthMax = width - nyanCatWidth;
|
|
48
48
|
|
|
49
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
49
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
50
50
|
Base.cursor.hide();
|
|
51
51
|
self.draw();
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
runner.on(EVENT_TEST_PENDING, function() {
|
|
54
|
+
runner.on(EVENT_TEST_PENDING, function () {
|
|
55
55
|
self.draw();
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
runner.on(EVENT_TEST_PASS, function() {
|
|
58
|
+
runner.on(EVENT_TEST_PASS, function () {
|
|
59
59
|
self.draw();
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
runner.on(EVENT_TEST_FAIL, function() {
|
|
62
|
+
runner.on(EVENT_TEST_FAIL, function () {
|
|
63
63
|
self.draw();
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
runner.once(EVENT_RUN_END, function() {
|
|
66
|
+
runner.once(EVENT_RUN_END, function () {
|
|
67
67
|
Base.cursor.show();
|
|
68
68
|
for (var i = 0; i < self.numberOfLines; i++) {
|
|
69
69
|
write('\n');
|
|
@@ -83,7 +83,7 @@ inherits(NyanCat, Base);
|
|
|
83
83
|
* @private
|
|
84
84
|
*/
|
|
85
85
|
|
|
86
|
-
NyanCat.prototype.draw = function() {
|
|
86
|
+
NyanCat.prototype.draw = function () {
|
|
87
87
|
this.appendRainbow();
|
|
88
88
|
this.drawScoreboard();
|
|
89
89
|
this.drawRainbow();
|
|
@@ -98,7 +98,7 @@ NyanCat.prototype.draw = function() {
|
|
|
98
98
|
* @private
|
|
99
99
|
*/
|
|
100
100
|
|
|
101
|
-
NyanCat.prototype.drawScoreboard = function() {
|
|
101
|
+
NyanCat.prototype.drawScoreboard = function () {
|
|
102
102
|
var stats = this.stats;
|
|
103
103
|
|
|
104
104
|
function draw(type, n) {
|
|
@@ -121,7 +121,7 @@ NyanCat.prototype.drawScoreboard = function() {
|
|
|
121
121
|
* @private
|
|
122
122
|
*/
|
|
123
123
|
|
|
124
|
-
NyanCat.prototype.appendRainbow = function() {
|
|
124
|
+
NyanCat.prototype.appendRainbow = function () {
|
|
125
125
|
var segment = this.tick ? '_' : '-';
|
|
126
126
|
var rainbowified = this.rainbowify(segment);
|
|
127
127
|
|
|
@@ -140,10 +140,10 @@ NyanCat.prototype.appendRainbow = function() {
|
|
|
140
140
|
* @private
|
|
141
141
|
*/
|
|
142
142
|
|
|
143
|
-
NyanCat.prototype.drawRainbow = function() {
|
|
143
|
+
NyanCat.prototype.drawRainbow = function () {
|
|
144
144
|
var self = this;
|
|
145
145
|
|
|
146
|
-
this.trajectories.forEach(function(line) {
|
|
146
|
+
this.trajectories.forEach(function (line) {
|
|
147
147
|
write('\u001b[' + self.scoreboardWidth + 'C');
|
|
148
148
|
write(line.join(''));
|
|
149
149
|
write('\n');
|
|
@@ -157,7 +157,7 @@ NyanCat.prototype.drawRainbow = function() {
|
|
|
157
157
|
*
|
|
158
158
|
* @private
|
|
159
159
|
*/
|
|
160
|
-
NyanCat.prototype.drawNyanCat = function() {
|
|
160
|
+
NyanCat.prototype.drawNyanCat = function () {
|
|
161
161
|
var self = this;
|
|
162
162
|
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
163
163
|
var dist = '\u001b[' + startWidth + 'C';
|
|
@@ -193,7 +193,7 @@ NyanCat.prototype.drawNyanCat = function() {
|
|
|
193
193
|
* @return {string}
|
|
194
194
|
*/
|
|
195
195
|
|
|
196
|
-
NyanCat.prototype.face = function() {
|
|
196
|
+
NyanCat.prototype.face = function () {
|
|
197
197
|
var stats = this.stats;
|
|
198
198
|
if (stats.failures) {
|
|
199
199
|
return '( x .x)';
|
|
@@ -212,7 +212,7 @@ NyanCat.prototype.face = function() {
|
|
|
212
212
|
* @param {number} n
|
|
213
213
|
*/
|
|
214
214
|
|
|
215
|
-
NyanCat.prototype.cursorUp = function(n) {
|
|
215
|
+
NyanCat.prototype.cursorUp = function (n) {
|
|
216
216
|
write('\u001b[' + n + 'A');
|
|
217
217
|
};
|
|
218
218
|
|
|
@@ -223,7 +223,7 @@ NyanCat.prototype.cursorUp = function(n) {
|
|
|
223
223
|
* @param {number} n
|
|
224
224
|
*/
|
|
225
225
|
|
|
226
|
-
NyanCat.prototype.cursorDown = function(n) {
|
|
226
|
+
NyanCat.prototype.cursorDown = function (n) {
|
|
227
227
|
write('\u001b[' + n + 'B');
|
|
228
228
|
};
|
|
229
229
|
|
|
@@ -233,7 +233,7 @@ NyanCat.prototype.cursorDown = function(n) {
|
|
|
233
233
|
* @private
|
|
234
234
|
* @return {Array}
|
|
235
235
|
*/
|
|
236
|
-
NyanCat.prototype.generateColors = function() {
|
|
236
|
+
NyanCat.prototype.generateColors = function () {
|
|
237
237
|
var colors = [];
|
|
238
238
|
|
|
239
239
|
for (var i = 0; i < 6 * 7; i++) {
|
|
@@ -255,7 +255,7 @@ NyanCat.prototype.generateColors = function() {
|
|
|
255
255
|
* @param {string} str
|
|
256
256
|
* @return {string}
|
|
257
257
|
*/
|
|
258
|
-
NyanCat.prototype.rainbowify = function(str) {
|
|
258
|
+
NyanCat.prototype.rainbowify = function (str) {
|
|
259
259
|
if (!Base.useColors) {
|
|
260
260
|
return str;
|
|
261
261
|
}
|
|
@@ -57,13 +57,13 @@ function Progress(runner, options) {
|
|
|
57
57
|
options.verbose = reporterOptions.verbose || false;
|
|
58
58
|
|
|
59
59
|
// tests started
|
|
60
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
60
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
61
61
|
process.stdout.write('\n');
|
|
62
62
|
cursor.hide();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
// tests complete
|
|
66
|
-
runner.on(EVENT_TEST_END, function() {
|
|
66
|
+
runner.on(EVENT_TEST_END, function () {
|
|
67
67
|
complete++;
|
|
68
68
|
|
|
69
69
|
var percent = complete / total;
|
|
@@ -89,7 +89,7 @@ function Progress(runner, options) {
|
|
|
89
89
|
|
|
90
90
|
// tests are complete, output some stats
|
|
91
91
|
// and the failures if any
|
|
92
|
-
runner.once(EVENT_RUN_END, function() {
|
|
92
|
+
runner.once(EVENT_RUN_END, function () {
|
|
93
93
|
cursor.show();
|
|
94
94
|
process.stdout.write('\n');
|
|
95
95
|
self.epilogue();
|
package/lib/reporters/spec.js
CHANGED
|
@@ -45,28 +45,28 @@ function Spec(runner, options) {
|
|
|
45
45
|
return Array(indents).join(' ');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
runner.on(EVENT_RUN_BEGIN, function() {
|
|
48
|
+
runner.on(EVENT_RUN_BEGIN, function () {
|
|
49
49
|
Base.consoleLog();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
runner.on(EVENT_SUITE_BEGIN, function(suite) {
|
|
52
|
+
runner.on(EVENT_SUITE_BEGIN, function (suite) {
|
|
53
53
|
++indents;
|
|
54
54
|
Base.consoleLog(color('suite', '%s%s'), indent(), suite.title);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
runner.on(EVENT_SUITE_END, function() {
|
|
57
|
+
runner.on(EVENT_SUITE_END, function () {
|
|
58
58
|
--indents;
|
|
59
59
|
if (indents === 1) {
|
|
60
60
|
Base.consoleLog();
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
64
|
+
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
65
65
|
var fmt = indent() + color('pending', ' - %s');
|
|
66
66
|
Base.consoleLog(fmt, test.title);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
69
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
70
70
|
var fmt;
|
|
71
71
|
if (test.speed === 'fast') {
|
|
72
72
|
fmt =
|
|
@@ -84,7 +84,7 @@ function Spec(runner, options) {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
runner.on(EVENT_TEST_FAIL, function(test) {
|
|
87
|
+
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
88
88
|
Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title);
|
|
89
89
|
});
|
|
90
90
|
|
package/lib/reporters/tap.js
CHANGED
|
@@ -49,27 +49,27 @@ function TAP(runner, options) {
|
|
|
49
49
|
|
|
50
50
|
this._producer = createProducer(tapVersion);
|
|
51
51
|
|
|
52
|
-
runner.once(EVENT_RUN_BEGIN, function() {
|
|
52
|
+
runner.once(EVENT_RUN_BEGIN, function () {
|
|
53
53
|
self._producer.writeVersion();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
runner.on(EVENT_TEST_END, function() {
|
|
56
|
+
runner.on(EVENT_TEST_END, function () {
|
|
57
57
|
++n;
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
runner.on(EVENT_TEST_PENDING, function(test) {
|
|
60
|
+
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
61
61
|
self._producer.writePending(n, test);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
runner.on(EVENT_TEST_PASS, function(test) {
|
|
64
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
65
65
|
self._producer.writePass(n, test);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
runner.on(EVENT_TEST_FAIL, function(test, err) {
|
|
68
|
+
runner.on(EVENT_TEST_FAIL, function (test, err) {
|
|
69
69
|
self._producer.writeFail(n, test, err);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
runner.once(EVENT_RUN_END, function() {
|
|
72
|
+
runner.once(EVENT_RUN_END, function () {
|
|
73
73
|
self._producer.writeEpilogue(runner.stats);
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -113,8 +113,8 @@ function println(format, varArgs) {
|
|
|
113
113
|
*/
|
|
114
114
|
function createProducer(tapVersion) {
|
|
115
115
|
var producers = {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
12: new TAP12Producer(),
|
|
117
|
+
13: new TAP13Producer()
|
|
118
118
|
};
|
|
119
119
|
var producer = producers[tapVersion];
|
|
120
120
|
|
|
@@ -144,7 +144,7 @@ function TAPProducer() {}
|
|
|
144
144
|
*
|
|
145
145
|
* @abstract
|
|
146
146
|
*/
|
|
147
|
-
TAPProducer.prototype.writeVersion = function() {};
|
|
147
|
+
TAPProducer.prototype.writeVersion = function () {};
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Writes the plan to reporter output stream.
|
|
@@ -152,7 +152,7 @@ TAPProducer.prototype.writeVersion = function() {};
|
|
|
152
152
|
* @abstract
|
|
153
153
|
* @param {number} ntests - Number of tests that are planned to run.
|
|
154
154
|
*/
|
|
155
|
-
TAPProducer.prototype.writePlan = function(ntests) {
|
|
155
|
+
TAPProducer.prototype.writePlan = function (ntests) {
|
|
156
156
|
println('%d..%d', 1, ntests);
|
|
157
157
|
};
|
|
158
158
|
|
|
@@ -163,7 +163,7 @@ TAPProducer.prototype.writePlan = function(ntests) {
|
|
|
163
163
|
* @param {number} n - Index of test that passed.
|
|
164
164
|
* @param {Test} test - Instance containing test information.
|
|
165
165
|
*/
|
|
166
|
-
TAPProducer.prototype.writePass = function(n, test) {
|
|
166
|
+
TAPProducer.prototype.writePass = function (n, test) {
|
|
167
167
|
println('ok %d %s', n, title(test));
|
|
168
168
|
};
|
|
169
169
|
|
|
@@ -174,7 +174,7 @@ TAPProducer.prototype.writePass = function(n, test) {
|
|
|
174
174
|
* @param {number} n - Index of test that was skipped.
|
|
175
175
|
* @param {Test} test - Instance containing test information.
|
|
176
176
|
*/
|
|
177
|
-
TAPProducer.prototype.writePending = function(n, test) {
|
|
177
|
+
TAPProducer.prototype.writePending = function (n, test) {
|
|
178
178
|
println('ok %d %s # SKIP -', n, title(test));
|
|
179
179
|
};
|
|
180
180
|
|
|
@@ -186,7 +186,7 @@ TAPProducer.prototype.writePending = function(n, test) {
|
|
|
186
186
|
* @param {Test} test - Instance containing test information.
|
|
187
187
|
* @param {Error} err - Reason the test failed.
|
|
188
188
|
*/
|
|
189
|
-
TAPProducer.prototype.writeFail = function(n, test, err) {
|
|
189
|
+
TAPProducer.prototype.writeFail = function (n, test, err) {
|
|
190
190
|
println('not ok %d %s', n, title(test));
|
|
191
191
|
};
|
|
192
192
|
|
|
@@ -196,7 +196,7 @@ TAPProducer.prototype.writeFail = function(n, test, err) {
|
|
|
196
196
|
* @abstract
|
|
197
197
|
* @param {Object} stats - Object containing run statistics.
|
|
198
198
|
*/
|
|
199
|
-
TAPProducer.prototype.writeEpilogue = function(stats) {
|
|
199
|
+
TAPProducer.prototype.writeEpilogue = function (stats) {
|
|
200
200
|
// :TBD: Why is this not counting pending tests?
|
|
201
201
|
println('# tests ' + (stats.passes + stats.failures));
|
|
202
202
|
println('# pass ' + stats.passes);
|
|
@@ -222,7 +222,7 @@ function TAP12Producer() {
|
|
|
222
222
|
* Writes that test failed to reporter output stream, with error formatting.
|
|
223
223
|
* @override
|
|
224
224
|
*/
|
|
225
|
-
this.writeFail = function(n, test, err) {
|
|
225
|
+
this.writeFail = function (n, test, err) {
|
|
226
226
|
TAPProducer.prototype.writeFail.call(this, n, test, err);
|
|
227
227
|
if (err.message) {
|
|
228
228
|
println(err.message.replace(/^/gm, ' '));
|
|
@@ -255,7 +255,7 @@ function TAP13Producer() {
|
|
|
255
255
|
* Writes the TAP version to reporter output stream.
|
|
256
256
|
* @override
|
|
257
257
|
*/
|
|
258
|
-
this.writeVersion = function() {
|
|
258
|
+
this.writeVersion = function () {
|
|
259
259
|
println('TAP version 13');
|
|
260
260
|
};
|
|
261
261
|
|
|
@@ -263,7 +263,7 @@ function TAP13Producer() {
|
|
|
263
263
|
* Writes that test failed to reporter output stream, with error formatting.
|
|
264
264
|
* @override
|
|
265
265
|
*/
|
|
266
|
-
this.writeFail = function(n, test, err) {
|
|
266
|
+
this.writeFail = function (n, test, err) {
|
|
267
267
|
TAPProducer.prototype.writeFail.call(this, n, test, err);
|
|
268
268
|
var emitYamlBlock = err.message != null || err.stack != null;
|
|
269
269
|
if (emitYamlBlock) {
|