mocha 12.0.0-beta-9 → 12.0.0-beta-9.2
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/README.md +1 -1
- package/lib/browser/parse-query.js +1 -1
- package/lib/cli/config.js +1 -1
- package/lib/context.js +1 -1
- package/lib/hook.js +70 -78
- package/lib/nodejs/parallel-buffered-runner.js +2 -3
- package/lib/pending.js +8 -5
- package/lib/reporters/base.js +102 -104
- package/lib/reporters/doc.js +71 -70
- package/lib/reporters/dot.js +47 -56
- package/lib/reporters/html.js +245 -248
- package/lib/reporters/json-stream.js +32 -35
- package/lib/reporters/json.js +69 -72
- package/lib/reporters/landing.js +64 -73
- package/lib/reporters/list.js +39 -49
- package/lib/reporters/markdown.js +74 -77
- package/lib/reporters/min.js +28 -37
- package/lib/reporters/nyan.js +212 -221
- package/lib/reporters/progress.js +73 -80
- package/lib/reporters/spec.js +65 -75
- package/lib/reporters/tap.js +114 -136
- package/lib/reporters/xunit.js +134 -143
- package/lib/runnable.js +391 -392
- package/lib/runner.js +5 -5
- package/lib/suite.js +579 -590
- package/lib/test.js +92 -96
- package/lib/utils.js +3 -21
- package/mocha.js +2776 -3072
- package/mocha.js.map +1 -1
- package/mocha.mjs +1 -1
- package/package.json +26 -25
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs
|
|
2
|
+
<img src="docs/src/components/mocha-logo.svg" alt="Mocha test framework logo"/>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">☕️ Classic, reliable, trusted test framework for Node.js and the browser ☕️</p>
|
|
@@ -14,7 +14,7 @@ module.exports = function parseQuery(qs) {
|
|
|
14
14
|
.reduce(function (obj, pair) {
|
|
15
15
|
var i = pair.indexOf("=");
|
|
16
16
|
var key = pair.slice(0, i);
|
|
17
|
-
var val = pair.slice(
|
|
17
|
+
var val = pair.slice(i + 1);
|
|
18
18
|
|
|
19
19
|
// Due to how the URLSearchParams API treats spaces
|
|
20
20
|
obj[key] = decodeURIComponent(val.replace(/\+/g, "%20"));
|
package/lib/cli/config.js
CHANGED
|
@@ -66,7 +66,7 @@ const parsers = (exports.parsers = {
|
|
|
66
66
|
* @returns {Object} Parsed config object
|
|
67
67
|
*/
|
|
68
68
|
exports.loadConfig = (filepath) => {
|
|
69
|
-
let config
|
|
69
|
+
let config;
|
|
70
70
|
debug("loadConfig: trying to parse config at %s", filepath);
|
|
71
71
|
|
|
72
72
|
const ext = path.extname(filepath);
|
package/lib/context.js
CHANGED
package/lib/hook.js
CHANGED
|
@@ -1,89 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var Runnable = require("./runnable");
|
|
4
|
-
const {
|
|
4
|
+
const { constants } = require("./utils");
|
|
5
5
|
const { MOCHA_ID_PROP_NAME } = constants;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @param {Function} fn
|
|
20
|
-
*/
|
|
21
|
-
function Hook(title, fn) {
|
|
22
|
-
Runnable.call(this, title, fn);
|
|
23
|
-
this.type = "hook";
|
|
24
|
-
}
|
|
7
|
+
class Hook extends Runnable {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize a new `Hook` with the given `title` and callback `fn`
|
|
10
|
+
*
|
|
11
|
+
* @extends Runnable
|
|
12
|
+
* @param {String} title
|
|
13
|
+
* @param {Function} fn
|
|
14
|
+
*/
|
|
15
|
+
constructor(title, fn) {
|
|
16
|
+
super(title, fn);
|
|
17
|
+
this.type = "hook";
|
|
18
|
+
}
|
|
25
19
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Resets the state for a next run.
|
|
22
|
+
*/
|
|
23
|
+
reset() {
|
|
24
|
+
super.reset(this);
|
|
25
|
+
delete this._error;
|
|
26
|
+
}
|
|
30
27
|
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* Get or set the test `err`.
|
|
30
|
+
*
|
|
31
|
+
* @memberof Hook
|
|
32
|
+
* @public
|
|
33
|
+
* @param {Error} err
|
|
34
|
+
* @return {Error}
|
|
35
|
+
*/
|
|
36
|
+
error(err) {
|
|
37
|
+
if (!arguments.length) {
|
|
38
|
+
err = this._error;
|
|
39
|
+
this._error = null;
|
|
40
|
+
return err;
|
|
41
|
+
}
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
* Get or set the test `err`.
|
|
41
|
-
*
|
|
42
|
-
* @memberof Hook
|
|
43
|
-
* @public
|
|
44
|
-
* @param {Error} err
|
|
45
|
-
* @return {Error}
|
|
46
|
-
*/
|
|
47
|
-
Hook.prototype.error = function (err) {
|
|
48
|
-
if (!arguments.length) {
|
|
49
|
-
err = this._error;
|
|
50
|
-
this._error = null;
|
|
51
|
-
return err;
|
|
43
|
+
this._error = err;
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Returns an object suitable for IPC.
|
|
48
|
+
* Functions are represented by keys beginning with `$$`.
|
|
49
|
+
* @private
|
|
50
|
+
* @returns {Object}
|
|
51
|
+
*/
|
|
52
|
+
serialize() {
|
|
53
|
+
return {
|
|
54
|
+
$$currentRetry: this.currentRetry(),
|
|
55
|
+
$$fullTitle: this.fullTitle(),
|
|
56
|
+
$$isPending: Boolean(this.isPending()),
|
|
57
|
+
$$titlePath: this.titlePath(),
|
|
58
|
+
ctx:
|
|
59
|
+
this.ctx && this.ctx.currentTest
|
|
60
|
+
? {
|
|
61
|
+
currentTest: {
|
|
62
|
+
title: this.ctx.currentTest.title,
|
|
63
|
+
[MOCHA_ID_PROP_NAME]: this.ctx.currentTest.id,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
: {},
|
|
67
|
+
duration: this.duration,
|
|
68
|
+
file: this.file,
|
|
69
|
+
parent: {
|
|
70
|
+
$$fullTitle: this.parent.fullTitle(),
|
|
71
|
+
[MOCHA_ID_PROP_NAME]: this.parent.id,
|
|
72
|
+
},
|
|
73
|
+
state: this.state,
|
|
74
|
+
title: this.title,
|
|
75
|
+
type: this.type,
|
|
76
|
+
[MOCHA_ID_PROP_NAME]: this.id,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
56
80
|
|
|
57
|
-
|
|
58
|
-
* Returns an object suitable for IPC.
|
|
59
|
-
* Functions are represented by keys beginning with `$$`.
|
|
60
|
-
* @private
|
|
61
|
-
* @returns {Object}
|
|
62
|
-
*/
|
|
63
|
-
Hook.prototype.serialize = function serialize() {
|
|
64
|
-
return {
|
|
65
|
-
$$currentRetry: this.currentRetry(),
|
|
66
|
-
$$fullTitle: this.fullTitle(),
|
|
67
|
-
$$isPending: Boolean(this.isPending()),
|
|
68
|
-
$$titlePath: this.titlePath(),
|
|
69
|
-
ctx:
|
|
70
|
-
this.ctx && this.ctx.currentTest
|
|
71
|
-
? {
|
|
72
|
-
currentTest: {
|
|
73
|
-
title: this.ctx.currentTest.title,
|
|
74
|
-
[MOCHA_ID_PROP_NAME]: this.ctx.currentTest.id,
|
|
75
|
-
},
|
|
76
|
-
}
|
|
77
|
-
: {},
|
|
78
|
-
duration: this.duration,
|
|
79
|
-
file: this.file,
|
|
80
|
-
parent: {
|
|
81
|
-
$$fullTitle: this.parent.fullTitle(),
|
|
82
|
-
[MOCHA_ID_PROP_NAME]: this.parent.id,
|
|
83
|
-
},
|
|
84
|
-
state: this.state,
|
|
85
|
-
title: this.title,
|
|
86
|
-
type: this.type,
|
|
87
|
-
[MOCHA_ID_PROP_NAME]: this.id,
|
|
88
|
-
};
|
|
89
|
-
};
|
|
81
|
+
module.exports = Hook;
|
|
@@ -22,9 +22,8 @@ const { createMap, constants } = require("../utils");
|
|
|
22
22
|
const { MOCHA_ID_PROP_NAME } = constants;
|
|
23
23
|
const { createFatalError } = require("../errors");
|
|
24
24
|
|
|
25
|
-
const DEFAULT_WORKER_REPORTER =
|
|
26
|
-
"./reporters/parallel-buffered"
|
|
27
|
-
);
|
|
25
|
+
const DEFAULT_WORKER_REPORTER =
|
|
26
|
+
require.resolve("./reporters/parallel-buffered");
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* List of options to _not_ serialize for transmission to workers
|
package/lib/pending.js
CHANGED
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
@module Pending
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
module.exports = Pending;
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
|
-
* Initialize a new `
|
|
8
|
+
* Initialize a new `PendingError` error with the given message.
|
|
11
9
|
*
|
|
12
10
|
* @param {string} message
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
class PendingError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "PendingError";
|
|
16
|
+
}
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
module.exports = PendingError;
|
package/lib/reporters/base.js
CHANGED
|
@@ -31,12 +31,6 @@ function getBrowserWindowSize() {
|
|
|
31
31
|
return [640, 480];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Expose `Base`.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
exports = module.exports = Base;
|
|
39
|
-
|
|
40
34
|
/**
|
|
41
35
|
* Check if both stdio streams are associated with a tty.
|
|
42
36
|
*/
|
|
@@ -49,9 +43,109 @@ var isatty = isBrowser || (process.stdout.isTTY && process.stderr.isTTY);
|
|
|
49
43
|
var consoleLog = console.log;
|
|
50
44
|
|
|
51
45
|
/**
|
|
52
|
-
*
|
|
46
|
+
* @abstract
|
|
47
|
+
* @description
|
|
48
|
+
* All other reporters generally inherit from this reporter.
|
|
53
49
|
*/
|
|
50
|
+
class Base {
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a new `Base` reporter instance.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @memberof Mocha.reporters
|
|
56
|
+
* @param {Runner} runner - Instance triggers reporter actions.
|
|
57
|
+
* @param {Object} [options] - runner options
|
|
58
|
+
*/
|
|
59
|
+
constructor(runner, options) {
|
|
60
|
+
var failures = (this.failures = []);
|
|
61
|
+
|
|
62
|
+
if (!runner) {
|
|
63
|
+
throw new TypeError("Missing runner argument");
|
|
64
|
+
}
|
|
65
|
+
this.options = options || {};
|
|
66
|
+
this.runner = runner;
|
|
67
|
+
this.stats = runner.stats; // assigned so Reporters keep a closer reference
|
|
68
|
+
|
|
69
|
+
var maxDiffSizeOpt =
|
|
70
|
+
this.options.reporterOption && this.options.reporterOption.maxDiffSize;
|
|
71
|
+
if (maxDiffSizeOpt !== undefined && !isNaN(Number(maxDiffSizeOpt))) {
|
|
72
|
+
exports.maxDiffSize = Number(maxDiffSizeOpt);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
76
|
+
if (test.duration > test.slow()) {
|
|
77
|
+
test.speed = "slow";
|
|
78
|
+
} else if (test.duration > test.slow() / 2) {
|
|
79
|
+
test.speed = "medium";
|
|
80
|
+
} else {
|
|
81
|
+
test.speed = "fast";
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
runner.on(EVENT_TEST_FAIL, function (test, err) {
|
|
86
|
+
if (showDiff(err)) {
|
|
87
|
+
stringifyDiffObjs(err);
|
|
88
|
+
}
|
|
89
|
+
// more than one error per test
|
|
90
|
+
if (test.err && err instanceof Error) {
|
|
91
|
+
test.err.multiple = (test.err.multiple || []).concat(err);
|
|
92
|
+
} else {
|
|
93
|
+
test.err = err;
|
|
94
|
+
}
|
|
95
|
+
failures.push(test);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Outputs common epilogue used by many of the bundled reporters.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
* @memberof Mocha.reporters
|
|
104
|
+
*/
|
|
105
|
+
epilogue() {
|
|
106
|
+
var stats = this.stats;
|
|
107
|
+
var fmt;
|
|
108
|
+
|
|
109
|
+
Base.consoleLog();
|
|
110
|
+
|
|
111
|
+
// passes
|
|
112
|
+
fmt =
|
|
113
|
+
color("bright pass", " ") +
|
|
114
|
+
color("green", " %d passing") +
|
|
115
|
+
color("light", " (%s)");
|
|
116
|
+
|
|
117
|
+
Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration));
|
|
54
118
|
|
|
119
|
+
// pending
|
|
120
|
+
if (stats.pending) {
|
|
121
|
+
fmt = color("pending", " ") + color("pending", " %d pending");
|
|
122
|
+
|
|
123
|
+
Base.consoleLog(fmt, stats.pending);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// failures
|
|
127
|
+
if (stats.failures) {
|
|
128
|
+
fmt = color("fail", " %d failing");
|
|
129
|
+
|
|
130
|
+
Base.consoleLog(fmt, stats.failures);
|
|
131
|
+
|
|
132
|
+
Base.list(this.failures);
|
|
133
|
+
Base.consoleLog();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
Base.consoleLog();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
Base.consoleLog = consoleLog;
|
|
141
|
+
|
|
142
|
+
Base.abstract = true;
|
|
143
|
+
|
|
144
|
+
exports = module.exports = Base;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Enable coloring by default, except in the browser interface.
|
|
148
|
+
*/
|
|
55
149
|
exports.useColors =
|
|
56
150
|
!isBrowser &&
|
|
57
151
|
(supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
|
|
@@ -347,98 +441,6 @@ exports.list = function (failures) {
|
|
|
347
441
|
});
|
|
348
442
|
};
|
|
349
443
|
|
|
350
|
-
/**
|
|
351
|
-
* Constructs a new `Base` reporter instance.
|
|
352
|
-
*
|
|
353
|
-
* @description
|
|
354
|
-
* All other reporters generally inherit from this reporter.
|
|
355
|
-
*
|
|
356
|
-
* @public
|
|
357
|
-
* @class
|
|
358
|
-
* @memberof Mocha.reporters
|
|
359
|
-
* @param {Runner} runner - Instance triggers reporter actions.
|
|
360
|
-
* @param {Object} [options] - runner options
|
|
361
|
-
*/
|
|
362
|
-
function Base(runner, options) {
|
|
363
|
-
var failures = (this.failures = []);
|
|
364
|
-
|
|
365
|
-
if (!runner) {
|
|
366
|
-
throw new TypeError("Missing runner argument");
|
|
367
|
-
}
|
|
368
|
-
this.options = options || {};
|
|
369
|
-
this.runner = runner;
|
|
370
|
-
this.stats = runner.stats; // assigned so Reporters keep a closer reference
|
|
371
|
-
|
|
372
|
-
var maxDiffSizeOpt =
|
|
373
|
-
this.options.reporterOption && this.options.reporterOption.maxDiffSize;
|
|
374
|
-
if (maxDiffSizeOpt !== undefined && !isNaN(Number(maxDiffSizeOpt))) {
|
|
375
|
-
exports.maxDiffSize = Number(maxDiffSizeOpt);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
runner.on(EVENT_TEST_PASS, function (test) {
|
|
379
|
-
if (test.duration > test.slow()) {
|
|
380
|
-
test.speed = "slow";
|
|
381
|
-
} else if (test.duration > test.slow() / 2) {
|
|
382
|
-
test.speed = "medium";
|
|
383
|
-
} else {
|
|
384
|
-
test.speed = "fast";
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
runner.on(EVENT_TEST_FAIL, function (test, err) {
|
|
389
|
-
if (showDiff(err)) {
|
|
390
|
-
stringifyDiffObjs(err);
|
|
391
|
-
}
|
|
392
|
-
// more than one error per test
|
|
393
|
-
if (test.err && err instanceof Error) {
|
|
394
|
-
test.err.multiple = (test.err.multiple || []).concat(err);
|
|
395
|
-
} else {
|
|
396
|
-
test.err = err;
|
|
397
|
-
}
|
|
398
|
-
failures.push(test);
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Outputs common epilogue used by many of the bundled reporters.
|
|
404
|
-
*
|
|
405
|
-
* @public
|
|
406
|
-
* @memberof Mocha.reporters
|
|
407
|
-
*/
|
|
408
|
-
Base.prototype.epilogue = function () {
|
|
409
|
-
var stats = this.stats;
|
|
410
|
-
var fmt;
|
|
411
|
-
|
|
412
|
-
Base.consoleLog();
|
|
413
|
-
|
|
414
|
-
// passes
|
|
415
|
-
fmt =
|
|
416
|
-
color("bright pass", " ") +
|
|
417
|
-
color("green", " %d passing") +
|
|
418
|
-
color("light", " (%s)");
|
|
419
|
-
|
|
420
|
-
Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration));
|
|
421
|
-
|
|
422
|
-
// pending
|
|
423
|
-
if (stats.pending) {
|
|
424
|
-
fmt = color("pending", " ") + color("pending", " %d pending");
|
|
425
|
-
|
|
426
|
-
Base.consoleLog(fmt, stats.pending);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// failures
|
|
430
|
-
if (stats.failures) {
|
|
431
|
-
fmt = color("fail", " %d failing");
|
|
432
|
-
|
|
433
|
-
Base.consoleLog(fmt, stats.failures);
|
|
434
|
-
|
|
435
|
-
Base.list(this.failures);
|
|
436
|
-
Base.consoleLog();
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
Base.consoleLog();
|
|
440
|
-
};
|
|
441
|
-
|
|
442
444
|
/**
|
|
443
445
|
* Pads the given `str` to `len`.
|
|
444
446
|
*
|
|
@@ -469,7 +471,7 @@ function inlineDiff(actual, expected) {
|
|
|
469
471
|
var width = String(lines.length).length;
|
|
470
472
|
msg = lines
|
|
471
473
|
.map(function (str, i) {
|
|
472
|
-
return pad(
|
|
474
|
+
return pad(i + 1, width) + " |" + " " + str;
|
|
473
475
|
})
|
|
474
476
|
.join("\n");
|
|
475
477
|
}
|
|
@@ -585,7 +587,3 @@ var objToString = Object.prototype.toString;
|
|
|
585
587
|
function sameType(a, b) {
|
|
586
588
|
return objToString.call(a) === objToString.call(b);
|
|
587
589
|
}
|
|
588
|
-
|
|
589
|
-
Base.consoleLog = consoleLog;
|
|
590
|
-
|
|
591
|
-
Base.abstract = true;
|
package/lib/reporters/doc.js
CHANGED
|
@@ -19,82 +19,83 @@ var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
|
|
19
19
|
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
|
|
20
20
|
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
exports = module.exports = Doc;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Constructs a new `Doc` reporter instance.
|
|
30
|
-
*
|
|
31
|
-
* @public
|
|
32
|
-
* @class
|
|
33
|
-
* @memberof Mocha.reporters
|
|
34
|
-
* @extends Mocha.reporters.Base
|
|
35
|
-
* @param {Runner} runner - Instance triggers reporter actions.
|
|
36
|
-
* @param {Object} [options] - runner options
|
|
37
|
-
*/
|
|
38
|
-
function Doc(runner, options) {
|
|
39
|
-
Base.call(this, runner, options);
|
|
22
|
+
class Doc extends Base {
|
|
23
|
+
static description = "HTML documentation";
|
|
40
24
|
|
|
41
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new `Doc` reporter instance.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @memberof Mocha.reporters
|
|
30
|
+
* @extends Mocha.reporters.Base
|
|
31
|
+
* @param {Runner} runner - Instance triggers reporter actions.
|
|
32
|
+
* @param {Object} [options] - runner options
|
|
33
|
+
*/
|
|
34
|
+
constructor(runner, options) {
|
|
35
|
+
super(runner, options);
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
return Array(indents).join(" ");
|
|
45
|
-
}
|
|
37
|
+
var indents = 2;
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return;
|
|
39
|
+
function indent() {
|
|
40
|
+
return Array(indents).join(" ");
|
|
50
41
|
}
|
|
51
|
-
++indents;
|
|
52
|
-
Base.consoleLog('%s<section class="suite">', indent());
|
|
53
|
-
++indents;
|
|
54
|
-
Base.consoleLog("%s<h1>%s</h1>", indent(), utils.escape(suite.title));
|
|
55
|
-
Base.consoleLog("%s<dl>", indent());
|
|
56
|
-
});
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
43
|
+
runner.on(EVENT_SUITE_BEGIN, function (suite) {
|
|
44
|
+
if (suite.root) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
++indents;
|
|
48
|
+
Base.consoleLog('%s<section class="suite">', indent());
|
|
49
|
+
++indents;
|
|
50
|
+
Base.consoleLog("%s<h1>%s</h1>", indent(), utils.escape(suite.title));
|
|
51
|
+
Base.consoleLog("%s<dl>", indent());
|
|
52
|
+
});
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
runner.on(EVENT_SUITE_END, function (suite) {
|
|
55
|
+
if (suite.root) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
Base.consoleLog("%s</dl>", indent());
|
|
59
|
+
--indents;
|
|
60
|
+
Base.consoleLog("%s</section>", indent());
|
|
61
|
+
--indents;
|
|
62
|
+
});
|
|
74
63
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
64
|
+
runner.on(EVENT_TEST_PASS, function (test) {
|
|
65
|
+
Base.consoleLog("%s <dt>%s</dt>", indent(), utils.escape(test.title));
|
|
66
|
+
Base.consoleLog("%s <dt>%s</dt>", indent(), utils.escape(test.file));
|
|
67
|
+
var code = utils.escape(utils.clean(test.body));
|
|
68
|
+
Base.consoleLog(
|
|
69
|
+
"%s <dd><pre><code>%s</code></pre></dd>",
|
|
70
|
+
indent(),
|
|
71
|
+
code,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
runner.on(EVENT_TEST_FAIL, function (test, err) {
|
|
76
|
+
Base.consoleLog(
|
|
77
|
+
'%s <dt class="error">%s</dt>',
|
|
78
|
+
indent(),
|
|
79
|
+
utils.escape(test.title),
|
|
80
|
+
);
|
|
81
|
+
Base.consoleLog(
|
|
82
|
+
'%s <dt class="error">%s</dt>',
|
|
83
|
+
indent(),
|
|
84
|
+
utils.escape(test.file),
|
|
85
|
+
);
|
|
86
|
+
var code = utils.escape(utils.clean(test.body));
|
|
87
|
+
Base.consoleLog(
|
|
88
|
+
'%s <dd class="error"><pre><code>%s</code></pre></dd>',
|
|
89
|
+
indent(),
|
|
90
|
+
code,
|
|
91
|
+
);
|
|
92
|
+
Base.consoleLog(
|
|
93
|
+
'%s <dd class="error">%s</dd>',
|
|
94
|
+
indent(),
|
|
95
|
+
utils.escape(err),
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
exports = module.exports = Doc;
|