elit 3.6.5 → 3.6.7
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +6 -0
- package/dist/build.cjs +421 -331
- package/dist/build.d.ts +1 -16
- package/dist/build.js +420 -330
- package/dist/build.mjs +420 -330
- package/dist/chokidar.cjs +219 -182
- package/dist/chokidar.d.ts +25 -10
- package/dist/chokidar.js +217 -182
- package/dist/chokidar.mjs +218 -183
- package/dist/cli.cjs +21608 -20241
- package/dist/cli.d.ts +19 -37
- package/dist/cli.mjs +21262 -19910
- package/dist/config.cjs +357 -350
- package/dist/config.d.ts +19 -240
- package/dist/config.js +520 -515
- package/dist/config.mjs +346 -341
- package/dist/contracts-BeW9k0yZ.d.ts +54 -0
- package/dist/contracts-D7KIS-TK.d.ts +36 -0
- package/dist/coverage.cjs +448 -485
- package/dist/coverage.d.ts +13 -59
- package/dist/coverage.js +447 -484
- package/dist/coverage.mjs +447 -484
- package/dist/database.cjs +819 -828
- package/dist/database.d.ts +8 -24
- package/dist/database.js +818 -829
- package/dist/database.mjs +818 -829
- package/dist/desktop-auto-render.cjs +1700 -1522
- package/dist/desktop-auto-render.d.ts +4 -9
- package/dist/desktop-auto-render.js +1695 -1517
- package/dist/desktop-auto-render.mjs +1696 -1518
- package/dist/desktop.cjs +3 -1
- package/dist/desktop.d.ts +4 -1
- package/dist/desktop.js +1 -1
- package/dist/desktop.mjs +1 -1
- package/dist/dev-build.cjs +830 -0
- package/dist/dev-build.d.ts +53 -0
- package/dist/dev-build.js +3318 -0
- package/dist/dev-build.mjs +797 -0
- package/dist/dom.cjs +717 -590
- package/dist/dom.d.ts +2 -15
- package/dist/dom.js +714 -587
- package/dist/dom.mjs +716 -589
- package/dist/el.cjs +62 -52
- package/dist/el.d.ts +5 -10
- package/dist/el.js +60 -52
- package/dist/el.mjs +60 -52
- package/dist/fs.cjs +72 -63
- package/dist/fs.d.ts +22 -19
- package/dist/fs.js +71 -62
- package/dist/fs.mjs +71 -62
- package/dist/hmr.cjs +40 -14
- package/dist/hmr.d.ts +11 -23
- package/dist/hmr.js +38 -14
- package/dist/hmr.mjs +38 -14
- package/dist/http.cjs +251 -99
- package/dist/http.d.ts +38 -104
- package/dist/http.js +249 -99
- package/dist/http.mjs +249 -99
- package/dist/https.cjs +524 -228
- package/dist/https.d.ts +44 -36
- package/dist/https.js +520 -226
- package/dist/https.mjs +522 -228
- package/dist/index.cjs +7502 -7690
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7486 -7676
- package/dist/index.mjs +7497 -7686
- package/dist/mime-types.cjs +10 -4
- package/dist/mime-types.d.ts +8 -11
- package/dist/mime-types.js +9 -3
- package/dist/mime-types.mjs +9 -3
- package/dist/native.cjs +8616 -8869
- package/dist/native.d.ts +7 -8
- package/dist/native.js +8682 -8935
- package/dist/native.mjs +8615 -8868
- package/dist/path.cjs +83 -77
- package/dist/path.d.ts +29 -29
- package/dist/path.js +82 -76
- package/dist/path.mjs +82 -76
- package/dist/pm.cjs +3300 -0
- package/dist/pm.d.ts +256 -0
- package/dist/pm.js +5638 -0
- package/dist/pm.mjs +3196 -0
- package/dist/preview-build.cjs +712 -0
- package/dist/preview-build.d.ts +59 -0
- package/dist/preview-build.js +3194 -0
- package/dist/preview-build.mjs +676 -0
- package/dist/render-context.cjs +13 -2
- package/dist/render-context.d.ts +9 -31
- package/dist/render-context.js +11 -2
- package/dist/render-context.mjs +11 -2
- package/dist/router.cjs +787 -645
- package/dist/router.d.ts +8 -12
- package/dist/router.js +786 -644
- package/dist/router.mjs +786 -644
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/server.cjs +3315 -2603
- package/dist/server.d.ts +49 -4
- package/dist/server.js +7611 -2834
- package/dist/server.mjs +3317 -2607
- package/dist/smtp-server.cjs +128 -0
- package/dist/smtp-server.d.ts +27 -0
- package/dist/smtp-server.js +4199 -0
- package/dist/smtp-server.mjs +100 -0
- package/dist/state-DvEkDehk.d.ts +195 -0
- package/dist/state.cjs +768 -658
- package/dist/state.d.ts +11 -69
- package/dist/state.js +760 -650
- package/dist/state.mjs +767 -657
- package/dist/style.cjs +1011 -968
- package/dist/style.d.ts +13 -127
- package/dist/style.js +1009 -970
- package/dist/style.mjs +1011 -971
- package/dist/test-reporter.cjs +332 -316
- package/dist/test-reporter.d.ts +28 -33
- package/dist/test-reporter.js +328 -312
- package/dist/test-reporter.mjs +328 -312
- package/dist/test-runtime.cjs +927 -968
- package/dist/test-runtime.d.ts +24 -99
- package/dist/test-runtime.js +922 -965
- package/dist/test-runtime.mjs +922 -965
- package/dist/test.cjs +4428 -4273
- package/dist/test.d.ts +2 -8
- package/dist/test.js +4307 -4154
- package/dist/test.mjs +4419 -4267
- package/dist/types-BONVzPtp.d.ts +59 -0
- package/dist/types-BR4wMiVx.d.ts +32 -0
- package/dist/types-C4gKykuG.d.ts +23 -0
- package/dist/types-CIhpN1-K.d.ts +64 -0
- package/dist/types-Ckj8md_j.d.ts +84 -0
- package/dist/types-CpjQTAkX.d.ts +24 -0
- package/dist/types-D0LjrYjS.d.ts +14 -0
- package/dist/types-DAisuVr5.d.ts +75 -0
- package/dist/types-tJn88E1N.d.ts +242 -0
- package/dist/types.d.ts +71 -226
- package/dist/universal.cjs +1 -1
- package/dist/universal.d.ts +1 -5
- package/dist/universal.js +1 -1
- package/dist/universal.mjs +1 -1
- package/dist/websocket-XfyK23zD.d.ts +119 -0
- package/dist/ws.cjs +129 -108
- package/dist/ws.d.ts +21 -131
- package/dist/ws.js +128 -109
- package/dist/ws.mjs +128 -109
- package/dist/wss.cjs +757 -479
- package/dist/wss.d.ts +31 -28
- package/dist/wss.js +755 -479
- package/dist/wss.mjs +758 -482
- package/package.json +16 -1
- package/vendor/epaint-0.31.1/src/image.rs +418 -0
- package/dist/server-CcBFc2F5.d.ts +0 -449
package/dist/test-reporter.cjs
CHANGED
|
@@ -17,9 +17,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// src/test
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
20
|
+
// src/test/reporter/index.ts
|
|
21
|
+
var reporter_exports = {};
|
|
22
|
+
__export(reporter_exports, {
|
|
23
23
|
DotReporter: () => DotReporter,
|
|
24
24
|
JsonReporter: () => JsonReporter,
|
|
25
25
|
TestReporter: () => TestReporter,
|
|
@@ -27,9 +27,9 @@ __export(test_reporter_exports, {
|
|
|
27
27
|
formatErrorStack: () => formatErrorStack,
|
|
28
28
|
formatProgress: () => formatProgress
|
|
29
29
|
});
|
|
30
|
-
module.exports = __toCommonJS(
|
|
30
|
+
module.exports = __toCommonJS(reporter_exports);
|
|
31
31
|
|
|
32
|
-
// src/runtime.ts
|
|
32
|
+
// src/shares/runtime.ts
|
|
33
33
|
var runtime = (() => {
|
|
34
34
|
if (typeof Deno !== "undefined") return "deno";
|
|
35
35
|
if (typeof Bun !== "undefined") return "bun";
|
|
@@ -39,37 +39,33 @@ var isNode = runtime === "node";
|
|
|
39
39
|
var isBun = runtime === "bun";
|
|
40
40
|
var isDeno = runtime === "deno";
|
|
41
41
|
|
|
42
|
-
// src/path.ts
|
|
42
|
+
// src/server/path/platform.ts
|
|
43
43
|
function getSeparator(isWin) {
|
|
44
44
|
return isWin ? "\\" : "/";
|
|
45
45
|
}
|
|
46
46
|
function getCwd() {
|
|
47
47
|
if (isNode || isBun) {
|
|
48
48
|
return process.cwd();
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
|
+
if (isDeno) {
|
|
50
51
|
return Deno.cwd();
|
|
51
52
|
}
|
|
52
53
|
return "/";
|
|
53
54
|
}
|
|
55
|
+
var isWindows = (() => {
|
|
56
|
+
if (isNode) {
|
|
57
|
+
return process.platform === "win32";
|
|
58
|
+
}
|
|
59
|
+
if (isDeno) {
|
|
60
|
+
return Deno.build.os === "windows";
|
|
61
|
+
}
|
|
62
|
+
return typeof process !== "undefined" && process.platform === "win32";
|
|
63
|
+
})();
|
|
64
|
+
|
|
65
|
+
// src/server/path/operations.ts
|
|
54
66
|
function findLastSeparator(path) {
|
|
55
67
|
return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
56
68
|
}
|
|
57
|
-
function createPathOps(isWin) {
|
|
58
|
-
return {
|
|
59
|
-
sep: getSeparator(isWin),
|
|
60
|
-
delimiter: isWin ? ";" : ":",
|
|
61
|
-
normalize: (path) => normalizePath(path, isWin),
|
|
62
|
-
join: (...paths) => joinPaths(paths, isWin),
|
|
63
|
-
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
64
|
-
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
65
|
-
relative: (from, to) => relativePath(from, to, isWin),
|
|
66
|
-
dirname: (path) => getDirname(path, isWin),
|
|
67
|
-
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
68
|
-
extname: (path) => getExtname(path),
|
|
69
|
-
parse: (path) => parsePath(path, isWin),
|
|
70
|
-
format: (pathObject) => formatPath(pathObject, isWin)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
69
|
function isAbsolutePosix(path) {
|
|
74
70
|
return path.length > 0 && path[0] === "/";
|
|
75
71
|
}
|
|
@@ -90,28 +86,18 @@ function isAbsoluteWin(path) {
|
|
|
90
86
|
}
|
|
91
87
|
return false;
|
|
92
88
|
}
|
|
93
|
-
var isWindows = (() => {
|
|
94
|
-
if (isNode) {
|
|
95
|
-
return process.platform === "win32";
|
|
96
|
-
} else if (isDeno) {
|
|
97
|
-
return Deno.build.os === "windows";
|
|
98
|
-
}
|
|
99
|
-
return typeof process !== "undefined" && process.platform === "win32";
|
|
100
|
-
})();
|
|
101
|
-
var posix = createPathOps(false);
|
|
102
|
-
var win32 = createPathOps(true);
|
|
103
89
|
function normalizePath(path, isWin) {
|
|
104
90
|
if (path.length === 0) return ".";
|
|
105
91
|
const separator = getSeparator(isWin);
|
|
106
92
|
const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
|
|
107
93
|
const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
|
|
108
|
-
|
|
94
|
+
const normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
|
|
109
95
|
const parts = normalized.split(separator);
|
|
110
96
|
const result = [];
|
|
111
|
-
for (let
|
|
112
|
-
const part = parts[
|
|
97
|
+
for (let index = 0; index < parts.length; index++) {
|
|
98
|
+
const part = parts[index];
|
|
113
99
|
if (part === "" || part === ".") {
|
|
114
|
-
if (
|
|
100
|
+
if (index === 0 && isAbsolute) result.push("");
|
|
115
101
|
continue;
|
|
116
102
|
}
|
|
117
103
|
if (part === "..") {
|
|
@@ -126,21 +112,21 @@ function normalizePath(path, isWin) {
|
|
|
126
112
|
result.push(part);
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
|
-
let
|
|
130
|
-
if (
|
|
115
|
+
let finalPath = result.join(separator);
|
|
116
|
+
if (finalPath.length === 0) {
|
|
131
117
|
return isAbsolute ? separator : ".";
|
|
132
118
|
}
|
|
133
|
-
if (trailingSeparator &&
|
|
134
|
-
|
|
119
|
+
if (trailingSeparator && finalPath[finalPath.length - 1] !== separator) {
|
|
120
|
+
finalPath += separator;
|
|
135
121
|
}
|
|
136
|
-
return
|
|
122
|
+
return finalPath;
|
|
137
123
|
}
|
|
138
124
|
function joinPaths(paths, isWin) {
|
|
139
125
|
if (paths.length === 0) return ".";
|
|
140
126
|
const separator = getSeparator(isWin);
|
|
141
127
|
let joined = "";
|
|
142
|
-
for (let
|
|
143
|
-
const path = paths[
|
|
128
|
+
for (let index = 0; index < paths.length; index++) {
|
|
129
|
+
const path = paths[index];
|
|
144
130
|
if (path && path.length > 0) {
|
|
145
131
|
if (joined.length === 0) {
|
|
146
132
|
joined = path;
|
|
@@ -155,43 +141,43 @@ function joinPaths(paths, isWin) {
|
|
|
155
141
|
function resolvePaths(paths, isWin) {
|
|
156
142
|
const separator = getSeparator(isWin);
|
|
157
143
|
let resolved = "";
|
|
158
|
-
let
|
|
159
|
-
for (let
|
|
160
|
-
const path = paths[
|
|
144
|
+
let absolute = false;
|
|
145
|
+
for (let index = paths.length - 1; index >= 0 && !absolute; index--) {
|
|
146
|
+
const path = paths[index];
|
|
161
147
|
if (path && path.length > 0) {
|
|
162
148
|
resolved = path + (resolved.length > 0 ? separator + resolved : "");
|
|
163
|
-
|
|
149
|
+
absolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
|
|
164
150
|
}
|
|
165
151
|
}
|
|
166
|
-
if (!
|
|
152
|
+
if (!absolute) {
|
|
167
153
|
const cwd = getCwd();
|
|
168
154
|
resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
|
|
169
155
|
}
|
|
170
156
|
return normalizePath(resolved, isWin);
|
|
171
157
|
}
|
|
172
158
|
function relativePath(from, to, isWin) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (
|
|
159
|
+
const resolvedFrom = resolvePaths([from], isWin);
|
|
160
|
+
const resolvedTo = resolvePaths([to], isWin);
|
|
161
|
+
if (resolvedFrom === resolvedTo) return "";
|
|
176
162
|
const separator = getSeparator(isWin);
|
|
177
|
-
const fromParts =
|
|
178
|
-
const toParts =
|
|
179
|
-
let commonLength = 0;
|
|
163
|
+
const fromParts = resolvedFrom.split(separator).filter((part) => part.length > 0);
|
|
164
|
+
const toParts = resolvedTo.split(separator).filter((part) => part.length > 0);
|
|
180
165
|
const minLength = Math.min(fromParts.length, toParts.length);
|
|
181
|
-
|
|
182
|
-
|
|
166
|
+
let commonLength = 0;
|
|
167
|
+
for (let index = 0; index < minLength; index++) {
|
|
168
|
+
if (fromParts[index] === toParts[index]) {
|
|
183
169
|
commonLength++;
|
|
184
170
|
} else {
|
|
185
171
|
break;
|
|
186
172
|
}
|
|
187
173
|
}
|
|
188
|
-
const upCount = fromParts.length - commonLength;
|
|
189
174
|
const result = [];
|
|
190
|
-
|
|
175
|
+
const upCount = fromParts.length - commonLength;
|
|
176
|
+
for (let index = 0; index < upCount; index++) {
|
|
191
177
|
result.push("..");
|
|
192
178
|
}
|
|
193
|
-
for (let
|
|
194
|
-
result.push(toParts[
|
|
179
|
+
for (let index = commonLength; index < toParts.length; index++) {
|
|
180
|
+
result.push(toParts[index]);
|
|
195
181
|
}
|
|
196
182
|
return result.join(separator) || ".";
|
|
197
183
|
}
|
|
@@ -199,15 +185,15 @@ function getDirname(path, isWin) {
|
|
|
199
185
|
if (path.length === 0) return ".";
|
|
200
186
|
const separator = getSeparator(isWin);
|
|
201
187
|
const normalized = normalizePath(path, isWin);
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
if (
|
|
205
|
-
return normalized.slice(0,
|
|
188
|
+
const lastSeparatorIndex = normalized.lastIndexOf(separator);
|
|
189
|
+
if (lastSeparatorIndex === -1) return ".";
|
|
190
|
+
if (lastSeparatorIndex === 0) return separator;
|
|
191
|
+
return normalized.slice(0, lastSeparatorIndex);
|
|
206
192
|
}
|
|
207
193
|
function getBasename(path, ext, isWin) {
|
|
208
194
|
if (path.length === 0) return "";
|
|
209
|
-
const
|
|
210
|
-
let base =
|
|
195
|
+
const lastSeparatorIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
|
|
196
|
+
let base = lastSeparatorIndex === -1 ? path : path.slice(lastSeparatorIndex + 1);
|
|
211
197
|
if (ext && base.endsWith(ext)) {
|
|
212
198
|
base = base.slice(0, base.length - ext.length);
|
|
213
199
|
}
|
|
@@ -215,8 +201,8 @@ function getBasename(path, ext, isWin) {
|
|
|
215
201
|
}
|
|
216
202
|
function getExtname(path) {
|
|
217
203
|
const lastDotIndex = path.lastIndexOf(".");
|
|
218
|
-
const
|
|
219
|
-
if (lastDotIndex === -1 || lastDotIndex <
|
|
204
|
+
const lastSeparatorIndex = findLastSeparator(path);
|
|
205
|
+
if (lastDotIndex === -1 || lastDotIndex < lastSeparatorIndex || lastDotIndex === path.length - 1) {
|
|
220
206
|
return "";
|
|
221
207
|
}
|
|
222
208
|
return path.slice(lastDotIndex);
|
|
@@ -232,10 +218,8 @@ function parsePath(path, isWin) {
|
|
|
232
218
|
} else if (path[0] === "\\" || path[0] === "/") {
|
|
233
219
|
root = "\\";
|
|
234
220
|
}
|
|
235
|
-
} else {
|
|
236
|
-
|
|
237
|
-
root = "/";
|
|
238
|
-
}
|
|
221
|
+
} else if (path[0] === "/") {
|
|
222
|
+
root = "/";
|
|
239
223
|
}
|
|
240
224
|
const dir = getDirname(path, isWin);
|
|
241
225
|
const base = getBasename(path, void 0, isWin);
|
|
@@ -251,11 +235,31 @@ function formatPath(pathObject, isWin) {
|
|
|
251
235
|
if (dir === pathObject.root) return dir + base;
|
|
252
236
|
return dir + separator + base;
|
|
253
237
|
}
|
|
238
|
+
function createPathOps(isWin) {
|
|
239
|
+
return {
|
|
240
|
+
sep: getSeparator(isWin),
|
|
241
|
+
delimiter: isWin ? ";" : ":",
|
|
242
|
+
normalize: (path) => normalizePath(path, isWin),
|
|
243
|
+
join: (...paths) => joinPaths(paths, isWin),
|
|
244
|
+
resolve: (...paths) => resolvePaths(paths, isWin),
|
|
245
|
+
isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
|
|
246
|
+
relative: (from, to) => relativePath(from, to, isWin),
|
|
247
|
+
dirname: (path) => getDirname(path, isWin),
|
|
248
|
+
basename: (path, ext) => getBasename(path, ext, isWin),
|
|
249
|
+
extname: (path) => getExtname(path),
|
|
250
|
+
parse: (path) => parsePath(path, isWin),
|
|
251
|
+
format: (pathObject) => formatPath(pathObject, isWin)
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/server/path/index.ts
|
|
256
|
+
var posix = createPathOps(false);
|
|
257
|
+
var win32 = createPathOps(true);
|
|
254
258
|
function relative(from, to) {
|
|
255
259
|
return relativePath(from, to, isWindows);
|
|
256
260
|
}
|
|
257
261
|
|
|
258
|
-
// src/test
|
|
262
|
+
// src/test/reporter/colors.ts
|
|
259
263
|
var colors = {
|
|
260
264
|
reset: "\x1B[0m",
|
|
261
265
|
bold: "\x1B[1m",
|
|
@@ -267,68 +271,220 @@ var colors = {
|
|
|
267
271
|
cyan: "\x1B[36m",
|
|
268
272
|
white: "\x1B[37m"
|
|
269
273
|
};
|
|
274
|
+
function colorize(color, text, enabled = true) {
|
|
275
|
+
return enabled ? colors[color] + text + colors.reset : text;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/test/reporter/suggestions.ts
|
|
270
279
|
function extractArg(code, functionName) {
|
|
271
|
-
const
|
|
272
|
-
const startIndex = code.indexOf(
|
|
280
|
+
const searchString = `.${functionName}(`;
|
|
281
|
+
const startIndex = code.indexOf(searchString);
|
|
273
282
|
if (startIndex === -1) return null;
|
|
274
283
|
let parenCount = 0;
|
|
275
284
|
let inString = false;
|
|
276
285
|
let stringChar = "";
|
|
277
|
-
|
|
278
|
-
for (let
|
|
279
|
-
const char = code[
|
|
286
|
+
const argumentStart = startIndex + searchString.length;
|
|
287
|
+
for (let index = argumentStart; index < code.length; index++) {
|
|
288
|
+
const char = code[index];
|
|
280
289
|
if (!inString) {
|
|
281
|
-
if (char === "(")
|
|
282
|
-
|
|
290
|
+
if (char === "(") {
|
|
291
|
+
parenCount++;
|
|
292
|
+
} else if (char === ")") {
|
|
283
293
|
parenCount--;
|
|
284
294
|
if (parenCount < 0) {
|
|
285
|
-
return code.slice(
|
|
295
|
+
return code.slice(argumentStart, index);
|
|
286
296
|
}
|
|
287
297
|
} else if (char === '"' || char === "'" || char === "`") {
|
|
288
298
|
inString = true;
|
|
289
299
|
stringChar = char;
|
|
290
300
|
}
|
|
291
|
-
} else {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
inString = false;
|
|
296
|
-
}
|
|
301
|
+
} else if (char === "\\" && index + 1 < code.length) {
|
|
302
|
+
index++;
|
|
303
|
+
} else if (char === stringChar) {
|
|
304
|
+
inString = false;
|
|
297
305
|
}
|
|
298
306
|
}
|
|
299
307
|
return null;
|
|
300
308
|
}
|
|
301
|
-
function extractReceivedValue(
|
|
302
|
-
const receivedIndex =
|
|
309
|
+
function extractReceivedValue(errorMessage) {
|
|
310
|
+
const receivedIndex = errorMessage.indexOf("Received:");
|
|
303
311
|
if (receivedIndex === -1) return null;
|
|
304
|
-
const afterReceived =
|
|
312
|
+
const afterReceived = errorMessage.slice(receivedIndex + 9).trimStart();
|
|
305
313
|
const newlineIndex = afterReceived.indexOf("\n");
|
|
306
314
|
if (newlineIndex !== -1) {
|
|
307
315
|
return afterReceived.slice(0, newlineIndex).trimEnd();
|
|
308
316
|
}
|
|
309
317
|
return afterReceived.trimEnd();
|
|
310
318
|
}
|
|
311
|
-
function parseQuotedString(
|
|
312
|
-
if (
|
|
313
|
-
const firstChar =
|
|
314
|
-
const lastChar =
|
|
319
|
+
function parseQuotedString(value) {
|
|
320
|
+
if (value.length < 2) return null;
|
|
321
|
+
const firstChar = value[0];
|
|
322
|
+
const lastChar = value[value.length - 1];
|
|
315
323
|
if ((firstChar === '"' || firstChar === "'" || firstChar === "`") && firstChar === lastChar) {
|
|
316
324
|
return {
|
|
317
325
|
quote: firstChar,
|
|
318
|
-
content:
|
|
326
|
+
content: value.slice(1, -1)
|
|
319
327
|
};
|
|
320
328
|
}
|
|
321
329
|
return null;
|
|
322
330
|
}
|
|
323
|
-
function stripQuotes(
|
|
324
|
-
if (
|
|
325
|
-
const firstChar =
|
|
326
|
-
const lastChar =
|
|
331
|
+
function stripQuotes(value) {
|
|
332
|
+
if (value.length < 2) return value;
|
|
333
|
+
const firstChar = value[0];
|
|
334
|
+
const lastChar = value[value.length - 1];
|
|
327
335
|
if ((firstChar === '"' || firstChar === "'" || firstChar === "`") && firstChar === lastChar) {
|
|
328
|
-
return
|
|
336
|
+
return value.slice(1, -1);
|
|
329
337
|
}
|
|
330
|
-
return
|
|
338
|
+
return value;
|
|
331
339
|
}
|
|
340
|
+
function buildSuggestion(code, errorMessage) {
|
|
341
|
+
const receivedValue = extractReceivedValue(errorMessage);
|
|
342
|
+
if (code.includes(".toBeGreaterThanOrEqual(")) {
|
|
343
|
+
const currentValue = extractArg(code, "toBeGreaterThanOrEqual");
|
|
344
|
+
if (currentValue && receivedValue) {
|
|
345
|
+
const actualValue = Number(receivedValue);
|
|
346
|
+
if (!Number.isNaN(actualValue)) {
|
|
347
|
+
return code.replace(
|
|
348
|
+
`.toBeGreaterThanOrEqual(${currentValue})`,
|
|
349
|
+
`.toBeGreaterThanOrEqual(${actualValue})`
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} else if (code.includes(".toBeGreaterThan(")) {
|
|
354
|
+
const currentValue = extractArg(code, "toBeGreaterThan");
|
|
355
|
+
if (currentValue && receivedValue) {
|
|
356
|
+
const actualValue = Number(receivedValue);
|
|
357
|
+
if (!Number.isNaN(actualValue)) {
|
|
358
|
+
return code.replace(
|
|
359
|
+
`.toBeGreaterThan(${currentValue})`,
|
|
360
|
+
`.toBeGreaterThan(${actualValue - 1})`
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
} else if (code.includes(".toBeLessThanOrEqual(")) {
|
|
365
|
+
const currentValue = extractArg(code, "toBeLessThanOrEqual");
|
|
366
|
+
if (currentValue && receivedValue) {
|
|
367
|
+
const actualValue = Number(receivedValue);
|
|
368
|
+
if (!Number.isNaN(actualValue)) {
|
|
369
|
+
return code.replace(
|
|
370
|
+
`.toBeLessThanOrEqual(${currentValue})`,
|
|
371
|
+
`.toBeLessThanOrEqual(${actualValue})`
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} else if (code.includes(".toBeLessThan(")) {
|
|
376
|
+
const currentValue = extractArg(code, "toBeLessThan");
|
|
377
|
+
if (currentValue && receivedValue) {
|
|
378
|
+
const actualValue = Number(receivedValue);
|
|
379
|
+
if (!Number.isNaN(actualValue)) {
|
|
380
|
+
return code.replace(
|
|
381
|
+
`.toBeLessThan(${currentValue})`,
|
|
382
|
+
`.toBeLessThan(${actualValue + 1})`
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
} else if (code.includes(".toStrictEqual(")) {
|
|
387
|
+
const expectedValue = extractArg(code, "toStrictEqual");
|
|
388
|
+
if (expectedValue && receivedValue) {
|
|
389
|
+
const quoted = parseQuotedString(expectedValue);
|
|
390
|
+
if (quoted) {
|
|
391
|
+
return code.replace(
|
|
392
|
+
`.toStrictEqual(${expectedValue})`,
|
|
393
|
+
`.toStrictEqual(${quoted.quote}${stripQuotes(receivedValue)}${quoted.quote})`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return code.replace(
|
|
397
|
+
`.toStrictEqual(${expectedValue})`,
|
|
398
|
+
`.toStrictEqual(${receivedValue})`
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
} else if (code.includes(".toEqual(")) {
|
|
402
|
+
const expectedValue = extractArg(code, "toEqual");
|
|
403
|
+
if (expectedValue && receivedValue) {
|
|
404
|
+
const quoted = parseQuotedString(expectedValue);
|
|
405
|
+
if (quoted) {
|
|
406
|
+
return code.replace(
|
|
407
|
+
`.toEqual(${expectedValue})`,
|
|
408
|
+
`.toEqual(${quoted.quote}${stripQuotes(receivedValue)}${quoted.quote})`
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
return code.replace(
|
|
412
|
+
`.toEqual(${expectedValue})`,
|
|
413
|
+
`.toEqual(${receivedValue})`
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
} else if (code.includes(".toMatch(")) {
|
|
417
|
+
const expectedPattern = extractArg(code, "toMatch");
|
|
418
|
+
if (expectedPattern && receivedValue) {
|
|
419
|
+
const quoted = parseQuotedString(expectedPattern);
|
|
420
|
+
if (quoted) {
|
|
421
|
+
return code.replace(
|
|
422
|
+
`.toMatch(${expectedPattern})`,
|
|
423
|
+
`.toMatch(${quoted.quote}${stripQuotes(receivedValue)}${quoted.quote})`
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
} else if (code.includes(".toContain(")) {
|
|
428
|
+
const expectedValue = extractArg(code, "toContain");
|
|
429
|
+
if (expectedValue && receivedValue) {
|
|
430
|
+
const quoted = parseQuotedString(expectedValue);
|
|
431
|
+
if (quoted) {
|
|
432
|
+
return code.replace(
|
|
433
|
+
`.toContain(${expectedValue})`,
|
|
434
|
+
`.toContain(${quoted.quote}${stripQuotes(receivedValue)}${quoted.quote})`
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
return code.replace(
|
|
438
|
+
`.toContain(${expectedValue})`,
|
|
439
|
+
`.toContain(${receivedValue})`
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
} else if (code.includes(".toHaveLength(")) {
|
|
443
|
+
const expectedLength = extractArg(code, "toHaveLength");
|
|
444
|
+
if (expectedLength && receivedValue) {
|
|
445
|
+
const actualLength = Number(receivedValue);
|
|
446
|
+
if (!Number.isNaN(actualLength)) {
|
|
447
|
+
return code.replace(
|
|
448
|
+
`.toHaveLength(${expectedLength})`,
|
|
449
|
+
`.toHaveLength(${actualLength})`
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
} else if (code.includes(".toBe(")) {
|
|
454
|
+
const expectedValue = extractArg(code, "toBe");
|
|
455
|
+
if (expectedValue) {
|
|
456
|
+
if (receivedValue) {
|
|
457
|
+
const quoted = parseQuotedString(expectedValue);
|
|
458
|
+
if (quoted) {
|
|
459
|
+
return code.replace(
|
|
460
|
+
`.toBe(${expectedValue})`,
|
|
461
|
+
`.toBe(${quoted.quote}${stripQuotes(receivedValue)}${quoted.quote})`
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
return code.replace(
|
|
465
|
+
`.toBe(${expectedValue})`,
|
|
466
|
+
`.toBe(${receivedValue})`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
if (expectedValue.includes("'") || expectedValue.includes('"')) {
|
|
470
|
+
return code.replace(".toBe(", ".toEqual(");
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
} else if (code.includes(".toBeDefined()")) {
|
|
474
|
+
return code.replace(".toBeDefined()", ".toBeTruthy()");
|
|
475
|
+
} else if (code.includes(".toBeNull()")) {
|
|
476
|
+
return code.replace(".toBeNull()", ".toBeUndefined()");
|
|
477
|
+
} else if (code.includes(".toBeUndefined()")) {
|
|
478
|
+
return code.replace(".toBeUndefined()", ".toBeNull()");
|
|
479
|
+
} else if (code.includes(".toBeTruthy()")) {
|
|
480
|
+
return code.replace(".toBeTruthy()", ".toBeDefined()");
|
|
481
|
+
} else if (code.includes(".toBeFalsy()")) {
|
|
482
|
+
return code.replace(".toBeFalsy()", ".toBeUndefined()");
|
|
483
|
+
}
|
|
484
|
+
return "";
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// src/test/reporter/default-reporter.ts
|
|
332
488
|
var TestReporter = class {
|
|
333
489
|
constructor(options = {}) {
|
|
334
490
|
this.startTime = 0;
|
|
@@ -342,7 +498,7 @@ var TestReporter = class {
|
|
|
342
498
|
};
|
|
343
499
|
}
|
|
344
500
|
c(color, text) {
|
|
345
|
-
return this.options.colors !== false
|
|
501
|
+
return colorize(color, text, this.options.colors !== false);
|
|
346
502
|
}
|
|
347
503
|
onRunStart(files) {
|
|
348
504
|
this.startTime = Date.now();
|
|
@@ -368,202 +524,52 @@ ${this.c("bold", "Test Files")}: ${files.length}`);
|
|
|
368
524
|
this.fileTestCount++;
|
|
369
525
|
if (result.status === "pass") {
|
|
370
526
|
console.log(` ${this.c("green", "\u2713")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("dim", `(${result.duration}ms)`)}`);
|
|
371
|
-
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (result.status === "fail") {
|
|
372
530
|
console.log(` ${this.c("red", "\u2715")} ${this.c("dim", result.suite + " > ")}${result.name}`);
|
|
373
|
-
if (result.error) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (result.codeSnippet) {
|
|
391
|
-
let suggestion = "";
|
|
392
|
-
const code = result.codeSnippet;
|
|
393
|
-
const errorMsg = result.error?.message || "";
|
|
394
|
-
const receivedValue = extractReceivedValue(errorMsg);
|
|
395
|
-
if (code.includes(".toBeGreaterThanOrEqual(")) {
|
|
396
|
-
const currentValue = extractArg(code, "toBeGreaterThanOrEqual");
|
|
397
|
-
if (currentValue && receivedValue) {
|
|
398
|
-
const actualValue = Number(receivedValue);
|
|
399
|
-
if (!isNaN(actualValue)) {
|
|
400
|
-
suggestion = code.replace(
|
|
401
|
-
`.toBeGreaterThanOrEqual(${currentValue})`,
|
|
402
|
-
`.toBeGreaterThanOrEqual(${actualValue})`
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
} else if (code.includes(".toBeGreaterThan(")) {
|
|
407
|
-
const currentValue = extractArg(code, "toBeGreaterThan");
|
|
408
|
-
if (currentValue && receivedValue) {
|
|
409
|
-
const actualValue = Number(receivedValue);
|
|
410
|
-
if (!isNaN(actualValue)) {
|
|
411
|
-
suggestion = code.replace(
|
|
412
|
-
`.toBeGreaterThan(${currentValue})`,
|
|
413
|
-
`.toBeGreaterThan(${actualValue - 1})`
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
} else if (code.includes(".toBeLessThanOrEqual(")) {
|
|
418
|
-
const currentValue = extractArg(code, "toBeLessThanOrEqual");
|
|
419
|
-
if (currentValue && receivedValue) {
|
|
420
|
-
const actualValue = Number(receivedValue);
|
|
421
|
-
if (!isNaN(actualValue)) {
|
|
422
|
-
suggestion = code.replace(
|
|
423
|
-
`.toBeLessThanOrEqual(${currentValue})`,
|
|
424
|
-
`.toBeLessThanOrEqual(${actualValue})`
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
} else if (code.includes(".toBeLessThan(")) {
|
|
429
|
-
const currentValue = extractArg(code, "toBeLessThan");
|
|
430
|
-
if (currentValue && receivedValue) {
|
|
431
|
-
const actualValue = Number(receivedValue);
|
|
432
|
-
if (!isNaN(actualValue)) {
|
|
433
|
-
suggestion = code.replace(
|
|
434
|
-
`.toBeLessThan(${currentValue})`,
|
|
435
|
-
`.toBeLessThan(${actualValue + 1})`
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
} else if (code.includes(".toStrictEqual(")) {
|
|
440
|
-
const expectedValue = extractArg(code, "toStrictEqual");
|
|
441
|
-
if (expectedValue && receivedValue) {
|
|
442
|
-
const quoted = parseQuotedString(expectedValue);
|
|
443
|
-
if (quoted) {
|
|
444
|
-
const strippedReceived = stripQuotes(receivedValue);
|
|
445
|
-
suggestion = code.replace(
|
|
446
|
-
`.toStrictEqual(${expectedValue})`,
|
|
447
|
-
`.toStrictEqual(${quoted.quote}${strippedReceived}${quoted.quote})`
|
|
448
|
-
);
|
|
449
|
-
} else {
|
|
450
|
-
suggestion = code.replace(
|
|
451
|
-
`.toStrictEqual(${expectedValue})`,
|
|
452
|
-
`.toStrictEqual(${receivedValue})`
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
} else if (code.includes(".toEqual(")) {
|
|
457
|
-
const expectedValue = extractArg(code, "toEqual");
|
|
458
|
-
if (expectedValue && receivedValue) {
|
|
459
|
-
const quoted = parseQuotedString(expectedValue);
|
|
460
|
-
if (quoted) {
|
|
461
|
-
const strippedReceived = stripQuotes(receivedValue);
|
|
462
|
-
suggestion = code.replace(
|
|
463
|
-
`.toEqual(${expectedValue})`,
|
|
464
|
-
`.toEqual(${quoted.quote}${strippedReceived}${quoted.quote})`
|
|
465
|
-
);
|
|
466
|
-
} else {
|
|
467
|
-
suggestion = code.replace(
|
|
468
|
-
`.toEqual(${expectedValue})`,
|
|
469
|
-
`.toEqual(${receivedValue})`
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
} else if (code.includes(".toMatch(")) {
|
|
474
|
-
const expectedPattern = extractArg(code, "toMatch");
|
|
475
|
-
if (expectedPattern && receivedValue) {
|
|
476
|
-
const quoted = parseQuotedString(expectedPattern);
|
|
477
|
-
if (quoted) {
|
|
478
|
-
const strippedReceived = stripQuotes(receivedValue);
|
|
479
|
-
suggestion = code.replace(
|
|
480
|
-
`.toMatch(${expectedPattern})`,
|
|
481
|
-
`.toMatch(${quoted.quote}${strippedReceived}${quoted.quote})`
|
|
482
|
-
);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
} else if (code.includes(".toContain(")) {
|
|
486
|
-
const expectedValue = extractArg(code, "toContain");
|
|
487
|
-
if (expectedValue && receivedValue) {
|
|
488
|
-
const quoted = parseQuotedString(expectedValue);
|
|
489
|
-
if (quoted) {
|
|
490
|
-
const strippedReceived = stripQuotes(receivedValue);
|
|
491
|
-
suggestion = code.replace(
|
|
492
|
-
`.toContain(${expectedValue})`,
|
|
493
|
-
`.toContain(${quoted.quote}${strippedReceived}${quoted.quote})`
|
|
494
|
-
);
|
|
495
|
-
} else {
|
|
496
|
-
suggestion = code.replace(
|
|
497
|
-
`.toContain(${expectedValue})`,
|
|
498
|
-
`.toContain(${receivedValue})`
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
} else if (code.includes(".toHaveLength(")) {
|
|
503
|
-
const expectedLength = extractArg(code, "toHaveLength");
|
|
504
|
-
if (expectedLength && receivedValue) {
|
|
505
|
-
const actualLength = Number(receivedValue);
|
|
506
|
-
if (!isNaN(actualLength)) {
|
|
507
|
-
suggestion = code.replace(
|
|
508
|
-
`.toHaveLength(${expectedLength})`,
|
|
509
|
-
`.toHaveLength(${actualLength})`
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
} else if (code.includes(".toBe(")) {
|
|
514
|
-
const expectedValue = extractArg(code, "toBe");
|
|
515
|
-
if (expectedValue) {
|
|
516
|
-
if (receivedValue) {
|
|
517
|
-
const quoted = parseQuotedString(expectedValue);
|
|
518
|
-
if (quoted) {
|
|
519
|
-
const strippedReceived = stripQuotes(receivedValue);
|
|
520
|
-
suggestion = code.replace(
|
|
521
|
-
`.toBe(${expectedValue})`,
|
|
522
|
-
`.toBe(${quoted.quote}${strippedReceived}${quoted.quote})`
|
|
523
|
-
);
|
|
524
|
-
} else {
|
|
525
|
-
suggestion = code.replace(
|
|
526
|
-
`.toBe(${expectedValue})`,
|
|
527
|
-
`.toBe(${receivedValue})`
|
|
528
|
-
);
|
|
529
|
-
}
|
|
530
|
-
} else if (expectedValue.includes("'") || expectedValue.includes('"')) {
|
|
531
|
-
suggestion = code.replace(".toBe(", ".toEqual(");
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
} else if (code.includes(".toBeDefined()")) {
|
|
535
|
-
suggestion = code.replace(".toBeDefined()", ".toBeTruthy()");
|
|
536
|
-
} else if (code.includes(".toBeNull()")) {
|
|
537
|
-
suggestion = code.replace(".toBeNull()", ".toBeUndefined()");
|
|
538
|
-
} else if (code.includes(".toBeUndefined()")) {
|
|
539
|
-
suggestion = code.replace(".toBeUndefined()", ".toBeNull()");
|
|
540
|
-
} else if (code.includes(".toBeTruthy()")) {
|
|
541
|
-
suggestion = code.replace(".toBeTruthy()", ".toBeDefined()");
|
|
542
|
-
} else if (code.includes(".toBeFalsy()")) {
|
|
543
|
-
suggestion = code.replace(".toBeFalsy()", ".toBeUndefined()");
|
|
544
|
-
}
|
|
545
|
-
console.log(` ${this.c("dim", "Code:")}`);
|
|
546
|
-
console.log(` ${this.c("dim", code)}`);
|
|
547
|
-
if (suggestion && suggestion !== code) {
|
|
548
|
-
console.log(` ${this.c("yellow", "example \u2192")} ${this.c("green", suggestion)}`);
|
|
549
|
-
}
|
|
531
|
+
if (!result.error) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (result.file) {
|
|
535
|
+
const relativePath2 = relative(process.cwd(), result.file).split("\\").join("/");
|
|
536
|
+
const lineSuffix = result.lineNumber ? `:${result.lineNumber}` : "";
|
|
537
|
+
console.log(` ${this.c("cyan", `\u{1F4C4} ${relativePath2}${lineSuffix}`)}`);
|
|
538
|
+
}
|
|
539
|
+
for (const line of result.error.message.split("\n")) {
|
|
540
|
+
if (line.includes("Expected:")) {
|
|
541
|
+
console.log(` ${this.c("green", "Expected:")} ${line.trim().replace("Expected:", "").trim()}`);
|
|
542
|
+
} else if (line.includes("Received:")) {
|
|
543
|
+
console.log(` ${this.c("red", "Received:")} ${line.trim().replace("Received:", "").trim()}`);
|
|
544
|
+
} else {
|
|
545
|
+
console.log(` ${this.c("red", line.trim())}`);
|
|
550
546
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
547
|
+
}
|
|
548
|
+
if (result.codeSnippet) {
|
|
549
|
+
const suggestion = buildSuggestion(result.codeSnippet, result.error.message || "");
|
|
550
|
+
console.log(` ${this.c("dim", "Code:")}`);
|
|
551
|
+
console.log(` ${this.c("dim", result.codeSnippet)}`);
|
|
552
|
+
if (suggestion && suggestion !== result.codeSnippet) {
|
|
553
|
+
console.log(` ${this.c("yellow", "example \u2192")} ${this.c("green", suggestion)}`);
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
|
|
556
|
+
if (this.options.verbose && result.error.stack) {
|
|
557
|
+
const stack = result.error.stack.split("\n").slice(1, 3).join("\n");
|
|
558
|
+
console.log(` ${this.c("dim", stack)}`);
|
|
559
|
+
}
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (result.status === "skip") {
|
|
557
563
|
console.log(` ${this.c("yellow", "\u25CB")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("yellow", "(skipped)")}`);
|
|
558
|
-
|
|
559
|
-
console.log(` ${this.c("cyan", "\u25CB")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("cyan", "(todo)")}`);
|
|
564
|
+
return;
|
|
560
565
|
}
|
|
566
|
+
console.log(` ${this.c("cyan", "\u25CB")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("cyan", "(todo)")}`);
|
|
561
567
|
}
|
|
562
568
|
onRunEnd(results) {
|
|
563
569
|
const duration = Date.now() - this.startTime;
|
|
564
|
-
const passed = results.filter((
|
|
565
|
-
const failed = results.filter((
|
|
566
|
-
const skipped = results.filter((
|
|
570
|
+
const passed = results.filter((result) => result.status === "pass").length;
|
|
571
|
+
const failed = results.filter((result) => result.status === "fail").length;
|
|
572
|
+
const skipped = results.filter((result) => result.status === "skip").length;
|
|
567
573
|
const total = results.length;
|
|
568
574
|
if (this.currentFile && this.fileTestCount > 0) {
|
|
569
575
|
console.log("");
|
|
@@ -577,6 +583,8 @@ ${this.c("bold", "Test Files")}: ${files.length}`);
|
|
|
577
583
|
console.log("");
|
|
578
584
|
}
|
|
579
585
|
};
|
|
586
|
+
|
|
587
|
+
// src/test/reporter/dot-reporter.ts
|
|
580
588
|
var DotReporter = class {
|
|
581
589
|
constructor() {
|
|
582
590
|
this.passed = 0;
|
|
@@ -610,9 +618,11 @@ var DotReporter = class {
|
|
|
610
618
|
`);
|
|
611
619
|
}
|
|
612
620
|
c(color, text) {
|
|
613
|
-
return
|
|
621
|
+
return colorize(color, text);
|
|
614
622
|
}
|
|
615
623
|
};
|
|
624
|
+
|
|
625
|
+
// src/test/reporter/json-reporter.ts
|
|
616
626
|
var JsonReporter = class {
|
|
617
627
|
constructor() {
|
|
618
628
|
this.startTime = 0;
|
|
@@ -625,30 +635,32 @@ var JsonReporter = class {
|
|
|
625
635
|
onTestResult(result) {
|
|
626
636
|
this.results.push(result);
|
|
627
637
|
}
|
|
628
|
-
onRunEnd(
|
|
638
|
+
onRunEnd(_results) {
|
|
629
639
|
const report = {
|
|
630
640
|
summary: {
|
|
631
|
-
total: results.length,
|
|
632
|
-
passed: results.filter((
|
|
633
|
-
failed: results.filter((
|
|
634
|
-
skipped: results.filter((
|
|
635
|
-
todo: results.filter((
|
|
641
|
+
total: this.results.length,
|
|
642
|
+
passed: this.results.filter((result) => result.status === "pass").length,
|
|
643
|
+
failed: this.results.filter((result) => result.status === "fail").length,
|
|
644
|
+
skipped: this.results.filter((result) => result.status === "skip").length,
|
|
645
|
+
todo: this.results.filter((result) => result.status === "todo").length,
|
|
636
646
|
duration: Date.now() - this.startTime
|
|
637
647
|
},
|
|
638
|
-
tests: results.map((
|
|
639
|
-
status:
|
|
640
|
-
name:
|
|
641
|
-
suite:
|
|
642
|
-
duration:
|
|
643
|
-
error:
|
|
644
|
-
message:
|
|
645
|
-
stack:
|
|
648
|
+
tests: this.results.map((result) => ({
|
|
649
|
+
status: result.status === "pass" ? "passed" : result.status === "fail" ? "failed" : result.status === "skip" ? "skipped" : "todo",
|
|
650
|
+
name: result.name,
|
|
651
|
+
suite: result.suite,
|
|
652
|
+
duration: result.duration,
|
|
653
|
+
error: result.error ? {
|
|
654
|
+
message: result.error.message,
|
|
655
|
+
stack: result.error.stack
|
|
646
656
|
} : void 0
|
|
647
657
|
}))
|
|
648
658
|
};
|
|
649
659
|
console.log(JSON.stringify(report, null, 2));
|
|
650
660
|
}
|
|
651
661
|
};
|
|
662
|
+
|
|
663
|
+
// src/test/reporter/verbose-reporter.ts
|
|
652
664
|
var VerboseReporter = class {
|
|
653
665
|
constructor() {
|
|
654
666
|
this.currentSuite = "";
|
|
@@ -676,9 +688,9 @@ ${colors.red} ${result.error.message}${colors.reset}`);
|
|
|
676
688
|
}
|
|
677
689
|
}
|
|
678
690
|
onRunEnd(results) {
|
|
679
|
-
const passed = results.filter((
|
|
680
|
-
const failed = results.filter((
|
|
681
|
-
const skipped = results.filter((
|
|
691
|
+
const passed = results.filter((result) => result.status === "pass").length;
|
|
692
|
+
const failed = results.filter((result) => result.status === "fail").length;
|
|
693
|
+
const skipped = results.filter((result) => result.status === "skip").length;
|
|
682
694
|
console.log(`
|
|
683
695
|
${colors.dim}${"\u2500".repeat(50)}${colors.reset}
|
|
684
696
|
`);
|
|
@@ -686,18 +698,22 @@ ${colors.dim}${"\u2500".repeat(50)}${colors.reset}
|
|
|
686
698
|
console.log(`${colors.green}All tests passed!${colors.reset}`);
|
|
687
699
|
console.log(`${colors.dim}${passed} tests${colors.reset}
|
|
688
700
|
`);
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}
|
|
695
|
-
console.log("");
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
console.log(`${colors.red}${failed} tests failed${colors.reset}`);
|
|
704
|
+
console.log(`${colors.green}${passed} tests passed${colors.reset}`);
|
|
705
|
+
if (skipped > 0) {
|
|
706
|
+
console.log(`${colors.yellow}${skipped} tests skipped${colors.reset}`);
|
|
696
707
|
}
|
|
708
|
+
console.log("");
|
|
697
709
|
}
|
|
698
710
|
};
|
|
711
|
+
|
|
712
|
+
// src/test/reporter/utilities.ts
|
|
699
713
|
function formatErrorStack(error) {
|
|
700
|
-
if (!error.stack)
|
|
714
|
+
if (!error.stack) {
|
|
715
|
+
return error.message;
|
|
716
|
+
}
|
|
701
717
|
const lines = error.stack.split("\n");
|
|
702
718
|
let formatted = `${error.message}
|
|
703
719
|
`;
|