mocha 11.7.4 → 11.7.6
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/bin/_mocha +2 -2
- package/bin/mocha.js +46 -44
- package/browser-entry.js +20 -20
- package/index.js +2 -2
- package/lib/browser/highlight-tags.js +6 -6
- package/lib/browser/parse-query.js +5 -5
- package/lib/browser/template.html +2 -2
- package/lib/cli/cli.js +32 -27
- package/lib/cli/collect-files.js +25 -25
- package/lib/cli/commands.js +4 -4
- package/lib/cli/config.js +26 -25
- package/lib/cli/index.js +2 -2
- package/lib/cli/init.js +19 -19
- package/lib/cli/lookup-files.js +20 -20
- package/lib/cli/node-flags.js +12 -12
- package/lib/cli/one-and-dones.js +12 -11
- package/lib/cli/options.js +49 -49
- package/lib/cli/run-helpers.js +52 -54
- package/lib/cli/run-option-metadata.js +75 -75
- package/lib/cli/run.js +164 -159
- package/lib/cli/watch-run.js +75 -75
- package/lib/context.js +1 -1
- package/lib/error-constants.js +17 -17
- package/lib/errors.js +26 -26
- package/lib/hook.js +9 -9
- package/lib/interfaces/bdd.js +8 -8
- package/lib/interfaces/common.js +12 -12
- package/lib/interfaces/exports.js +8 -8
- package/lib/interfaces/index.js +5 -5
- package/lib/interfaces/qunit.js +7 -7
- package/lib/interfaces/tdd.js +7 -7
- package/lib/mocha.js +97 -97
- package/lib/nodejs/buffered-worker-pool.js +30 -30
- package/lib/nodejs/esm-utils.js +24 -21
- package/lib/nodejs/file-unloader.js +2 -2
- package/lib/nodejs/parallel-buffered-runner.js +67 -67
- package/lib/nodejs/reporters/parallel-buffered.js +13 -10
- package/lib/nodejs/serializer.js +47 -47
- package/lib/nodejs/worker.js +38 -38
- package/lib/pending.js +1 -1
- package/lib/plugin-loader.js +48 -48
- package/lib/reporters/base.js +97 -94
- package/lib/reporters/doc.js +17 -17
- package/lib/reporters/dot.js +14 -14
- package/lib/reporters/html.js +73 -67
- package/lib/reporters/index.js +16 -16
- package/lib/reporters/json-stream.js +10 -10
- package/lib/reporters/json.js +16 -16
- package/lib/reporters/landing.js +20 -20
- package/lib/reporters/list.js +10 -10
- package/lib/reporters/markdown.js +21 -21
- package/lib/reporters/min.js +7 -7
- package/lib/reporters/nyan.js +35 -35
- package/lib/reporters/progress.js +14 -14
- package/lib/reporters/spec.js +15 -15
- package/lib/reporters/tap.js +26 -26
- package/lib/reporters/xunit.js +38 -34
- package/lib/runnable.js +41 -41
- package/lib/runner.js +105 -105
- package/lib/stats-collector.js +4 -4
- package/lib/suite.js +56 -46
- package/lib/test.js +10 -10
- package/lib/utils.js +122 -122
- package/mocha.css +68 -50
- package/mocha.js +826 -803
- package/mocha.js.map +1 -1
- package/package.json +8 -13
package/lib/reporters/json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var fs = require(
|
|
16
|
-
var path = require(
|
|
17
|
-
const createUnsupportedError = require(
|
|
18
|
-
const utils = require(
|
|
19
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var fs = require("node:fs");
|
|
16
|
+
var path = require("node:path");
|
|
17
|
+
const createUnsupportedError = require("../errors").createUnsupportedError;
|
|
18
|
+
const utils = require("../utils");
|
|
19
|
+
var constants = require("../runner").constants;
|
|
20
20
|
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
21
21
|
var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
|
22
22
|
var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
|
@@ -51,7 +51,7 @@ function JSONReporter(runner, options = {}) {
|
|
|
51
51
|
|
|
52
52
|
if (options.reporterOption && options.reporterOption.output) {
|
|
53
53
|
if (utils.isBrowser()) {
|
|
54
|
-
throw createUnsupportedError(
|
|
54
|
+
throw createUnsupportedError("file output not supported in browser");
|
|
55
55
|
}
|
|
56
56
|
output = options.reporterOption.output;
|
|
57
57
|
}
|
|
@@ -78,7 +78,7 @@ function JSONReporter(runner, options = {}) {
|
|
|
78
78
|
tests: tests.map(clean),
|
|
79
79
|
pending: pending.map(clean),
|
|
80
80
|
failures: failures.map(clean),
|
|
81
|
-
passes: passes.map(clean)
|
|
81
|
+
passes: passes.map(clean),
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
runner.testResults = obj;
|
|
@@ -86,11 +86,11 @@ function JSONReporter(runner, options = {}) {
|
|
|
86
86
|
var json = JSON.stringify(obj, null, 2);
|
|
87
87
|
if (output) {
|
|
88
88
|
try {
|
|
89
|
-
fs.mkdirSync(path.dirname(output), {recursive: true});
|
|
89
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
90
90
|
fs.writeFileSync(output, json);
|
|
91
91
|
} catch (err) {
|
|
92
92
|
console.error(
|
|
93
|
-
`${Base.symbols.err} [mocha] writing output to "${output}" failed: ${err.message}\n
|
|
93
|
+
`${Base.symbols.err} [mocha] writing output to "${output}" failed: ${err.message}\n`,
|
|
94
94
|
);
|
|
95
95
|
process.stdout.write(json);
|
|
96
96
|
}
|
|
@@ -121,7 +121,7 @@ function clean(test) {
|
|
|
121
121
|
duration: test.duration,
|
|
122
122
|
currentRetry: test.currentRetry(),
|
|
123
123
|
speed: test.speed,
|
|
124
|
-
err: cleanCycles(err)
|
|
124
|
+
err: cleanCycles(err),
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -136,16 +136,16 @@ function cleanCycles(obj) {
|
|
|
136
136
|
var cache = [];
|
|
137
137
|
return JSON.parse(
|
|
138
138
|
JSON.stringify(obj, function (key, value) {
|
|
139
|
-
if (typeof value ===
|
|
139
|
+
if (typeof value === "object" && value !== null) {
|
|
140
140
|
if (cache.indexOf(value) !== -1) {
|
|
141
141
|
// Instead of going in a circle, we'll print [object Object]
|
|
142
|
-
return
|
|
142
|
+
return "" + value;
|
|
143
143
|
}
|
|
144
144
|
cache.push(value);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return value;
|
|
148
|
-
})
|
|
148
|
+
}),
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -164,4 +164,4 @@ function errorJSON(err) {
|
|
|
164
164
|
return res;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
JSONReporter.description =
|
|
167
|
+
JSONReporter.description = "single JSON object";
|
package/lib/reporters/landing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var inherits = require(
|
|
16
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var inherits = require("../utils").inherits;
|
|
16
|
+
var constants = require("../runner").constants;
|
|
17
17
|
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
18
18
|
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
19
19
|
var EVENT_TEST_END = constants.EVENT_TEST_END;
|
|
20
|
-
var STATE_FAILED = require(
|
|
20
|
+
var STATE_FAILED = require("../runnable").constants.STATE_FAILED;
|
|
21
21
|
|
|
22
22
|
var cursor = Base.cursor;
|
|
23
23
|
var color = Base.color;
|
|
@@ -38,7 +38,7 @@ Base.colors.plane = 0;
|
|
|
38
38
|
* Airplane crash color.
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
|
-
Base.colors[
|
|
41
|
+
Base.colors["plane crash"] = 31;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Runway color.
|
|
@@ -63,18 +63,18 @@ function Landing(runner, options) {
|
|
|
63
63
|
var width = (Base.window.width * 0.75) | 0;
|
|
64
64
|
var stream = process.stdout;
|
|
65
65
|
|
|
66
|
-
var plane = color(
|
|
66
|
+
var plane = color("plane", "✈");
|
|
67
67
|
var crashed = -1;
|
|
68
68
|
var n = 0;
|
|
69
69
|
var total = 0;
|
|
70
70
|
|
|
71
71
|
function runway() {
|
|
72
|
-
var buf = Array(width).join(
|
|
73
|
-
return
|
|
72
|
+
var buf = Array(width).join("-");
|
|
73
|
+
return " " + color("runway", buf);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
runner.on(EVENT_RUN_BEGIN, function () {
|
|
77
|
-
stream.write(
|
|
77
|
+
stream.write("\n\n\n ");
|
|
78
78
|
cursor.hide();
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -83,32 +83,32 @@ function Landing(runner, options) {
|
|
|
83
83
|
var col = crashed === -1 ? ((width * ++n) / ++total) | 0 : crashed;
|
|
84
84
|
// show the crash
|
|
85
85
|
if (test.state === STATE_FAILED) {
|
|
86
|
-
plane = color(
|
|
86
|
+
plane = color("plane crash", "✈");
|
|
87
87
|
crashed = col;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// render landing strip
|
|
91
|
-
stream.write(
|
|
91
|
+
stream.write("\u001b[" + (width + 1) + "D\u001b[2A");
|
|
92
92
|
stream.write(runway());
|
|
93
|
-
stream.write(
|
|
94
|
-
stream.write(color(
|
|
93
|
+
stream.write("\n ");
|
|
94
|
+
stream.write(color("runway", Array(col).join("⋅")));
|
|
95
95
|
stream.write(plane);
|
|
96
|
-
stream.write(color(
|
|
96
|
+
stream.write(color("runway", Array(width - col).join("⋅") + "\n"));
|
|
97
97
|
stream.write(runway());
|
|
98
|
-
stream.write(
|
|
98
|
+
stream.write("\u001b[0m");
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
runner.once(EVENT_RUN_END, function () {
|
|
102
102
|
cursor.show();
|
|
103
|
-
process.stdout.write(
|
|
103
|
+
process.stdout.write("\n");
|
|
104
104
|
self.epilogue();
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
// if cursor is hidden when we ctrl-C, then it will remain hidden unless...
|
|
108
|
-
process.once(
|
|
108
|
+
process.once("SIGINT", function () {
|
|
109
109
|
cursor.show();
|
|
110
110
|
process.nextTick(function () {
|
|
111
|
-
process.kill(process.pid,
|
|
111
|
+
process.kill(process.pid, "SIGINT");
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -118,4 +118,4 @@ function Landing(runner, options) {
|
|
|
118
118
|
*/
|
|
119
119
|
inherits(Landing, Base);
|
|
120
120
|
|
|
121
|
-
Landing.description =
|
|
121
|
+
Landing.description = "Unicode landing strip";
|
package/lib/reporters/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var inherits = require(
|
|
16
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var inherits = require("../utils").inherits;
|
|
16
|
+
var constants = require("../runner").constants;
|
|
17
17
|
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
18
18
|
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
19
19
|
var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN;
|
|
@@ -50,26 +50,26 @@ function List(runner, options) {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
runner.on(EVENT_TEST_BEGIN, function (test) {
|
|
53
|
-
process.stdout.write(color(
|
|
53
|
+
process.stdout.write(color("pass", " " + test.fullTitle() + ": "));
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
runner.on(EVENT_TEST_PENDING, function (test) {
|
|
57
|
-
var fmt = color(
|
|
57
|
+
var fmt = color("checkmark", " -") + color("pending", " %s");
|
|
58
58
|
Base.consoleLog(fmt, test.fullTitle());
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
runner.on(EVENT_TEST_PASS, function (test) {
|
|
62
62
|
var fmt =
|
|
63
|
-
color(
|
|
64
|
-
color(
|
|
65
|
-
color(test.speed,
|
|
63
|
+
color("checkmark", " " + Base.symbols.ok) +
|
|
64
|
+
color("pass", " %s: ") +
|
|
65
|
+
color(test.speed, "%dms");
|
|
66
66
|
cursor.CR();
|
|
67
67
|
Base.consoleLog(fmt, test.fullTitle(), test.duration);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
runner.on(EVENT_TEST_FAIL, function (test) {
|
|
71
71
|
cursor.CR();
|
|
72
|
-
Base.consoleLog(color(
|
|
72
|
+
Base.consoleLog(color("fail", " %d) %s"), ++n, test.fullTitle());
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
runner.once(EVENT_RUN_END, self.epilogue.bind(self));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var utils = require(
|
|
16
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var utils = require("../utils");
|
|
16
|
+
var constants = require("../runner").constants;
|
|
17
17
|
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
18
18
|
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
|
|
19
19
|
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
|
|
@@ -23,7 +23,7 @@ var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
|
23
23
|
* Constants
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
var SUITE_PREFIX =
|
|
26
|
+
var SUITE_PREFIX = "$";
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Expose `Markdown`.
|
|
@@ -45,17 +45,17 @@ function Markdown(runner, options) {
|
|
|
45
45
|
Base.call(this, runner, options);
|
|
46
46
|
|
|
47
47
|
var level = 0;
|
|
48
|
-
var buf =
|
|
48
|
+
var buf = "";
|
|
49
49
|
|
|
50
50
|
function title(str) {
|
|
51
|
-
return Array(level).join(
|
|
51
|
+
return Array(level).join("#") + " " + str;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function mapTOC(suite, obj) {
|
|
55
55
|
var ret = obj;
|
|
56
56
|
var key = SUITE_PREFIX + suite.title;
|
|
57
57
|
|
|
58
|
-
obj = obj[key] = obj[key] || {suite};
|
|
58
|
+
obj = obj[key] = obj[key] || { suite };
|
|
59
59
|
suite.suites.forEach(function (suite) {
|
|
60
60
|
mapTOC(suite, obj);
|
|
61
61
|
});
|
|
@@ -65,16 +65,16 @@ function Markdown(runner, options) {
|
|
|
65
65
|
|
|
66
66
|
function stringifyTOC(obj, level) {
|
|
67
67
|
++level;
|
|
68
|
-
var buf =
|
|
68
|
+
var buf = "";
|
|
69
69
|
var link;
|
|
70
70
|
for (var key in obj) {
|
|
71
|
-
if (key ===
|
|
71
|
+
if (key === "suite") {
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
74
74
|
if (key !== SUITE_PREFIX) {
|
|
75
|
-
link =
|
|
76
|
-
link +=
|
|
77
|
-
buf += Array(level).join(
|
|
75
|
+
link = " - [" + key.substring(1) + "]";
|
|
76
|
+
link += "(#" + utils.slug(obj[key].suite.fullTitle()) + ")\n";
|
|
77
|
+
buf += Array(level).join(" ") + link;
|
|
78
78
|
}
|
|
79
79
|
buf += stringifyTOC(obj[key], level);
|
|
80
80
|
}
|
|
@@ -91,8 +91,8 @@ function Markdown(runner, options) {
|
|
|
91
91
|
runner.on(EVENT_SUITE_BEGIN, function (suite) {
|
|
92
92
|
++level;
|
|
93
93
|
var slug = utils.slug(suite.fullTitle());
|
|
94
|
-
buf += '<a name="' + slug + '"></a>' +
|
|
95
|
-
buf += title(suite.title) +
|
|
94
|
+
buf += '<a name="' + slug + '"></a>' + "\n";
|
|
95
|
+
buf += title(suite.title) + "\n";
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
runner.on(EVENT_SUITE_END, function () {
|
|
@@ -101,17 +101,17 @@ function Markdown(runner, options) {
|
|
|
101
101
|
|
|
102
102
|
runner.on(EVENT_TEST_PASS, function (test) {
|
|
103
103
|
var code = utils.clean(test.body);
|
|
104
|
-
buf += test.title +
|
|
105
|
-
buf +=
|
|
106
|
-
buf += code +
|
|
107
|
-
buf +=
|
|
104
|
+
buf += test.title + ".\n";
|
|
105
|
+
buf += "\n```js\n";
|
|
106
|
+
buf += code + "\n";
|
|
107
|
+
buf += "```\n\n";
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
runner.once(EVENT_RUN_END, function () {
|
|
111
|
-
process.stdout.write(
|
|
111
|
+
process.stdout.write("# TOC\n");
|
|
112
112
|
process.stdout.write(generateTOC(runner.suite));
|
|
113
113
|
process.stdout.write(buf);
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
Markdown.description =
|
|
117
|
+
Markdown.description = "GitHub Flavored Markdown";
|
package/lib/reporters/min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var inherits = require(
|
|
16
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var inherits = require("../utils").inherits;
|
|
16
|
+
var constants = require("../runner").constants;
|
|
17
17
|
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
18
18
|
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
19
19
|
|
|
@@ -41,9 +41,9 @@ function Min(runner, options) {
|
|
|
41
41
|
|
|
42
42
|
runner.on(EVENT_RUN_BEGIN, function () {
|
|
43
43
|
// clear screen
|
|
44
|
-
process.stdout.write(
|
|
44
|
+
process.stdout.write("\u001b[2J");
|
|
45
45
|
// set cursor position
|
|
46
|
-
process.stdout.write(
|
|
46
|
+
process.stdout.write("\u001b[1;3H");
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
runner.once(EVENT_RUN_END, this.epilogue.bind(this));
|
|
@@ -54,4 +54,4 @@ function Min(runner, options) {
|
|
|
54
54
|
*/
|
|
55
55
|
inherits(Min, Base);
|
|
56
56
|
|
|
57
|
-
Min.description =
|
|
57
|
+
Min.description = "essentially just a summary";
|
package/lib/reporters/nyan.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var constants = require(
|
|
16
|
-
var inherits = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var constants = require("../runner").constants;
|
|
16
|
+
var inherits = require("../utils").inherits;
|
|
17
17
|
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
18
18
|
var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
|
19
19
|
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
|
@@ -71,7 +71,7 @@ function NyanCat(runner, options) {
|
|
|
71
71
|
runner.once(EVENT_RUN_END, function () {
|
|
72
72
|
Base.cursor.show();
|
|
73
73
|
for (var i = 0; i < self.numberOfLines; i++) {
|
|
74
|
-
process.stdout.write(
|
|
74
|
+
process.stdout.write("\n");
|
|
75
75
|
}
|
|
76
76
|
self.epilogue();
|
|
77
77
|
});
|
|
@@ -107,15 +107,15 @@ NyanCat.prototype.drawScoreboard = function () {
|
|
|
107
107
|
var stats = this.stats;
|
|
108
108
|
|
|
109
109
|
function draw(type, n) {
|
|
110
|
-
process.stdout.write(
|
|
110
|
+
process.stdout.write(" ");
|
|
111
111
|
process.stdout.write(Base.color(type, n));
|
|
112
|
-
process.stdout.write(
|
|
112
|
+
process.stdout.write("\n");
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
draw(
|
|
116
|
-
draw(
|
|
117
|
-
draw(
|
|
118
|
-
process.stdout.write(
|
|
115
|
+
draw("green", stats.passes);
|
|
116
|
+
draw("fail", stats.failures);
|
|
117
|
+
draw("pending", stats.pending);
|
|
118
|
+
process.stdout.write("\n");
|
|
119
119
|
|
|
120
120
|
this.cursorUp(this.numberOfLines);
|
|
121
121
|
};
|
|
@@ -127,7 +127,7 @@ NyanCat.prototype.drawScoreboard = function () {
|
|
|
127
127
|
*/
|
|
128
128
|
|
|
129
129
|
NyanCat.prototype.appendRainbow = function () {
|
|
130
|
-
var segment = this.tick ?
|
|
130
|
+
var segment = this.tick ? "_" : "-";
|
|
131
131
|
var rainbowified = this.rainbowify(segment);
|
|
132
132
|
|
|
133
133
|
for (var index = 0; index < this.numberOfLines; index++) {
|
|
@@ -149,9 +149,9 @@ NyanCat.prototype.drawRainbow = function () {
|
|
|
149
149
|
var self = this;
|
|
150
150
|
|
|
151
151
|
this.trajectories.forEach(function (line) {
|
|
152
|
-
process.stdout.write(
|
|
153
|
-
process.stdout.write(line.join(
|
|
154
|
-
process.stdout.write(
|
|
152
|
+
process.stdout.write("\u001b[" + self.scoreboardWidth + "C");
|
|
153
|
+
process.stdout.write(line.join(""));
|
|
154
|
+
process.stdout.write("\n");
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
this.cursorUp(this.numberOfLines);
|
|
@@ -165,28 +165,28 @@ NyanCat.prototype.drawRainbow = function () {
|
|
|
165
165
|
NyanCat.prototype.drawNyanCat = function () {
|
|
166
166
|
var self = this;
|
|
167
167
|
var startWidth = this.scoreboardWidth + this.trajectories[0].length;
|
|
168
|
-
var dist =
|
|
169
|
-
var padding =
|
|
168
|
+
var dist = "\u001b[" + startWidth + "C";
|
|
169
|
+
var padding = "";
|
|
170
170
|
|
|
171
171
|
process.stdout.write(dist);
|
|
172
|
-
process.stdout.write(
|
|
173
|
-
process.stdout.write(
|
|
172
|
+
process.stdout.write("_,------,");
|
|
173
|
+
process.stdout.write("\n");
|
|
174
174
|
|
|
175
175
|
process.stdout.write(dist);
|
|
176
|
-
padding = self.tick ?
|
|
177
|
-
process.stdout.write(
|
|
178
|
-
process.stdout.write(
|
|
176
|
+
padding = self.tick ? " " : " ";
|
|
177
|
+
process.stdout.write("_|" + padding + "/\\_/\\ ");
|
|
178
|
+
process.stdout.write("\n");
|
|
179
179
|
|
|
180
180
|
process.stdout.write(dist);
|
|
181
|
-
padding = self.tick ?
|
|
182
|
-
var tail = self.tick ?
|
|
183
|
-
process.stdout.write(tail +
|
|
184
|
-
process.stdout.write(
|
|
181
|
+
padding = self.tick ? "_" : "__";
|
|
182
|
+
var tail = self.tick ? "~" : "^";
|
|
183
|
+
process.stdout.write(tail + "|" + padding + this.face() + " ");
|
|
184
|
+
process.stdout.write("\n");
|
|
185
185
|
|
|
186
186
|
process.stdout.write(dist);
|
|
187
|
-
padding = self.tick ?
|
|
187
|
+
padding = self.tick ? " " : " ";
|
|
188
188
|
process.stdout.write(padding + '"" "" ');
|
|
189
|
-
process.stdout.write(
|
|
189
|
+
process.stdout.write("\n");
|
|
190
190
|
|
|
191
191
|
this.cursorUp(this.numberOfLines);
|
|
192
192
|
};
|
|
@@ -201,13 +201,13 @@ NyanCat.prototype.drawNyanCat = function () {
|
|
|
201
201
|
NyanCat.prototype.face = function () {
|
|
202
202
|
var stats = this.stats;
|
|
203
203
|
if (stats.failures) {
|
|
204
|
-
return
|
|
204
|
+
return "( x .x)";
|
|
205
205
|
} else if (stats.pending) {
|
|
206
|
-
return
|
|
206
|
+
return "( o .o)";
|
|
207
207
|
} else if (stats.passes) {
|
|
208
|
-
return
|
|
208
|
+
return "( ^ .^)";
|
|
209
209
|
}
|
|
210
|
-
return
|
|
210
|
+
return "( - .-)";
|
|
211
211
|
};
|
|
212
212
|
|
|
213
213
|
/**
|
|
@@ -218,7 +218,7 @@ NyanCat.prototype.face = function () {
|
|
|
218
218
|
*/
|
|
219
219
|
|
|
220
220
|
NyanCat.prototype.cursorUp = function (n) {
|
|
221
|
-
process.stdout.write(
|
|
221
|
+
process.stdout.write("\u001b[" + n + "A");
|
|
222
222
|
};
|
|
223
223
|
|
|
224
224
|
/**
|
|
@@ -229,7 +229,7 @@ NyanCat.prototype.cursorUp = function (n) {
|
|
|
229
229
|
*/
|
|
230
230
|
|
|
231
231
|
NyanCat.prototype.cursorDown = function (n) {
|
|
232
|
-
process.stdout.write(
|
|
232
|
+
process.stdout.write("\u001b[" + n + "B");
|
|
233
233
|
};
|
|
234
234
|
|
|
235
235
|
/**
|
|
@@ -266,7 +266,7 @@ NyanCat.prototype.rainbowify = function (str) {
|
|
|
266
266
|
}
|
|
267
267
|
var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
|
|
268
268
|
this.colorIndex += 1;
|
|
269
|
-
return
|
|
269
|
+
return "\u001b[38;5;" + color + "m" + str + "\u001b[0m";
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
NyanCat.description = '"nyan cat"';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../runner.js')} Runner
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
* Module dependencies.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var Base = require(
|
|
15
|
-
var constants = require(
|
|
14
|
+
var Base = require("./base");
|
|
15
|
+
var constants = require("../runner").constants;
|
|
16
16
|
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
|
17
17
|
var EVENT_TEST_END = constants.EVENT_TEST_END;
|
|
18
18
|
var EVENT_RUN_END = constants.EVENT_RUN_END;
|
|
19
|
-
var inherits = require(
|
|
19
|
+
var inherits = require("../utils").inherits;
|
|
20
20
|
var color = Base.color;
|
|
21
21
|
var cursor = Base.cursor;
|
|
22
22
|
|
|
@@ -55,15 +55,15 @@ function Progress(runner, options) {
|
|
|
55
55
|
options = options || {};
|
|
56
56
|
var reporterOptions = options.reporterOptions || {};
|
|
57
57
|
|
|
58
|
-
options.open = reporterOptions.open ||
|
|
59
|
-
options.complete = reporterOptions.complete ||
|
|
58
|
+
options.open = reporterOptions.open || "[";
|
|
59
|
+
options.complete = reporterOptions.complete || "▬";
|
|
60
60
|
options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
|
|
61
|
-
options.close = reporterOptions.close ||
|
|
61
|
+
options.close = reporterOptions.close || "]";
|
|
62
62
|
options.verbose = reporterOptions.verbose || false;
|
|
63
63
|
|
|
64
64
|
// tests started
|
|
65
65
|
runner.on(EVENT_RUN_BEGIN, function () {
|
|
66
|
-
process.stdout.write(
|
|
66
|
+
process.stdout.write("\n");
|
|
67
67
|
cursor.hide();
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -82,13 +82,13 @@ function Progress(runner, options) {
|
|
|
82
82
|
lastN = n;
|
|
83
83
|
|
|
84
84
|
cursor.CR();
|
|
85
|
-
process.stdout.write(
|
|
86
|
-
process.stdout.write(color(
|
|
85
|
+
process.stdout.write("\u001b[J");
|
|
86
|
+
process.stdout.write(color("progress", " " + options.open));
|
|
87
87
|
process.stdout.write(Array(n).join(options.complete));
|
|
88
88
|
process.stdout.write(Array(i).join(options.incomplete));
|
|
89
|
-
process.stdout.write(color(
|
|
89
|
+
process.stdout.write(color("progress", options.close));
|
|
90
90
|
if (options.verbose) {
|
|
91
|
-
process.stdout.write(color(
|
|
91
|
+
process.stdout.write(color("progress", " " + complete + " of " + total));
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -96,7 +96,7 @@ function Progress(runner, options) {
|
|
|
96
96
|
// and the failures if any
|
|
97
97
|
runner.once(EVENT_RUN_END, function () {
|
|
98
98
|
cursor.show();
|
|
99
|
-
process.stdout.write(
|
|
99
|
+
process.stdout.write("\n");
|
|
100
100
|
self.epilogue();
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -106,4 +106,4 @@ function Progress(runner, options) {
|
|
|
106
106
|
*/
|
|
107
107
|
inherits(Progress, Base);
|
|
108
108
|
|
|
109
|
-
Progress.description =
|
|
109
|
+
Progress.description = "a progress bar";
|