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
package/lib/mocharc.json
ADDED
package/lib/pending.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Expose `Pending`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
module.exports = Pending;
|
|
8
4
|
|
|
9
5
|
/**
|
|
@@ -11,6 +7,6 @@ module.exports = Pending;
|
|
|
11
7
|
*
|
|
12
8
|
* @param {string} message
|
|
13
9
|
*/
|
|
14
|
-
function Pending
|
|
10
|
+
function Pending(message) {
|
|
15
11
|
this.message = message;
|
|
16
12
|
}
|
package/lib/reporters/base.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
var tty = require('tty');
|
|
10
10
|
var diff = require('diff');
|
|
11
|
-
var
|
|
11
|
+
var milliseconds = require('ms');
|
|
12
12
|
var utils = require('../utils');
|
|
13
13
|
var supportsColor = process.browser ? null : require('supports-color');
|
|
14
14
|
|
|
@@ -18,19 +18,6 @@ var supportsColor = process.browser ? null : require('supports-color');
|
|
|
18
18
|
|
|
19
19
|
exports = module.exports = Base;
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Save timer references to avoid Sinon interfering.
|
|
23
|
-
* See: https://github.com/mochajs/mocha/issues/237
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/* eslint-disable no-unused-vars, no-native-reassign */
|
|
27
|
-
var Date = global.Date;
|
|
28
|
-
var setTimeout = global.setTimeout;
|
|
29
|
-
var setInterval = global.setInterval;
|
|
30
|
-
var clearTimeout = global.clearTimeout;
|
|
31
|
-
var clearInterval = global.clearInterval;
|
|
32
|
-
/* eslint-enable no-unused-vars, no-native-reassign */
|
|
33
|
-
|
|
34
21
|
/**
|
|
35
22
|
* Check if both stdio streams are associated with a tty.
|
|
36
23
|
*/
|
|
@@ -41,7 +28,9 @@ var isatty = tty.isatty(1) && tty.isatty(2);
|
|
|
41
28
|
* Enable coloring by default, except in the browser interface.
|
|
42
29
|
*/
|
|
43
30
|
|
|
44
|
-
exports.useColors =
|
|
31
|
+
exports.useColors =
|
|
32
|
+
!process.browser &&
|
|
33
|
+
(supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
|
|
45
34
|
|
|
46
35
|
/**
|
|
47
36
|
* Inline diffs instead of +/-
|
|
@@ -103,14 +92,14 @@ if (process.platform === 'win32') {
|
|
|
103
92
|
* @param {string} type
|
|
104
93
|
* @param {string} str
|
|
105
94
|
* @return {string}
|
|
106
|
-
* @
|
|
95
|
+
* @private
|
|
107
96
|
*/
|
|
108
|
-
var color = exports.color = function
|
|
97
|
+
var color = (exports.color = function(type, str) {
|
|
109
98
|
if (!exports.useColors) {
|
|
110
99
|
return String(str);
|
|
111
100
|
}
|
|
112
101
|
return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
|
|
113
|
-
};
|
|
102
|
+
});
|
|
114
103
|
|
|
115
104
|
/**
|
|
116
105
|
* Expose term window size, with some defaults for when stderr is not a tty.
|
|
@@ -131,23 +120,23 @@ if (isatty) {
|
|
|
131
120
|
*/
|
|
132
121
|
|
|
133
122
|
exports.cursor = {
|
|
134
|
-
hide: function
|
|
123
|
+
hide: function() {
|
|
135
124
|
isatty && process.stdout.write('\u001b[?25l');
|
|
136
125
|
},
|
|
137
126
|
|
|
138
|
-
show: function
|
|
127
|
+
show: function() {
|
|
139
128
|
isatty && process.stdout.write('\u001b[?25h');
|
|
140
129
|
},
|
|
141
130
|
|
|
142
|
-
deleteLine: function
|
|
131
|
+
deleteLine: function() {
|
|
143
132
|
isatty && process.stdout.write('\u001b[2K');
|
|
144
133
|
},
|
|
145
134
|
|
|
146
|
-
beginningOfLine: function
|
|
135
|
+
beginningOfLine: function() {
|
|
147
136
|
isatty && process.stdout.write('\u001b[0G');
|
|
148
137
|
},
|
|
149
138
|
|
|
150
|
-
CR: function
|
|
139
|
+
CR: function() {
|
|
151
140
|
if (isatty) {
|
|
152
141
|
exports.cursor.deleteLine();
|
|
153
142
|
exports.cursor.beginningOfLine();
|
|
@@ -157,11 +146,16 @@ exports.cursor = {
|
|
|
157
146
|
}
|
|
158
147
|
};
|
|
159
148
|
|
|
160
|
-
function showDiff
|
|
161
|
-
return
|
|
149
|
+
function showDiff(err) {
|
|
150
|
+
return (
|
|
151
|
+
err &&
|
|
152
|
+
err.showDiff !== false &&
|
|
153
|
+
sameType(err.actual, err.expected) &&
|
|
154
|
+
err.expected !== undefined
|
|
155
|
+
);
|
|
162
156
|
}
|
|
163
157
|
|
|
164
|
-
function stringifyDiffObjs
|
|
158
|
+
function stringifyDiffObjs(err) {
|
|
165
159
|
if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
|
|
166
160
|
err.actual = utils.stringify(err.actual);
|
|
167
161
|
err.expected = utils.stringify(err.expected);
|
|
@@ -178,11 +172,11 @@ function stringifyDiffObjs (err) {
|
|
|
178
172
|
* @param {string} expected
|
|
179
173
|
* @return {string} Diff
|
|
180
174
|
*/
|
|
181
|
-
var generateDiff = exports.generateDiff = function
|
|
175
|
+
var generateDiff = (exports.generateDiff = function(actual, expected) {
|
|
182
176
|
return exports.inlineDiffs
|
|
183
177
|
? inlineDiff(actual, expected)
|
|
184
178
|
: unifiedDiff(actual, expected);
|
|
185
|
-
};
|
|
179
|
+
});
|
|
186
180
|
|
|
187
181
|
/**
|
|
188
182
|
* Output the given `failures` as a list.
|
|
@@ -191,14 +185,14 @@ var generateDiff = exports.generateDiff = function (actual, expected) {
|
|
|
191
185
|
* @memberof Mocha.reporters.Base
|
|
192
186
|
* @variation 1
|
|
193
187
|
* @param {Array} failures
|
|
194
|
-
* @api public
|
|
195
188
|
*/
|
|
196
189
|
|
|
197
|
-
exports.list = function
|
|
190
|
+
exports.list = function(failures) {
|
|
198
191
|
console.log();
|
|
199
|
-
failures.forEach(function
|
|
192
|
+
failures.forEach(function(test, i) {
|
|
200
193
|
// format
|
|
201
|
-
var fmt =
|
|
194
|
+
var fmt =
|
|
195
|
+
color('error title', ' %s) %s:\n') +
|
|
202
196
|
color('error message', ' %s') +
|
|
203
197
|
color('error stack', '\n%s\n');
|
|
204
198
|
|
|
@@ -232,7 +226,8 @@ exports.list = function (failures) {
|
|
|
232
226
|
// explicitly show diff
|
|
233
227
|
if (!exports.hideDiff && showDiff(err)) {
|
|
234
228
|
stringifyDiffObjs(err);
|
|
235
|
-
fmt =
|
|
229
|
+
fmt =
|
|
230
|
+
color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
|
|
236
231
|
var match = message.match(/^([^:]+): expected/);
|
|
237
232
|
msg = '\n ' + color('error message', match ? match[1] : msg);
|
|
238
233
|
|
|
@@ -244,7 +239,7 @@ exports.list = function (failures) {
|
|
|
244
239
|
|
|
245
240
|
// indented test title
|
|
246
241
|
var testTitle = '';
|
|
247
|
-
test.titlePath().forEach(function
|
|
242
|
+
test.titlePath().forEach(function(str, index) {
|
|
248
243
|
if (index !== 0) {
|
|
249
244
|
testTitle += '\n ';
|
|
250
245
|
}
|
|
@@ -254,7 +249,7 @@ exports.list = function (failures) {
|
|
|
254
249
|
testTitle += str;
|
|
255
250
|
});
|
|
256
251
|
|
|
257
|
-
console.log(fmt,
|
|
252
|
+
console.log(fmt, i + 1, testTitle, msg, stack);
|
|
258
253
|
});
|
|
259
254
|
};
|
|
260
255
|
|
|
@@ -262,45 +257,24 @@ exports.list = function (failures) {
|
|
|
262
257
|
* Initialize a new `Base` reporter.
|
|
263
258
|
*
|
|
264
259
|
* All other reporters generally
|
|
265
|
-
* inherit from this reporter
|
|
266
|
-
* stats such as test duration, number
|
|
267
|
-
* of tests passed / failed etc.
|
|
260
|
+
* inherit from this reporter.
|
|
268
261
|
*
|
|
269
262
|
* @memberof Mocha.reporters
|
|
270
263
|
* @public
|
|
271
264
|
* @class
|
|
272
265
|
* @param {Runner} runner
|
|
273
|
-
* @api public
|
|
274
266
|
*/
|
|
275
267
|
|
|
276
|
-
function Base
|
|
277
|
-
var
|
|
278
|
-
var failures = this.failures = [];
|
|
268
|
+
function Base(runner) {
|
|
269
|
+
var failures = (this.failures = []);
|
|
279
270
|
|
|
280
271
|
if (!runner) {
|
|
281
|
-
|
|
272
|
+
throw new TypeError('Missing runner argument');
|
|
282
273
|
}
|
|
274
|
+
this.stats = runner.stats; // assigned so Reporters keep a closer reference
|
|
283
275
|
this.runner = runner;
|
|
284
276
|
|
|
285
|
-
runner.
|
|
286
|
-
|
|
287
|
-
runner.on('start', function () {
|
|
288
|
-
stats.start = new Date();
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
runner.on('suite', function (suite) {
|
|
292
|
-
stats.suites = stats.suites || 0;
|
|
293
|
-
suite.root || stats.suites++;
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
runner.on('test end', function () {
|
|
297
|
-
stats.tests = stats.tests || 0;
|
|
298
|
-
stats.tests++;
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
runner.on('pass', function (test) {
|
|
302
|
-
stats.passes = stats.passes || 0;
|
|
303
|
-
|
|
277
|
+
runner.on('pass', function(test) {
|
|
304
278
|
if (test.duration > test.slow()) {
|
|
305
279
|
test.speed = 'slow';
|
|
306
280
|
} else if (test.duration > test.slow() / 2) {
|
|
@@ -308,28 +282,15 @@ function Base (runner) {
|
|
|
308
282
|
} else {
|
|
309
283
|
test.speed = 'fast';
|
|
310
284
|
}
|
|
311
|
-
|
|
312
|
-
stats.passes++;
|
|
313
285
|
});
|
|
314
286
|
|
|
315
|
-
runner.on('fail', function
|
|
316
|
-
stats.failures = stats.failures || 0;
|
|
317
|
-
stats.failures++;
|
|
287
|
+
runner.on('fail', function(test, err) {
|
|
318
288
|
if (showDiff(err)) {
|
|
319
289
|
stringifyDiffObjs(err);
|
|
320
290
|
}
|
|
321
291
|
test.err = err;
|
|
322
292
|
failures.push(test);
|
|
323
293
|
});
|
|
324
|
-
|
|
325
|
-
runner.once('end', function () {
|
|
326
|
-
stats.end = new Date();
|
|
327
|
-
stats.duration = stats.end - stats.start;
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
runner.on('pending', function () {
|
|
331
|
-
stats.pending++;
|
|
332
|
-
});
|
|
333
294
|
}
|
|
334
295
|
|
|
335
296
|
/**
|
|
@@ -338,27 +299,24 @@ function Base (runner) {
|
|
|
338
299
|
*
|
|
339
300
|
* @memberof Mocha.reporters.Base
|
|
340
301
|
* @public
|
|
341
|
-
* @api public
|
|
342
302
|
*/
|
|
343
|
-
Base.prototype.epilogue = function
|
|
303
|
+
Base.prototype.epilogue = function() {
|
|
344
304
|
var stats = this.stats;
|
|
345
305
|
var fmt;
|
|
346
306
|
|
|
347
307
|
console.log();
|
|
348
308
|
|
|
349
309
|
// passes
|
|
350
|
-
fmt =
|
|
310
|
+
fmt =
|
|
311
|
+
color('bright pass', ' ') +
|
|
351
312
|
color('green', ' %d passing') +
|
|
352
313
|
color('light', ' (%s)');
|
|
353
314
|
|
|
354
|
-
console.log(fmt,
|
|
355
|
-
stats.passes || 0,
|
|
356
|
-
ms(stats.duration));
|
|
315
|
+
console.log(fmt, stats.passes || 0, milliseconds(stats.duration));
|
|
357
316
|
|
|
358
317
|
// pending
|
|
359
318
|
if (stats.pending) {
|
|
360
|
-
fmt = color('pending', ' ') +
|
|
361
|
-
color('pending', ' %d pending');
|
|
319
|
+
fmt = color('pending', ' ') + color('pending', ' %d pending');
|
|
362
320
|
|
|
363
321
|
console.log(fmt, stats.pending);
|
|
364
322
|
}
|
|
@@ -379,12 +337,12 @@ Base.prototype.epilogue = function () {
|
|
|
379
337
|
/**
|
|
380
338
|
* Pad the given `str` to `len`.
|
|
381
339
|
*
|
|
382
|
-
* @
|
|
340
|
+
* @private
|
|
383
341
|
* @param {string} str
|
|
384
342
|
* @param {string} len
|
|
385
343
|
* @return {string}
|
|
386
344
|
*/
|
|
387
|
-
function pad
|
|
345
|
+
function pad(str, len) {
|
|
388
346
|
str = String(str);
|
|
389
347
|
return Array(len - str.length + 1).join(' ') + str;
|
|
390
348
|
}
|
|
@@ -392,25 +350,28 @@ function pad (str, len) {
|
|
|
392
350
|
/**
|
|
393
351
|
* Returns an inline diff between 2 strings with coloured ANSI output.
|
|
394
352
|
*
|
|
395
|
-
* @
|
|
353
|
+
* @private
|
|
396
354
|
* @param {String} actual
|
|
397
355
|
* @param {String} expected
|
|
398
356
|
* @return {string} Diff
|
|
399
357
|
*/
|
|
400
|
-
function inlineDiff
|
|
358
|
+
function inlineDiff(actual, expected) {
|
|
401
359
|
var msg = errorDiff(actual, expected);
|
|
402
360
|
|
|
403
361
|
// linenos
|
|
404
362
|
var lines = msg.split('\n');
|
|
405
363
|
if (lines.length > 4) {
|
|
406
364
|
var width = String(lines.length).length;
|
|
407
|
-
msg = lines
|
|
408
|
-
|
|
409
|
-
|
|
365
|
+
msg = lines
|
|
366
|
+
.map(function(str, i) {
|
|
367
|
+
return pad(++i, width) + ' |' + ' ' + str;
|
|
368
|
+
})
|
|
369
|
+
.join('\n');
|
|
410
370
|
}
|
|
411
371
|
|
|
412
372
|
// legend
|
|
413
|
-
msg =
|
|
373
|
+
msg =
|
|
374
|
+
'\n' +
|
|
414
375
|
color('diff removed', 'actual') +
|
|
415
376
|
' ' +
|
|
416
377
|
color('diff added', 'expected') +
|
|
@@ -426,14 +387,14 @@ function inlineDiff (actual, expected) {
|
|
|
426
387
|
/**
|
|
427
388
|
* Returns a unified diff between two strings with coloured ANSI output.
|
|
428
389
|
*
|
|
429
|
-
* @
|
|
390
|
+
* @private
|
|
430
391
|
* @param {String} actual
|
|
431
392
|
* @param {String} expected
|
|
432
393
|
* @return {string} The diff.
|
|
433
394
|
*/
|
|
434
|
-
function unifiedDiff
|
|
395
|
+
function unifiedDiff(actual, expected) {
|
|
435
396
|
var indent = ' ';
|
|
436
|
-
function cleanUp
|
|
397
|
+
function cleanUp(line) {
|
|
437
398
|
if (line[0] === '+') {
|
|
438
399
|
return indent + colorLines('diff added', line);
|
|
439
400
|
}
|
|
@@ -448,50 +409,62 @@ function unifiedDiff (actual, expected) {
|
|
|
448
409
|
}
|
|
449
410
|
return indent + line;
|
|
450
411
|
}
|
|
451
|
-
function notBlank
|
|
412
|
+
function notBlank(line) {
|
|
452
413
|
return typeof line !== 'undefined' && line !== null;
|
|
453
414
|
}
|
|
454
415
|
var msg = diff.createPatch('string', actual, expected);
|
|
455
416
|
var lines = msg.split('\n').splice(5);
|
|
456
|
-
return
|
|
457
|
-
|
|
417
|
+
return (
|
|
418
|
+
'\n ' +
|
|
419
|
+
colorLines('diff added', '+ expected') +
|
|
420
|
+
' ' +
|
|
458
421
|
colorLines('diff removed', '- actual') +
|
|
459
422
|
'\n\n' +
|
|
460
|
-
lines
|
|
423
|
+
lines
|
|
424
|
+
.map(cleanUp)
|
|
425
|
+
.filter(notBlank)
|
|
426
|
+
.join('\n')
|
|
427
|
+
);
|
|
461
428
|
}
|
|
462
429
|
|
|
463
430
|
/**
|
|
464
431
|
* Return a character diff for `err`.
|
|
465
432
|
*
|
|
466
|
-
* @
|
|
433
|
+
* @private
|
|
467
434
|
* @param {String} actual
|
|
468
435
|
* @param {String} expected
|
|
469
436
|
* @return {string} the diff
|
|
470
437
|
*/
|
|
471
|
-
function errorDiff
|
|
472
|
-
return diff
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
438
|
+
function errorDiff(actual, expected) {
|
|
439
|
+
return diff
|
|
440
|
+
.diffWordsWithSpace(actual, expected)
|
|
441
|
+
.map(function(str) {
|
|
442
|
+
if (str.added) {
|
|
443
|
+
return colorLines('diff added', str.value);
|
|
444
|
+
}
|
|
445
|
+
if (str.removed) {
|
|
446
|
+
return colorLines('diff removed', str.value);
|
|
447
|
+
}
|
|
448
|
+
return str.value;
|
|
449
|
+
})
|
|
450
|
+
.join('');
|
|
481
451
|
}
|
|
482
452
|
|
|
483
453
|
/**
|
|
484
454
|
* Color lines for `str`, using the color `name`.
|
|
485
455
|
*
|
|
486
|
-
* @
|
|
456
|
+
* @private
|
|
487
457
|
* @param {string} name
|
|
488
458
|
* @param {string} str
|
|
489
459
|
* @return {string}
|
|
490
460
|
*/
|
|
491
|
-
function colorLines
|
|
492
|
-
return str
|
|
493
|
-
|
|
494
|
-
|
|
461
|
+
function colorLines(name, str) {
|
|
462
|
+
return str
|
|
463
|
+
.split('\n')
|
|
464
|
+
.map(function(str) {
|
|
465
|
+
return color(name, str);
|
|
466
|
+
})
|
|
467
|
+
.join('\n');
|
|
495
468
|
}
|
|
496
469
|
|
|
497
470
|
/**
|
|
@@ -502,11 +475,13 @@ var objToString = Object.prototype.toString;
|
|
|
502
475
|
/**
|
|
503
476
|
* Check that a / b have the same type.
|
|
504
477
|
*
|
|
505
|
-
* @
|
|
478
|
+
* @private
|
|
506
479
|
* @param {Object} a
|
|
507
480
|
* @param {Object} b
|
|
508
481
|
* @return {boolean}
|
|
509
482
|
*/
|
|
510
|
-
function sameType
|
|
483
|
+
function sameType(a, b) {
|
|
511
484
|
return objToString.call(a) === objToString.call(b);
|
|
512
485
|
}
|
|
486
|
+
|
|
487
|
+
Base.abstract = true;
|
package/lib/reporters/doc.js
CHANGED
|
@@ -23,18 +23,17 @@ exports = module.exports = Doc;
|
|
|
23
23
|
* @extends {Base}
|
|
24
24
|
* @public
|
|
25
25
|
* @param {Runner} runner
|
|
26
|
-
* @api public
|
|
27
26
|
*/
|
|
28
|
-
function Doc
|
|
27
|
+
function Doc(runner) {
|
|
29
28
|
Base.call(this, runner);
|
|
30
29
|
|
|
31
30
|
var indents = 2;
|
|
32
31
|
|
|
33
|
-
function indent
|
|
32
|
+
function indent() {
|
|
34
33
|
return Array(indents).join(' ');
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
runner.on('suite', function
|
|
36
|
+
runner.on('suite', function(suite) {
|
|
38
37
|
if (suite.root) {
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
@@ -45,7 +44,7 @@ function Doc (runner) {
|
|
|
45
44
|
console.log('%s<dl>', indent());
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
runner.on('suite end', function
|
|
47
|
+
runner.on('suite end', function(suite) {
|
|
49
48
|
if (suite.root) {
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
@@ -55,16 +54,26 @@ function Doc (runner) {
|
|
|
55
54
|
--indents;
|
|
56
55
|
});
|
|
57
56
|
|
|
58
|
-
runner.on('pass', function
|
|
57
|
+
runner.on('pass', function(test) {
|
|
59
58
|
console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
|
|
60
59
|
var code = utils.escape(utils.clean(test.body));
|
|
61
60
|
console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
|
|
62
61
|
});
|
|
63
62
|
|
|
64
|
-
runner.on('fail', function
|
|
65
|
-
console.log(
|
|
63
|
+
runner.on('fail', function(test, err) {
|
|
64
|
+
console.log(
|
|
65
|
+
'%s <dt class="error">%s</dt>',
|
|
66
|
+
indent(),
|
|
67
|
+
utils.escape(test.title)
|
|
68
|
+
);
|
|
66
69
|
var code = utils.escape(utils.clean(test.body));
|
|
67
|
-
console.log(
|
|
70
|
+
console.log(
|
|
71
|
+
'%s <dd class="error"><pre><code>%s</code></pre></dd>',
|
|
72
|
+
indent(),
|
|
73
|
+
code
|
|
74
|
+
);
|
|
68
75
|
console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
|
|
69
76
|
});
|
|
70
77
|
}
|
|
78
|
+
|
|
79
|
+
Doc.description = 'HTML documentation';
|
package/lib/reporters/dot.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
var Base = require('./base');
|
|
10
10
|
var inherits = require('../utils').inherits;
|
|
11
|
-
var color = Base.color;
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Expose `Dot`.
|
|
@@ -23,46 +22,45 @@ exports = module.exports = Dot;
|
|
|
23
22
|
* @memberof Mocha.reporters
|
|
24
23
|
* @extends Mocha.reporters.Base
|
|
25
24
|
* @public
|
|
26
|
-
* @api public
|
|
27
25
|
* @param {Runner} runner
|
|
28
26
|
*/
|
|
29
|
-
function Dot
|
|
27
|
+
function Dot(runner) {
|
|
30
28
|
Base.call(this, runner);
|
|
31
29
|
|
|
32
30
|
var self = this;
|
|
33
|
-
var width = Base.window.width * 0.75 | 0;
|
|
31
|
+
var width = (Base.window.width * 0.75) | 0;
|
|
34
32
|
var n = -1;
|
|
35
33
|
|
|
36
|
-
runner.on('start', function
|
|
34
|
+
runner.on('start', function() {
|
|
37
35
|
process.stdout.write('\n');
|
|
38
36
|
});
|
|
39
37
|
|
|
40
|
-
runner.on('pending', function
|
|
38
|
+
runner.on('pending', function() {
|
|
41
39
|
if (++n % width === 0) {
|
|
42
40
|
process.stdout.write('\n ');
|
|
43
41
|
}
|
|
44
|
-
process.stdout.write(color('pending', Base.symbols.comma));
|
|
42
|
+
process.stdout.write(Base.color('pending', Base.symbols.comma));
|
|
45
43
|
});
|
|
46
44
|
|
|
47
|
-
runner.on('pass', function
|
|
45
|
+
runner.on('pass', function(test) {
|
|
48
46
|
if (++n % width === 0) {
|
|
49
47
|
process.stdout.write('\n ');
|
|
50
48
|
}
|
|
51
49
|
if (test.speed === 'slow') {
|
|
52
|
-
process.stdout.write(color('bright yellow', Base.symbols.dot));
|
|
50
|
+
process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
|
|
53
51
|
} else {
|
|
54
|
-
process.stdout.write(color(test.speed, Base.symbols.dot));
|
|
52
|
+
process.stdout.write(Base.color(test.speed, Base.symbols.dot));
|
|
55
53
|
}
|
|
56
54
|
});
|
|
57
55
|
|
|
58
|
-
runner.on('fail', function
|
|
56
|
+
runner.on('fail', function() {
|
|
59
57
|
if (++n % width === 0) {
|
|
60
58
|
process.stdout.write('\n ');
|
|
61
59
|
}
|
|
62
|
-
process.stdout.write(color('fail', Base.symbols.bang));
|
|
60
|
+
process.stdout.write(Base.color('fail', Base.symbols.bang));
|
|
63
61
|
});
|
|
64
62
|
|
|
65
|
-
runner.once('end', function
|
|
63
|
+
runner.once('end', function() {
|
|
66
64
|
console.log();
|
|
67
65
|
self.epilogue();
|
|
68
66
|
});
|
|
@@ -72,3 +70,5 @@ function Dot (runner) {
|
|
|
72
70
|
* Inherit from `Base.prototype`.
|
|
73
71
|
*/
|
|
74
72
|
inherits(Dot, Base);
|
|
73
|
+
|
|
74
|
+
Dot.description = 'dot matrix representation';
|