mocha 5.1.1 → 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 +32 -0
- package/bin/_mocha +82 -36
- 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 +7 -7
- package/lib/hook.js +5 -16
- package/lib/interfaces/bdd.js +12 -13
- package/lib/interfaces/common.js +18 -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 +56 -57
- package/lib/ms.js +7 -5
- package/lib/pending.js +1 -5
- package/lib/reporters/base.js +91 -63
- package/lib/reporters/doc.js +16 -8
- package/lib/reporters/dot.js +7 -7
- package/lib/reporters/html.js +74 -40
- package/lib/reporters/json-stream.js +7 -7
- package/lib/reporters/json.js +21 -19
- package/lib/reporters/landing.js +7 -7
- package/lib/reporters/list.js +9 -9
- package/lib/reporters/markdown.js +11 -11
- package/lib/reporters/min.js +2 -2
- package/lib/reporters/nyan.js +24 -24
- package/lib/reporters/progress.js +6 -6
- package/lib/reporters/spec.js +12 -10
- package/lib/reporters/tap.js +8 -8
- package/lib/reporters/xunit.js +41 -23
- package/lib/runnable.js +64 -62
- package/lib/runner.js +99 -78
- package/lib/suite.js +39 -33
- package/lib/test.js +9 -13
- package/lib/utils.js +131 -85
- package/mocha.js +1556 -1064
- package/package.json +32 -19
- package/images/error.png +0 -0
- package/images/ok.png +0 -0
package/lib/reporters/html.js
CHANGED
|
@@ -36,7 +36,8 @@ exports = module.exports = HTML;
|
|
|
36
36
|
* Stats template.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
var statsTemplate =
|
|
39
|
+
var statsTemplate =
|
|
40
|
+
'<ul id="mocha-stats">' +
|
|
40
41
|
'<li class="progress"><canvas width="40" height="40"></canvas></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>' +
|
|
@@ -55,7 +56,7 @@ var playIcon = '‣';
|
|
|
55
56
|
* @api public
|
|
56
57
|
* @param {Runner} runner
|
|
57
58
|
*/
|
|
58
|
-
function HTML
|
|
59
|
+
function HTML(runner) {
|
|
59
60
|
Base.call(this, runner);
|
|
60
61
|
|
|
61
62
|
var self = this;
|
|
@@ -90,10 +91,10 @@ function HTML (runner) {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
// pass toggle
|
|
93
|
-
on(passesLink, 'click', function
|
|
94
|
+
on(passesLink, 'click', function(evt) {
|
|
94
95
|
evt.preventDefault();
|
|
95
96
|
unhide();
|
|
96
|
-
var name =
|
|
97
|
+
var name = /pass/.test(report.className) ? '' : ' pass';
|
|
97
98
|
report.className = report.className.replace(/fail|pass/g, '') + name;
|
|
98
99
|
if (report.className.trim()) {
|
|
99
100
|
hideSuitesWithout('test pass');
|
|
@@ -101,10 +102,10 @@ function HTML (runner) {
|
|
|
101
102
|
});
|
|
102
103
|
|
|
103
104
|
// failure toggle
|
|
104
|
-
on(failuresLink, 'click', function
|
|
105
|
+
on(failuresLink, 'click', function(evt) {
|
|
105
106
|
evt.preventDefault();
|
|
106
107
|
unhide();
|
|
107
|
-
var name =
|
|
108
|
+
var name = /fail/.test(report.className) ? '' : ' fail';
|
|
108
109
|
report.className = report.className.replace(/fail|pass/g, '') + name;
|
|
109
110
|
if (report.className.trim()) {
|
|
110
111
|
hideSuitesWithout('test fail');
|
|
@@ -118,14 +119,18 @@ function HTML (runner) {
|
|
|
118
119
|
progress.size(40);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
runner.on('suite', function
|
|
122
|
+
runner.on('suite', function(suite) {
|
|
122
123
|
if (suite.root) {
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
// suite
|
|
127
128
|
var url = self.suiteURL(suite);
|
|
128
|
-
var el = fragment(
|
|
129
|
+
var el = fragment(
|
|
130
|
+
'<li class="suite"><h1><a href="%s">%s</a></h1></li>',
|
|
131
|
+
url,
|
|
132
|
+
escape(suite.title)
|
|
133
|
+
);
|
|
129
134
|
|
|
130
135
|
// container
|
|
131
136
|
stack[0].appendChild(el);
|
|
@@ -133,7 +138,7 @@ function HTML (runner) {
|
|
|
133
138
|
el.appendChild(stack[0]);
|
|
134
139
|
});
|
|
135
140
|
|
|
136
|
-
runner.on('suite end', function
|
|
141
|
+
runner.on('suite end', function(suite) {
|
|
137
142
|
if (suite.root) {
|
|
138
143
|
updateStats();
|
|
139
144
|
return;
|
|
@@ -141,19 +146,27 @@ function HTML (runner) {
|
|
|
141
146
|
stack.shift();
|
|
142
147
|
});
|
|
143
148
|
|
|
144
|
-
runner.on('pass', function
|
|
149
|
+
runner.on('pass', function(test) {
|
|
145
150
|
var url = self.testURL(test);
|
|
146
|
-
var markup =
|
|
147
|
-
'<
|
|
151
|
+
var markup =
|
|
152
|
+
'<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
|
|
153
|
+
'<a href="%s" class="replay">' +
|
|
154
|
+
playIcon +
|
|
155
|
+
'</a></h2></li>';
|
|
148
156
|
var el = fragment(markup, test.speed, test.title, test.duration, url);
|
|
149
157
|
self.addCodeToggle(el, test.body);
|
|
150
158
|
appendToStack(el);
|
|
151
159
|
updateStats();
|
|
152
160
|
});
|
|
153
161
|
|
|
154
|
-
runner.on('fail', function
|
|
155
|
-
var el = fragment(
|
|
156
|
-
test
|
|
162
|
+
runner.on('fail', function(test) {
|
|
163
|
+
var el = fragment(
|
|
164
|
+
'<li class="test fail"><h2>%e <a href="%e" class="replay">' +
|
|
165
|
+
playIcon +
|
|
166
|
+
'</a></h2></li>',
|
|
167
|
+
test.title,
|
|
168
|
+
self.testURL(test)
|
|
169
|
+
);
|
|
157
170
|
var stackString; // Note: Includes leading newline
|
|
158
171
|
var message = test.err.toString();
|
|
159
172
|
|
|
@@ -168,7 +181,9 @@ function HTML (runner) {
|
|
|
168
181
|
if (indexOfMessage === -1) {
|
|
169
182
|
stackString = test.err.stack;
|
|
170
183
|
} else {
|
|
171
|
-
stackString = test.err.stack.substr(
|
|
184
|
+
stackString = test.err.stack.substr(
|
|
185
|
+
test.err.message.length + indexOfMessage
|
|
186
|
+
);
|
|
172
187
|
}
|
|
173
188
|
} else if (test.err.sourceURL && test.err.line !== undefined) {
|
|
174
189
|
// Safari doesn't give you a stack. Let's at least provide a source line.
|
|
@@ -178,12 +193,21 @@ function HTML (runner) {
|
|
|
178
193
|
stackString = stackString || '';
|
|
179
194
|
|
|
180
195
|
if (test.err.htmlMessage && stackString) {
|
|
181
|
-
el.appendChild(
|
|
182
|
-
|
|
196
|
+
el.appendChild(
|
|
197
|
+
fragment(
|
|
198
|
+
'<div class="html-error">%s\n<pre class="error">%e</pre></div>',
|
|
199
|
+
test.err.htmlMessage,
|
|
200
|
+
stackString
|
|
201
|
+
)
|
|
202
|
+
);
|
|
183
203
|
} else if (test.err.htmlMessage) {
|
|
184
|
-
el.appendChild(
|
|
204
|
+
el.appendChild(
|
|
205
|
+
fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
|
|
206
|
+
);
|
|
185
207
|
} else {
|
|
186
|
-
el.appendChild(
|
|
208
|
+
el.appendChild(
|
|
209
|
+
fragment('<pre class="error">%e%e</pre>', message, stackString)
|
|
210
|
+
);
|
|
187
211
|
}
|
|
188
212
|
|
|
189
213
|
self.addCodeToggle(el, test.body);
|
|
@@ -191,22 +215,25 @@ function HTML (runner) {
|
|
|
191
215
|
updateStats();
|
|
192
216
|
});
|
|
193
217
|
|
|
194
|
-
runner.on('pending', function
|
|
195
|
-
var el = fragment(
|
|
218
|
+
runner.on('pending', function(test) {
|
|
219
|
+
var el = fragment(
|
|
220
|
+
'<li class="test pass pending"><h2>%e</h2></li>',
|
|
221
|
+
test.title
|
|
222
|
+
);
|
|
196
223
|
appendToStack(el);
|
|
197
224
|
updateStats();
|
|
198
225
|
});
|
|
199
226
|
|
|
200
|
-
function appendToStack
|
|
227
|
+
function appendToStack(el) {
|
|
201
228
|
// Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
|
|
202
229
|
if (stack[0]) {
|
|
203
230
|
stack[0].appendChild(el);
|
|
204
231
|
}
|
|
205
232
|
}
|
|
206
233
|
|
|
207
|
-
function updateStats
|
|
234
|
+
function updateStats() {
|
|
208
235
|
// TODO: add to stats
|
|
209
|
-
var percent = stats.tests / runner.total * 100 | 0;
|
|
236
|
+
var percent = (stats.tests / runner.total * 100) | 0;
|
|
210
237
|
if (progress) {
|
|
211
238
|
progress.update(percent).draw(ctx);
|
|
212
239
|
}
|
|
@@ -225,7 +252,7 @@ function HTML (runner) {
|
|
|
225
252
|
* @param {string} s
|
|
226
253
|
* @return {string} A new URL.
|
|
227
254
|
*/
|
|
228
|
-
function makeUrl
|
|
255
|
+
function makeUrl(s) {
|
|
229
256
|
var search = window.location.search;
|
|
230
257
|
|
|
231
258
|
// Remove previous grep query parameter if present
|
|
@@ -233,7 +260,12 @@ function makeUrl (s) {
|
|
|
233
260
|
search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
|
|
234
261
|
}
|
|
235
262
|
|
|
236
|
-
return
|
|
263
|
+
return (
|
|
264
|
+
window.location.pathname +
|
|
265
|
+
(search ? search + '&' : '?') +
|
|
266
|
+
'grep=' +
|
|
267
|
+
encodeURIComponent(escapeRe(s))
|
|
268
|
+
);
|
|
237
269
|
}
|
|
238
270
|
|
|
239
271
|
/**
|
|
@@ -241,7 +273,7 @@ function makeUrl (s) {
|
|
|
241
273
|
*
|
|
242
274
|
* @param {Object} [suite]
|
|
243
275
|
*/
|
|
244
|
-
HTML.prototype.suiteURL = function
|
|
276
|
+
HTML.prototype.suiteURL = function(suite) {
|
|
245
277
|
return makeUrl(suite.fullTitle());
|
|
246
278
|
};
|
|
247
279
|
|
|
@@ -250,7 +282,7 @@ HTML.prototype.suiteURL = function (suite) {
|
|
|
250
282
|
*
|
|
251
283
|
* @param {Object} [test]
|
|
252
284
|
*/
|
|
253
|
-
HTML.prototype.testURL = function
|
|
285
|
+
HTML.prototype.testURL = function(test) {
|
|
254
286
|
return makeUrl(test.fullTitle());
|
|
255
287
|
};
|
|
256
288
|
|
|
@@ -260,10 +292,10 @@ HTML.prototype.testURL = function (test) {
|
|
|
260
292
|
* @param {HTMLLIElement} el
|
|
261
293
|
* @param {string} contents
|
|
262
294
|
*/
|
|
263
|
-
HTML.prototype.addCodeToggle = function
|
|
295
|
+
HTML.prototype.addCodeToggle = function(el, contents) {
|
|
264
296
|
var h2 = el.getElementsByTagName('h2')[0];
|
|
265
297
|
|
|
266
|
-
on(h2, 'click', function
|
|
298
|
+
on(h2, 'click', function() {
|
|
267
299
|
pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
|
|
268
300
|
});
|
|
269
301
|
|
|
@@ -277,7 +309,7 @@ HTML.prototype.addCodeToggle = function (el, contents) {
|
|
|
277
309
|
*
|
|
278
310
|
* @param {string} msg
|
|
279
311
|
*/
|
|
280
|
-
function error
|
|
312
|
+
function error(msg) {
|
|
281
313
|
document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
|
|
282
314
|
}
|
|
283
315
|
|
|
@@ -286,15 +318,17 @@ function error (msg) {
|
|
|
286
318
|
*
|
|
287
319
|
* @param {string} html
|
|
288
320
|
*/
|
|
289
|
-
function fragment
|
|
321
|
+
function fragment(html) {
|
|
290
322
|
var args = arguments;
|
|
291
323
|
var div = document.createElement('div');
|
|
292
324
|
var i = 1;
|
|
293
325
|
|
|
294
|
-
div.innerHTML = html.replace(/%([se])/g, function
|
|
326
|
+
div.innerHTML = html.replace(/%([se])/g, function(_, type) {
|
|
295
327
|
switch (type) {
|
|
296
|
-
case 's':
|
|
297
|
-
|
|
328
|
+
case 's':
|
|
329
|
+
return String(args[i++]);
|
|
330
|
+
case 'e':
|
|
331
|
+
return escape(args[i++]);
|
|
298
332
|
// no default
|
|
299
333
|
}
|
|
300
334
|
});
|
|
@@ -308,7 +342,7 @@ function fragment (html) {
|
|
|
308
342
|
*
|
|
309
343
|
* @param {text} classname
|
|
310
344
|
*/
|
|
311
|
-
function hideSuitesWithout
|
|
345
|
+
function hideSuitesWithout(classname) {
|
|
312
346
|
var suites = document.getElementsByClassName('suite');
|
|
313
347
|
for (var i = 0; i < suites.length; i++) {
|
|
314
348
|
var els = suites[i].getElementsByClassName(classname);
|
|
@@ -321,7 +355,7 @@ function hideSuitesWithout (classname) {
|
|
|
321
355
|
/**
|
|
322
356
|
* Unhide .hidden suites.
|
|
323
357
|
*/
|
|
324
|
-
function unhide
|
|
358
|
+
function unhide() {
|
|
325
359
|
var els = document.getElementsByClassName('suite hidden');
|
|
326
360
|
for (var i = 0; i < els.length; ++i) {
|
|
327
361
|
els[i].className = els[i].className.replace('suite hidden', 'suite');
|
|
@@ -334,7 +368,7 @@ function unhide () {
|
|
|
334
368
|
* @param {HTMLElement} el
|
|
335
369
|
* @param {string} contents
|
|
336
370
|
*/
|
|
337
|
-
function text
|
|
371
|
+
function text(el, contents) {
|
|
338
372
|
if (el.textContent) {
|
|
339
373
|
el.textContent = contents;
|
|
340
374
|
} else {
|
|
@@ -345,7 +379,7 @@ function text (el, contents) {
|
|
|
345
379
|
/**
|
|
346
380
|
* Listen on `event` with callback `fn`.
|
|
347
381
|
*/
|
|
348
|
-
function on
|
|
382
|
+
function on(el, event, fn) {
|
|
349
383
|
if (el.addEventListener) {
|
|
350
384
|
el.addEventListener(event, fn, false);
|
|
351
385
|
} else {
|
|
@@ -25,28 +25,28 @@ exports = module.exports = List;
|
|
|
25
25
|
* @api public
|
|
26
26
|
* @param {Runner} runner
|
|
27
27
|
*/
|
|
28
|
-
function List
|
|
28
|
+
function List(runner) {
|
|
29
29
|
Base.call(this, runner);
|
|
30
30
|
|
|
31
31
|
var self = this;
|
|
32
32
|
var total = runner.total;
|
|
33
33
|
|
|
34
|
-
runner.on('start', function
|
|
35
|
-
console.log(JSON.stringify(['start', {
|
|
34
|
+
runner.on('start', function() {
|
|
35
|
+
console.log(JSON.stringify(['start', {total: total}]));
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
runner.on('pass', function
|
|
38
|
+
runner.on('pass', function(test) {
|
|
39
39
|
console.log(JSON.stringify(['pass', clean(test)]));
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
runner.on('fail', function
|
|
42
|
+
runner.on('fail', function(test, err) {
|
|
43
43
|
test = clean(test);
|
|
44
44
|
test.err = err.message;
|
|
45
45
|
test.stack = err.stack || null;
|
|
46
46
|
console.log(JSON.stringify(['fail', test]));
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
runner.once('end', function
|
|
49
|
+
runner.once('end', function() {
|
|
50
50
|
process.stdout.write(JSON.stringify(['end', self.stats]));
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -59,7 +59,7 @@ function List (runner) {
|
|
|
59
59
|
* @param {Object} test
|
|
60
60
|
* @return {Object}
|
|
61
61
|
*/
|
|
62
|
-
function clean
|
|
62
|
+
function clean(test) {
|
|
63
63
|
return {
|
|
64
64
|
title: test.title,
|
|
65
65
|
fullTitle: test.fullTitle(),
|
package/lib/reporters/json.js
CHANGED
|
@@ -24,7 +24,7 @@ exports = module.exports = JSONReporter;
|
|
|
24
24
|
* @api public
|
|
25
25
|
* @param {Runner} runner
|
|
26
26
|
*/
|
|
27
|
-
function JSONReporter
|
|
27
|
+
function JSONReporter(runner) {
|
|
28
28
|
Base.call(this, runner);
|
|
29
29
|
|
|
30
30
|
var self = this;
|
|
@@ -33,23 +33,23 @@ function JSONReporter (runner) {
|
|
|
33
33
|
var failures = [];
|
|
34
34
|
var passes = [];
|
|
35
35
|
|
|
36
|
-
runner.on('test end', function
|
|
36
|
+
runner.on('test end', function(test) {
|
|
37
37
|
tests.push(test);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
runner.on('pass', function
|
|
40
|
+
runner.on('pass', function(test) {
|
|
41
41
|
passes.push(test);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
runner.on('fail', function
|
|
44
|
+
runner.on('fail', function(test) {
|
|
45
45
|
failures.push(test);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
runner.on('pending', function
|
|
48
|
+
runner.on('pending', function(test) {
|
|
49
49
|
pending.push(test);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
runner.once('end', function
|
|
52
|
+
runner.once('end', function() {
|
|
53
53
|
var obj = {
|
|
54
54
|
stats: self.stats,
|
|
55
55
|
tests: tests.map(clean),
|
|
@@ -72,7 +72,7 @@ function JSONReporter (runner) {
|
|
|
72
72
|
* @param {Object} test
|
|
73
73
|
* @return {Object}
|
|
74
74
|
*/
|
|
75
|
-
function clean
|
|
75
|
+
function clean(test) {
|
|
76
76
|
var err = test.err || {};
|
|
77
77
|
if (err instanceof Error) {
|
|
78
78
|
err = errorJSON(err);
|
|
@@ -94,19 +94,21 @@ function clean (test) {
|
|
|
94
94
|
* @param {Object} obj
|
|
95
95
|
* @return {Object}
|
|
96
96
|
*/
|
|
97
|
-
function cleanCycles
|
|
97
|
+
function cleanCycles(obj) {
|
|
98
98
|
var cache = [];
|
|
99
|
-
return JSON.parse(
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
return JSON.parse(
|
|
100
|
+
JSON.stringify(obj, function(key, value) {
|
|
101
|
+
if (typeof value === 'object' && value !== null) {
|
|
102
|
+
if (cache.indexOf(value) !== -1) {
|
|
103
|
+
// Instead of going in a circle, we'll print [object Object]
|
|
104
|
+
return '' + value;
|
|
105
|
+
}
|
|
106
|
+
cache.push(value);
|
|
104
107
|
}
|
|
105
|
-
cache.push(value);
|
|
106
|
-
}
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
return value;
|
|
110
|
+
})
|
|
111
|
+
);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/**
|
|
@@ -116,9 +118,9 @@ function cleanCycles (obj) {
|
|
|
116
118
|
* @param {Error} err
|
|
117
119
|
* @return {Object}
|
|
118
120
|
*/
|
|
119
|
-
function errorJSON
|
|
121
|
+
function errorJSON(err) {
|
|
120
122
|
var res = {};
|
|
121
|
-
Object.getOwnPropertyNames(err).forEach(function
|
|
123
|
+
Object.getOwnPropertyNames(err).forEach(function(key) {
|
|
122
124
|
res[key] = err[key];
|
|
123
125
|
}, err);
|
|
124
126
|
return res;
|
package/lib/reporters/landing.js
CHANGED
|
@@ -45,30 +45,30 @@ Base.colors.runway = 90;
|
|
|
45
45
|
* @api public
|
|
46
46
|
* @param {Runner} runner
|
|
47
47
|
*/
|
|
48
|
-
function Landing
|
|
48
|
+
function Landing(runner) {
|
|
49
49
|
Base.call(this, runner);
|
|
50
50
|
|
|
51
51
|
var self = this;
|
|
52
|
-
var width = Base.window.width * 0.75 | 0;
|
|
52
|
+
var width = (Base.window.width * 0.75) | 0;
|
|
53
53
|
var total = runner.total;
|
|
54
54
|
var stream = process.stdout;
|
|
55
55
|
var plane = color('plane', '✈');
|
|
56
56
|
var crashed = -1;
|
|
57
57
|
var n = 0;
|
|
58
58
|
|
|
59
|
-
function runway
|
|
59
|
+
function runway() {
|
|
60
60
|
var buf = Array(width).join('-');
|
|
61
61
|
return ' ' + color('runway', buf);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
runner.on('start', function
|
|
64
|
+
runner.on('start', function() {
|
|
65
65
|
stream.write('\n\n\n ');
|
|
66
66
|
cursor.hide();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
runner.on('test end', function
|
|
69
|
+
runner.on('test end', function(test) {
|
|
70
70
|
// check if the plane crashed
|
|
71
|
-
var col = crashed === -1 ? width * ++n / total | 0 : crashed;
|
|
71
|
+
var col = crashed === -1 ? (width * ++n / total) | 0 : crashed;
|
|
72
72
|
|
|
73
73
|
// show the crash
|
|
74
74
|
if (test.state === 'failed') {
|
|
@@ -87,7 +87,7 @@ function Landing (runner) {
|
|
|
87
87
|
stream.write('\u001b[0m');
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
runner.once('end', function
|
|
90
|
+
runner.once('end', function() {
|
|
91
91
|
cursor.show();
|
|
92
92
|
console.log();
|
|
93
93
|
self.epilogue();
|
package/lib/reporters/list.js
CHANGED
|
@@ -27,35 +27,35 @@ exports = module.exports = List;
|
|
|
27
27
|
* @api public
|
|
28
28
|
* @param {Runner} runner
|
|
29
29
|
*/
|
|
30
|
-
function List
|
|
30
|
+
function List(runner) {
|
|
31
31
|
Base.call(this, runner);
|
|
32
32
|
|
|
33
33
|
var self = this;
|
|
34
34
|
var n = 0;
|
|
35
35
|
|
|
36
|
-
runner.on('start', function
|
|
36
|
+
runner.on('start', function() {
|
|
37
37
|
console.log();
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
runner.on('test', function
|
|
40
|
+
runner.on('test', function(test) {
|
|
41
41
|
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
runner.on('pending', function
|
|
45
|
-
var fmt = color('checkmark', ' -') +
|
|
46
|
-
color('pending', ' %s');
|
|
44
|
+
runner.on('pending', function(test) {
|
|
45
|
+
var fmt = color('checkmark', ' -') + color('pending', ' %s');
|
|
47
46
|
console.log(fmt, test.fullTitle());
|
|
48
47
|
});
|
|
49
48
|
|
|
50
|
-
runner.on('pass', function
|
|
51
|
-
var fmt =
|
|
49
|
+
runner.on('pass', function(test) {
|
|
50
|
+
var fmt =
|
|
51
|
+
color('checkmark', ' ' + Base.symbols.ok) +
|
|
52
52
|
color('pass', ' %s: ') +
|
|
53
53
|
color(test.speed, '%dms');
|
|
54
54
|
cursor.CR();
|
|
55
55
|
console.log(fmt, test.fullTitle(), test.duration);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
runner.on('fail', function
|
|
58
|
+
runner.on('fail', function(test) {
|
|
59
59
|
cursor.CR();
|
|
60
60
|
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
|
|
61
61
|
});
|
|
@@ -31,29 +31,29 @@ exports = module.exports = Markdown;
|
|
|
31
31
|
* @api public
|
|
32
32
|
* @param {Runner} runner
|
|
33
33
|
*/
|
|
34
|
-
function Markdown
|
|
34
|
+
function Markdown(runner) {
|
|
35
35
|
Base.call(this, runner);
|
|
36
36
|
|
|
37
37
|
var level = 0;
|
|
38
38
|
var buf = '';
|
|
39
39
|
|
|
40
|
-
function title
|
|
40
|
+
function title(str) {
|
|
41
41
|
return Array(level).join('#') + ' ' + str;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function mapTOC
|
|
44
|
+
function mapTOC(suite, obj) {
|
|
45
45
|
var ret = obj;
|
|
46
46
|
var key = SUITE_PREFIX + suite.title;
|
|
47
47
|
|
|
48
|
-
obj = obj[key] = obj[key] || {
|
|
49
|
-
suite.suites.forEach(function
|
|
48
|
+
obj = obj[key] = obj[key] || {suite: suite};
|
|
49
|
+
suite.suites.forEach(function(suite) {
|
|
50
50
|
mapTOC(suite, obj);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
return ret;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function stringifyTOC
|
|
56
|
+
function stringifyTOC(obj, level) {
|
|
57
57
|
++level;
|
|
58
58
|
var buf = '';
|
|
59
59
|
var link;
|
|
@@ -71,25 +71,25 @@ function Markdown (runner) {
|
|
|
71
71
|
return buf;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function generateTOC
|
|
74
|
+
function generateTOC(suite) {
|
|
75
75
|
var obj = mapTOC(suite, {});
|
|
76
76
|
return stringifyTOC(obj, 0);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
generateTOC(runner.suite);
|
|
80
80
|
|
|
81
|
-
runner.on('suite', function
|
|
81
|
+
runner.on('suite', function(suite) {
|
|
82
82
|
++level;
|
|
83
83
|
var slug = utils.slug(suite.fullTitle());
|
|
84
84
|
buf += '<a name="' + slug + '"></a>' + '\n';
|
|
85
85
|
buf += title(suite.title) + '\n';
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
runner.on('suite end', function
|
|
88
|
+
runner.on('suite end', function() {
|
|
89
89
|
--level;
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
runner.on('pass', function
|
|
92
|
+
runner.on('pass', function(test) {
|
|
93
93
|
var code = utils.clean(test.body);
|
|
94
94
|
buf += test.title + '.\n';
|
|
95
95
|
buf += '\n```js\n';
|
|
@@ -97,7 +97,7 @@ function Markdown (runner) {
|
|
|
97
97
|
buf += '```\n\n';
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
runner.once('end', function
|
|
100
|
+
runner.once('end', function() {
|
|
101
101
|
process.stdout.write('# TOC\n');
|
|
102
102
|
process.stdout.write(generateTOC(runner.suite));
|
|
103
103
|
process.stdout.write(buf);
|
package/lib/reporters/min.js
CHANGED
|
@@ -25,10 +25,10 @@ exports = module.exports = Min;
|
|
|
25
25
|
* @api public
|
|
26
26
|
* @param {Runner} runner
|
|
27
27
|
*/
|
|
28
|
-
function Min
|
|
28
|
+
function Min(runner) {
|
|
29
29
|
Base.call(this, runner);
|
|
30
30
|
|
|
31
|
-
runner.on('start', function
|
|
31
|
+
runner.on('start', function() {
|
|
32
32
|
// clear screen
|
|
33
33
|
process.stdout.write('\u001b[2J');
|
|
34
34
|
// set cursor position
|