elit 3.3.2 → 3.3.4

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.
Files changed (143) hide show
  1. package/dist/build.d.mts +1 -1
  2. package/dist/build.js +1 -0
  3. package/dist/build.js.map +1 -0
  4. package/dist/build.mjs +1 -0
  5. package/dist/build.mjs.map +1 -0
  6. package/dist/chokidar.js +1 -0
  7. package/dist/chokidar.js.map +1 -0
  8. package/dist/chokidar.mjs +1 -0
  9. package/dist/chokidar.mjs.map +1 -0
  10. package/dist/cli.js +4691 -34
  11. package/dist/config.d.mts +3 -1
  12. package/dist/config.d.ts +3 -1
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +1 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/config.mjs +1 -0
  17. package/dist/config.mjs.map +1 -0
  18. package/dist/coverage.d.mts +85 -0
  19. package/dist/coverage.d.ts +76 -0
  20. package/dist/coverage.d.ts.map +1 -0
  21. package/dist/coverage.js +1549 -0
  22. package/dist/coverage.js.map +1 -0
  23. package/dist/coverage.mjs +1520 -0
  24. package/dist/coverage.mjs.map +1 -0
  25. package/dist/database.d.mts +31 -6
  26. package/dist/database.d.ts +31 -6
  27. package/dist/database.d.ts.map +1 -1
  28. package/dist/database.js +60 -33
  29. package/dist/database.js.map +1 -0
  30. package/dist/database.mjs +60 -33
  31. package/dist/database.mjs.map +1 -0
  32. package/dist/dom.js +1 -0
  33. package/dist/dom.js.map +1 -0
  34. package/dist/dom.mjs +1 -0
  35. package/dist/dom.mjs.map +1 -0
  36. package/dist/el.js +1 -0
  37. package/dist/el.js.map +1 -0
  38. package/dist/el.mjs +1 -0
  39. package/dist/el.mjs.map +1 -0
  40. package/dist/fs.js +1 -0
  41. package/dist/fs.js.map +1 -0
  42. package/dist/fs.mjs +1 -0
  43. package/dist/fs.mjs.map +1 -0
  44. package/dist/hmr.js +1 -0
  45. package/dist/hmr.js.map +1 -0
  46. package/dist/hmr.mjs +1 -0
  47. package/dist/hmr.mjs.map +1 -0
  48. package/dist/http.js +1 -0
  49. package/dist/http.js.map +1 -0
  50. package/dist/http.mjs +1 -0
  51. package/dist/http.mjs.map +1 -0
  52. package/dist/https.d.mts +1 -1
  53. package/dist/https.js +1 -0
  54. package/dist/https.js.map +1 -0
  55. package/dist/https.mjs +1 -0
  56. package/dist/https.mjs.map +1 -0
  57. package/dist/index.d.mts +1 -1
  58. package/dist/index.js +1 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/index.mjs +1 -0
  61. package/dist/index.mjs.map +1 -0
  62. package/dist/mime-types.js +1 -0
  63. package/dist/mime-types.js.map +1 -0
  64. package/dist/mime-types.mjs +1 -0
  65. package/dist/mime-types.mjs.map +1 -0
  66. package/dist/path.js +1 -0
  67. package/dist/path.js.map +1 -0
  68. package/dist/path.mjs +1 -0
  69. package/dist/path.mjs.map +1 -0
  70. package/dist/router.js +1 -0
  71. package/dist/router.js.map +1 -0
  72. package/dist/router.mjs +1 -0
  73. package/dist/router.mjs.map +1 -0
  74. package/dist/runtime.js +1 -0
  75. package/dist/runtime.js.map +1 -0
  76. package/dist/runtime.mjs +1 -0
  77. package/dist/runtime.mjs.map +1 -0
  78. package/dist/{server-Cz3z-5ls.d.mts → server-BFTzgJpO.d.mts} +62 -1
  79. package/dist/{server-BG2CaVMh.d.ts → server-CIXtexNS.d.ts} +62 -1
  80. package/dist/server.d.mts +1 -1
  81. package/dist/server.d.ts +9 -0
  82. package/dist/server.d.ts.map +1 -1
  83. package/dist/server.js +12 -0
  84. package/dist/server.js.map +1 -0
  85. package/dist/server.mjs +12 -0
  86. package/dist/server.mjs.map +1 -0
  87. package/dist/state.d.mts +1 -1
  88. package/dist/state.js +1 -0
  89. package/dist/state.js.map +1 -0
  90. package/dist/state.mjs +1 -0
  91. package/dist/state.mjs.map +1 -0
  92. package/dist/style.js +1 -0
  93. package/dist/style.js.map +1 -0
  94. package/dist/style.mjs +1 -0
  95. package/dist/style.mjs.map +1 -0
  96. package/dist/test-globals.d.ts +184 -0
  97. package/dist/test-reporter.d.mts +77 -0
  98. package/dist/test-reporter.d.ts +73 -0
  99. package/dist/test-reporter.d.ts.map +1 -0
  100. package/dist/test-reporter.js +726 -0
  101. package/dist/test-reporter.js.map +1 -0
  102. package/dist/test-reporter.mjs +696 -0
  103. package/dist/test-reporter.mjs.map +1 -0
  104. package/dist/test-runtime.d.mts +122 -0
  105. package/dist/test-runtime.d.ts +120 -0
  106. package/dist/test-runtime.d.ts.map +1 -0
  107. package/dist/test-runtime.js +1292 -0
  108. package/dist/test-runtime.js.map +1 -0
  109. package/dist/test-runtime.mjs +1269 -0
  110. package/dist/test-runtime.mjs.map +1 -0
  111. package/dist/test.d.mts +39 -0
  112. package/dist/test.d.ts +38 -0
  113. package/dist/test.d.ts.map +1 -0
  114. package/dist/test.js +4966 -0
  115. package/dist/test.js.map +1 -0
  116. package/dist/test.mjs +4944 -0
  117. package/dist/test.mjs.map +1 -0
  118. package/dist/types.d.mts +62 -1
  119. package/dist/types.d.ts +52 -0
  120. package/dist/types.d.ts.map +1 -1
  121. package/dist/types.js +1 -0
  122. package/dist/types.js.map +1 -0
  123. package/dist/types.mjs +1 -0
  124. package/dist/types.mjs.map +1 -0
  125. package/dist/ws.js +1 -0
  126. package/dist/ws.js.map +1 -0
  127. package/dist/ws.mjs +1 -0
  128. package/dist/ws.mjs.map +1 -0
  129. package/dist/wss.js +1 -0
  130. package/dist/wss.js.map +1 -0
  131. package/dist/wss.mjs +1 -0
  132. package/dist/wss.mjs.map +1 -0
  133. package/package.json +37 -5
  134. package/src/cli.ts +169 -1
  135. package/src/config.ts +3 -1
  136. package/src/coverage.ts +1479 -0
  137. package/src/database.ts +71 -35
  138. package/src/server.ts +12 -0
  139. package/src/test-globals.d.ts +184 -0
  140. package/src/test-reporter.ts +609 -0
  141. package/src/test-runtime.ts +1359 -0
  142. package/src/test.ts +368 -0
  143. package/src/types.ts +59 -0
@@ -0,0 +1,696 @@
1
+ import {createRequire as __createRequire} from 'module';const require = __createRequire(import.meta.url);
2
+
3
+ // src/runtime.ts
4
+ var runtime = (() => {
5
+ if (typeof Deno !== "undefined") return "deno";
6
+ if (typeof Bun !== "undefined") return "bun";
7
+ return "node";
8
+ })();
9
+ var isNode = runtime === "node";
10
+ var isBun = runtime === "bun";
11
+ var isDeno = runtime === "deno";
12
+
13
+ // src/path.ts
14
+ function getSeparator(isWin) {
15
+ return isWin ? "\\" : "/";
16
+ }
17
+ function getCwd() {
18
+ if (isNode || isBun) {
19
+ return process.cwd();
20
+ } else if (isDeno) {
21
+ return Deno.cwd();
22
+ }
23
+ return "/";
24
+ }
25
+ function findLastSeparator(path) {
26
+ return Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
27
+ }
28
+ function createPathOps(isWin) {
29
+ return {
30
+ sep: getSeparator(isWin),
31
+ delimiter: isWin ? ";" : ":",
32
+ normalize: (path) => normalizePath(path, isWin),
33
+ join: (...paths) => joinPaths(paths, isWin),
34
+ resolve: (...paths) => resolvePaths(paths, isWin),
35
+ isAbsolute: (path) => isWin ? isAbsoluteWin(path) : isAbsolutePosix(path),
36
+ relative: (from, to) => relativePath(from, to, isWin),
37
+ dirname: (path) => getDirname(path, isWin),
38
+ basename: (path, ext) => getBasename(path, ext, isWin),
39
+ extname: (path) => getExtname(path),
40
+ parse: (path) => parsePath(path, isWin),
41
+ format: (pathObject) => formatPath(pathObject, isWin)
42
+ };
43
+ }
44
+ function isAbsolutePosix(path) {
45
+ return path.length > 0 && path[0] === "/";
46
+ }
47
+ function isAbsoluteWin(path) {
48
+ const len = path.length;
49
+ if (len === 0) return false;
50
+ const code = path.charCodeAt(0);
51
+ if (code === 47 || code === 92) {
52
+ return true;
53
+ }
54
+ if (code >= 65 && code <= 90 || code >= 97 && code <= 122) {
55
+ if (len > 2 && path.charCodeAt(1) === 58) {
56
+ const code2 = path.charCodeAt(2);
57
+ if (code2 === 47 || code2 === 92) {
58
+ return true;
59
+ }
60
+ }
61
+ }
62
+ return false;
63
+ }
64
+ var isWindows = (() => {
65
+ if (isNode) {
66
+ return process.platform === "win32";
67
+ } else if (isDeno) {
68
+ return Deno.build.os === "windows";
69
+ }
70
+ return typeof process !== "undefined" && process.platform === "win32";
71
+ })();
72
+ var posix = createPathOps(false);
73
+ var win32 = createPathOps(true);
74
+ function normalizePath(path, isWin) {
75
+ if (path.length === 0) return ".";
76
+ const separator = getSeparator(isWin);
77
+ const isAbsolute = isWin ? isAbsoluteWin(path) : isAbsolutePosix(path);
78
+ const trailingSeparator = path[path.length - 1] === separator || isWin && path[path.length - 1] === "/";
79
+ let normalized = path.replace(isWin ? /[\/\\]+/g : /\/+/g, separator);
80
+ const parts = normalized.split(separator);
81
+ const result = [];
82
+ for (let i = 0; i < parts.length; i++) {
83
+ const part = parts[i];
84
+ if (part === "" || part === ".") {
85
+ if (i === 0 && isAbsolute) result.push("");
86
+ continue;
87
+ }
88
+ if (part === "..") {
89
+ if (result.length > 0 && result[result.length - 1] !== "..") {
90
+ if (!(result.length === 1 && result[0] === "")) {
91
+ result.pop();
92
+ }
93
+ } else if (!isAbsolute) {
94
+ result.push("..");
95
+ }
96
+ } else {
97
+ result.push(part);
98
+ }
99
+ }
100
+ let final = result.join(separator);
101
+ if (final.length === 0) {
102
+ return isAbsolute ? separator : ".";
103
+ }
104
+ if (trailingSeparator && final[final.length - 1] !== separator) {
105
+ final += separator;
106
+ }
107
+ return final;
108
+ }
109
+ function joinPaths(paths, isWin) {
110
+ if (paths.length === 0) return ".";
111
+ const separator = getSeparator(isWin);
112
+ let joined = "";
113
+ for (let i = 0; i < paths.length; i++) {
114
+ const path = paths[i];
115
+ if (path && path.length > 0) {
116
+ if (joined.length === 0) {
117
+ joined = path;
118
+ } else {
119
+ joined += separator + path;
120
+ }
121
+ }
122
+ }
123
+ if (joined.length === 0) return ".";
124
+ return normalizePath(joined, isWin);
125
+ }
126
+ function resolvePaths(paths, isWin) {
127
+ const separator = getSeparator(isWin);
128
+ let resolved = "";
129
+ let isAbsolute = false;
130
+ for (let i = paths.length - 1; i >= 0 && !isAbsolute; i--) {
131
+ const path = paths[i];
132
+ if (path && path.length > 0) {
133
+ resolved = path + (resolved.length > 0 ? separator + resolved : "");
134
+ isAbsolute = isWin ? isAbsoluteWin(resolved) : isAbsolutePosix(resolved);
135
+ }
136
+ }
137
+ if (!isAbsolute) {
138
+ const cwd = getCwd();
139
+ resolved = cwd + (resolved.length > 0 ? separator + resolved : "");
140
+ }
141
+ return normalizePath(resolved, isWin);
142
+ }
143
+ function relativePath(from, to, isWin) {
144
+ from = resolvePaths([from], isWin);
145
+ to = resolvePaths([to], isWin);
146
+ if (from === to) return "";
147
+ const separator = getSeparator(isWin);
148
+ const fromParts = from.split(separator).filter((p) => p.length > 0);
149
+ const toParts = to.split(separator).filter((p) => p.length > 0);
150
+ let commonLength = 0;
151
+ const minLength = Math.min(fromParts.length, toParts.length);
152
+ for (let i = 0; i < minLength; i++) {
153
+ if (fromParts[i] === toParts[i]) {
154
+ commonLength++;
155
+ } else {
156
+ break;
157
+ }
158
+ }
159
+ const upCount = fromParts.length - commonLength;
160
+ const result = [];
161
+ for (let i = 0; i < upCount; i++) {
162
+ result.push("..");
163
+ }
164
+ for (let i = commonLength; i < toParts.length; i++) {
165
+ result.push(toParts[i]);
166
+ }
167
+ return result.join(separator) || ".";
168
+ }
169
+ function getDirname(path, isWin) {
170
+ if (path.length === 0) return ".";
171
+ const separator = getSeparator(isWin);
172
+ const normalized = normalizePath(path, isWin);
173
+ const lastSepIndex = normalized.lastIndexOf(separator);
174
+ if (lastSepIndex === -1) return ".";
175
+ if (lastSepIndex === 0) return separator;
176
+ return normalized.slice(0, lastSepIndex);
177
+ }
178
+ function getBasename(path, ext, isWin) {
179
+ if (path.length === 0) return "";
180
+ const lastSepIndex = isWin ? findLastSeparator(path) : path.lastIndexOf("/");
181
+ let base = lastSepIndex === -1 ? path : path.slice(lastSepIndex + 1);
182
+ if (ext && base.endsWith(ext)) {
183
+ base = base.slice(0, base.length - ext.length);
184
+ }
185
+ return base;
186
+ }
187
+ function getExtname(path) {
188
+ const lastDotIndex = path.lastIndexOf(".");
189
+ const lastSepIndex = findLastSeparator(path);
190
+ if (lastDotIndex === -1 || lastDotIndex < lastSepIndex || lastDotIndex === path.length - 1) {
191
+ return "";
192
+ }
193
+ return path.slice(lastDotIndex);
194
+ }
195
+ function parsePath(path, isWin) {
196
+ let root = "";
197
+ if (isWin) {
198
+ if (path.length >= 2 && path[1] === ":") {
199
+ root = path.slice(0, 2);
200
+ if (path.length > 2 && (path[2] === "\\" || path[2] === "/")) {
201
+ root += "\\";
202
+ }
203
+ } else if (path[0] === "\\" || path[0] === "/") {
204
+ root = "\\";
205
+ }
206
+ } else {
207
+ if (path[0] === "/") {
208
+ root = "/";
209
+ }
210
+ }
211
+ const dir = getDirname(path, isWin);
212
+ const base = getBasename(path, void 0, isWin);
213
+ const ext = getExtname(path);
214
+ const name = ext ? base.slice(0, base.length - ext.length) : base;
215
+ return { root, dir, base, ext, name };
216
+ }
217
+ function formatPath(pathObject, isWin) {
218
+ const separator = getSeparator(isWin);
219
+ const dir = pathObject.dir || pathObject.root || "";
220
+ const base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
221
+ if (!dir) return base;
222
+ if (dir === pathObject.root) return dir + base;
223
+ return dir + separator + base;
224
+ }
225
+ function relative(from, to) {
226
+ return relativePath(from, to, isWindows);
227
+ }
228
+
229
+ // src/test-reporter.ts
230
+ var colors = {
231
+ reset: "\x1B[0m",
232
+ bold: "\x1B[1m",
233
+ dim: "\x1B[2m",
234
+ red: "\x1B[31m",
235
+ green: "\x1B[32m",
236
+ yellow: "\x1B[33m",
237
+ blue: "\x1B[34m",
238
+ cyan: "\x1B[36m",
239
+ white: "\x1B[37m"
240
+ };
241
+ function extractArg(code, functionName) {
242
+ const searchStr = `.${functionName}(`;
243
+ const startIndex = code.indexOf(searchStr);
244
+ if (startIndex === -1) return null;
245
+ let parenCount = 0;
246
+ let inString = false;
247
+ let stringChar = "";
248
+ let argStart = startIndex + searchStr.length;
249
+ for (let i = argStart; i < code.length; i++) {
250
+ const char = code[i];
251
+ if (!inString) {
252
+ if (char === "(") parenCount++;
253
+ else if (char === ")") {
254
+ parenCount--;
255
+ if (parenCount < 0) {
256
+ return code.slice(argStart, i);
257
+ }
258
+ } else if (char === '"' || char === "'" || char === "`") {
259
+ inString = true;
260
+ stringChar = char;
261
+ }
262
+ } else {
263
+ if (char === "\\" && i + 1 < code.length) {
264
+ i++;
265
+ } else if (char === stringChar) {
266
+ inString = false;
267
+ }
268
+ }
269
+ }
270
+ return null;
271
+ }
272
+ function extractReceivedValue(errorMsg) {
273
+ const receivedIndex = errorMsg.indexOf("Received:");
274
+ if (receivedIndex === -1) return null;
275
+ const afterReceived = errorMsg.slice(receivedIndex + 9).trimStart();
276
+ const newlineIndex = afterReceived.indexOf("\n");
277
+ if (newlineIndex !== -1) {
278
+ return afterReceived.slice(0, newlineIndex).trimEnd();
279
+ }
280
+ return afterReceived.trimEnd();
281
+ }
282
+ function parseQuotedString(str) {
283
+ if (str.length < 2) return null;
284
+ const firstChar = str[0];
285
+ const lastChar = str[str.length - 1];
286
+ if ((firstChar === '"' || firstChar === "'" || firstChar === "`") && firstChar === lastChar) {
287
+ return {
288
+ quote: firstChar,
289
+ content: str.slice(1, -1)
290
+ };
291
+ }
292
+ return null;
293
+ }
294
+ function stripQuotes(str) {
295
+ if (str.length < 2) return str;
296
+ const firstChar = str[0];
297
+ const lastChar = str[str.length - 1];
298
+ if ((firstChar === '"' || firstChar === "'" || firstChar === "`") && firstChar === lastChar) {
299
+ return str.slice(1, -1);
300
+ }
301
+ return str;
302
+ }
303
+ var TestReporter = class {
304
+ constructor(options = {}) {
305
+ this.startTime = 0;
306
+ this.currentFile = void 0;
307
+ this.fileTestCount = 0;
308
+ this.totalFiles = 0;
309
+ this.options = {
310
+ verbose: false,
311
+ colors: true,
312
+ ...options
313
+ };
314
+ }
315
+ c(color, text) {
316
+ return this.options.colors !== false ? colors[color] + text + colors.reset : text;
317
+ }
318
+ onRunStart(files) {
319
+ this.startTime = Date.now();
320
+ this.totalFiles = files.length;
321
+ console.log(`
322
+ ${this.c("bold", "Test Files")}: ${files.length}`);
323
+ console.log(`${this.c("dim", "\u2500".repeat(50))}
324
+ `);
325
+ }
326
+ onTestResult(result) {
327
+ const filePath = result.file ? relative(process.cwd(), result.file).split("\\").join("/") : void 0;
328
+ if (filePath !== this.currentFile) {
329
+ if (this.currentFile && this.fileTestCount > 0) {
330
+ console.log("");
331
+ }
332
+ this.currentFile = filePath;
333
+ this.fileTestCount = 0;
334
+ if (filePath) {
335
+ console.log(`${this.c("cyan", "\u25CF")} ${this.c("bold", filePath)}`);
336
+ console.log(`${this.c("dim", "\u2504".repeat(50))}`);
337
+ }
338
+ }
339
+ this.fileTestCount++;
340
+ if (result.status === "pass") {
341
+ console.log(` ${this.c("green", "\u2713")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("dim", `(${result.duration}ms)`)}`);
342
+ } else if (result.status === "fail") {
343
+ console.log(` ${this.c("red", "\u2715")} ${this.c("dim", result.suite + " > ")}${result.name}`);
344
+ if (result.error) {
345
+ const filePath2 = result.file;
346
+ if (filePath2) {
347
+ const relativePath2 = relative(process.cwd(), filePath2).split("\\").join("/");
348
+ const lineSuffix = result.lineNumber ? `:${result.lineNumber}` : "";
349
+ console.log(` ${this.c("cyan", `\u{1F4C4} ${relativePath2}${lineSuffix}`)}`);
350
+ }
351
+ const lines = result.error.message.split("\n");
352
+ for (const line of lines) {
353
+ if (line.includes("Expected:")) {
354
+ console.log(` ${this.c("green", "Expected:")} ${line.trim().replace("Expected:", "").trim()}`);
355
+ } else if (line.includes("Received:")) {
356
+ console.log(` ${this.c("red", "Received:")} ${line.trim().replace("Received:", "").trim()}`);
357
+ } else {
358
+ console.log(` ${this.c("red", line.trim())}`);
359
+ }
360
+ }
361
+ if (result.codeSnippet) {
362
+ let suggestion = "";
363
+ const code = result.codeSnippet;
364
+ const errorMsg = result.error?.message || "";
365
+ const receivedValue = extractReceivedValue(errorMsg);
366
+ if (code.includes(".toBeGreaterThanOrEqual(")) {
367
+ const currentValue = extractArg(code, "toBeGreaterThanOrEqual");
368
+ if (currentValue && receivedValue) {
369
+ const actualValue = Number(receivedValue);
370
+ if (!isNaN(actualValue)) {
371
+ suggestion = code.replace(
372
+ `.toBeGreaterThanOrEqual(${currentValue})`,
373
+ `.toBeGreaterThanOrEqual(${actualValue})`
374
+ );
375
+ }
376
+ }
377
+ } else if (code.includes(".toBeGreaterThan(")) {
378
+ const currentValue = extractArg(code, "toBeGreaterThan");
379
+ if (currentValue && receivedValue) {
380
+ const actualValue = Number(receivedValue);
381
+ if (!isNaN(actualValue)) {
382
+ suggestion = code.replace(
383
+ `.toBeGreaterThan(${currentValue})`,
384
+ `.toBeGreaterThan(${actualValue - 1})`
385
+ );
386
+ }
387
+ }
388
+ } else if (code.includes(".toBeLessThanOrEqual(")) {
389
+ const currentValue = extractArg(code, "toBeLessThanOrEqual");
390
+ if (currentValue && receivedValue) {
391
+ const actualValue = Number(receivedValue);
392
+ if (!isNaN(actualValue)) {
393
+ suggestion = code.replace(
394
+ `.toBeLessThanOrEqual(${currentValue})`,
395
+ `.toBeLessThanOrEqual(${actualValue})`
396
+ );
397
+ }
398
+ }
399
+ } else if (code.includes(".toBeLessThan(")) {
400
+ const currentValue = extractArg(code, "toBeLessThan");
401
+ if (currentValue && receivedValue) {
402
+ const actualValue = Number(receivedValue);
403
+ if (!isNaN(actualValue)) {
404
+ suggestion = code.replace(
405
+ `.toBeLessThan(${currentValue})`,
406
+ `.toBeLessThan(${actualValue + 1})`
407
+ );
408
+ }
409
+ }
410
+ } else if (code.includes(".toStrictEqual(")) {
411
+ const expectedValue = extractArg(code, "toStrictEqual");
412
+ if (expectedValue && receivedValue) {
413
+ const quoted = parseQuotedString(expectedValue);
414
+ if (quoted) {
415
+ const strippedReceived = stripQuotes(receivedValue);
416
+ suggestion = code.replace(
417
+ `.toStrictEqual(${expectedValue})`,
418
+ `.toStrictEqual(${quoted.quote}${strippedReceived}${quoted.quote})`
419
+ );
420
+ } else {
421
+ suggestion = code.replace(
422
+ `.toStrictEqual(${expectedValue})`,
423
+ `.toStrictEqual(${receivedValue})`
424
+ );
425
+ }
426
+ }
427
+ } else if (code.includes(".toEqual(")) {
428
+ const expectedValue = extractArg(code, "toEqual");
429
+ if (expectedValue && receivedValue) {
430
+ const quoted = parseQuotedString(expectedValue);
431
+ if (quoted) {
432
+ const strippedReceived = stripQuotes(receivedValue);
433
+ suggestion = code.replace(
434
+ `.toEqual(${expectedValue})`,
435
+ `.toEqual(${quoted.quote}${strippedReceived}${quoted.quote})`
436
+ );
437
+ } else {
438
+ suggestion = code.replace(
439
+ `.toEqual(${expectedValue})`,
440
+ `.toEqual(${receivedValue})`
441
+ );
442
+ }
443
+ }
444
+ } else if (code.includes(".toMatch(")) {
445
+ const expectedPattern = extractArg(code, "toMatch");
446
+ if (expectedPattern && receivedValue) {
447
+ const quoted = parseQuotedString(expectedPattern);
448
+ if (quoted) {
449
+ const strippedReceived = stripQuotes(receivedValue);
450
+ suggestion = code.replace(
451
+ `.toMatch(${expectedPattern})`,
452
+ `.toMatch(${quoted.quote}${strippedReceived}${quoted.quote})`
453
+ );
454
+ }
455
+ }
456
+ } else if (code.includes(".toContain(")) {
457
+ const expectedValue = extractArg(code, "toContain");
458
+ if (expectedValue && receivedValue) {
459
+ const quoted = parseQuotedString(expectedValue);
460
+ if (quoted) {
461
+ const strippedReceived = stripQuotes(receivedValue);
462
+ suggestion = code.replace(
463
+ `.toContain(${expectedValue})`,
464
+ `.toContain(${quoted.quote}${strippedReceived}${quoted.quote})`
465
+ );
466
+ } else {
467
+ suggestion = code.replace(
468
+ `.toContain(${expectedValue})`,
469
+ `.toContain(${receivedValue})`
470
+ );
471
+ }
472
+ }
473
+ } else if (code.includes(".toHaveLength(")) {
474
+ const expectedLength = extractArg(code, "toHaveLength");
475
+ if (expectedLength && receivedValue) {
476
+ const actualLength = Number(receivedValue);
477
+ if (!isNaN(actualLength)) {
478
+ suggestion = code.replace(
479
+ `.toHaveLength(${expectedLength})`,
480
+ `.toHaveLength(${actualLength})`
481
+ );
482
+ }
483
+ }
484
+ } else if (code.includes(".toBe(")) {
485
+ const expectedValue = extractArg(code, "toBe");
486
+ if (expectedValue) {
487
+ if (receivedValue) {
488
+ const quoted = parseQuotedString(expectedValue);
489
+ if (quoted) {
490
+ const strippedReceived = stripQuotes(receivedValue);
491
+ suggestion = code.replace(
492
+ `.toBe(${expectedValue})`,
493
+ `.toBe(${quoted.quote}${strippedReceived}${quoted.quote})`
494
+ );
495
+ } else {
496
+ suggestion = code.replace(
497
+ `.toBe(${expectedValue})`,
498
+ `.toBe(${receivedValue})`
499
+ );
500
+ }
501
+ } else if (expectedValue.includes("'") || expectedValue.includes('"')) {
502
+ suggestion = code.replace(".toBe(", ".toEqual(");
503
+ }
504
+ }
505
+ } else if (code.includes(".toBeDefined()")) {
506
+ suggestion = code.replace(".toBeDefined()", ".toBeTruthy()");
507
+ } else if (code.includes(".toBeNull()")) {
508
+ suggestion = code.replace(".toBeNull()", ".toBeUndefined()");
509
+ } else if (code.includes(".toBeUndefined()")) {
510
+ suggestion = code.replace(".toBeUndefined()", ".toBeNull()");
511
+ } else if (code.includes(".toBeTruthy()")) {
512
+ suggestion = code.replace(".toBeTruthy()", ".toBeDefined()");
513
+ } else if (code.includes(".toBeFalsy()")) {
514
+ suggestion = code.replace(".toBeFalsy()", ".toBeUndefined()");
515
+ }
516
+ console.log(` ${this.c("dim", "Code:")}`);
517
+ console.log(` ${this.c("dim", code)}`);
518
+ if (suggestion && suggestion !== code) {
519
+ console.log(` ${this.c("yellow", "example \u2192")} ${this.c("green", suggestion)}`);
520
+ }
521
+ }
522
+ if (this.options.verbose && result.error.stack) {
523
+ const stack = result.error.stack.split("\n").slice(1, 3).join("\n");
524
+ console.log(` ${this.c("dim", stack)}`);
525
+ }
526
+ }
527
+ } else if (result.status === "skip") {
528
+ console.log(` ${this.c("yellow", "\u25CB")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("yellow", "(skipped)")}`);
529
+ } else if (result.status === "todo") {
530
+ console.log(` ${this.c("cyan", "\u25CB")} ${this.c("dim", result.suite + " > ")}${result.name} ${this.c("cyan", "(todo)")}`);
531
+ }
532
+ }
533
+ onRunEnd(results) {
534
+ const duration = Date.now() - this.startTime;
535
+ const passed = results.filter((r) => r.status === "pass").length;
536
+ const failed = results.filter((r) => r.status === "fail").length;
537
+ const skipped = results.filter((r) => r.status === "skip").length;
538
+ const total = results.length;
539
+ if (this.currentFile && this.fileTestCount > 0) {
540
+ console.log("");
541
+ }
542
+ console.log(`${this.c("dim", "\u2500".repeat(50))}`);
543
+ console.log("");
544
+ console.log(`${this.c("bold", "Test Suites:")} ${this.c("green", `${this.totalFiles} passed`)}${this.c("dim", `, ${this.totalFiles} total`)}`);
545
+ console.log(`${this.c("bold", "Tests:")} ${this.c("green", `${passed} passed`)}${failed > 0 ? `, ${this.c("red", `${failed} failed`)}` : ""}${skipped > 0 ? `, ${this.c("yellow", `${skipped} skipped`)}` : ""}${this.c("dim", `, ${total} total`)}`);
546
+ console.log(`${this.c("bold", "Snapshots:")} ${this.c("dim", "0 total")}`);
547
+ console.log(`${this.c("bold", "Time:")} ${this.c("dim", `${(duration / 1e3).toFixed(2)}s`)}`);
548
+ console.log("");
549
+ }
550
+ };
551
+ var DotReporter = class {
552
+ constructor() {
553
+ this.passed = 0;
554
+ this.failed = 0;
555
+ this.skipped = 0;
556
+ this.todo = 0;
557
+ this.lineLength = 0;
558
+ }
559
+ onRunStart(files) {
560
+ console.log(`
561
+ ${files.length} test files
562
+ `);
563
+ }
564
+ onTestResult(result) {
565
+ const symbol = result.status === "pass" ? "." : result.status === "fail" ? this.c("red", "F") : result.status === "skip" ? this.c("yellow", "o") : this.c("cyan", "o");
566
+ process.stdout.write(symbol);
567
+ this.lineLength++;
568
+ if (result.status === "pass") this.passed++;
569
+ else if (result.status === "fail") this.failed++;
570
+ else if (result.status === "skip") this.skipped++;
571
+ else if (result.status === "todo") this.todo++;
572
+ if (this.lineLength >= 50) {
573
+ process.stdout.write("\n ");
574
+ this.lineLength = 0;
575
+ }
576
+ }
577
+ onRunEnd(_results) {
578
+ console.log(`
579
+
580
+ ${this.c("green", this.passed + " passed")} ${this.c("dim", "\xB7")} ${this.c("red", this.failed + " failed")} ${this.c("dim", "\xB7")} ${this.c("yellow", this.skipped + " skipped")}
581
+ `);
582
+ }
583
+ c(color, text) {
584
+ return colors[color] + text + colors.reset;
585
+ }
586
+ };
587
+ var JsonReporter = class {
588
+ constructor() {
589
+ this.startTime = 0;
590
+ this.results = [];
591
+ }
592
+ onRunStart(_files) {
593
+ this.startTime = Date.now();
594
+ this.results = [];
595
+ }
596
+ onTestResult(result) {
597
+ this.results.push(result);
598
+ }
599
+ onRunEnd(results) {
600
+ const report = {
601
+ summary: {
602
+ total: results.length,
603
+ passed: results.filter((r) => r.status === "pass").length,
604
+ failed: results.filter((r) => r.status === "fail").length,
605
+ skipped: results.filter((r) => r.status === "skip").length,
606
+ todo: results.filter((r) => r.status === "todo").length,
607
+ duration: Date.now() - this.startTime
608
+ },
609
+ tests: results.map((r) => ({
610
+ status: r.status === "pass" ? "passed" : r.status === "fail" ? "failed" : r.status === "skip" ? "skipped" : "todo",
611
+ name: r.name,
612
+ suite: r.suite,
613
+ duration: r.duration,
614
+ error: r.error ? {
615
+ message: r.error.message,
616
+ stack: r.error.stack
617
+ } : void 0
618
+ }))
619
+ };
620
+ console.log(JSON.stringify(report, null, 2));
621
+ }
622
+ };
623
+ var VerboseReporter = class {
624
+ constructor() {
625
+ this.currentSuite = "";
626
+ }
627
+ onRunStart(_files) {
628
+ console.log(`
629
+ ${colors.cyan}Running tests${colors.reset}
630
+ `);
631
+ }
632
+ onTestResult(result) {
633
+ if (result.suite !== this.currentSuite) {
634
+ this.currentSuite = result.suite;
635
+ console.log(`
636
+ ${colors.dim}${result.suite}${colors.reset}`);
637
+ }
638
+ const icon = result.status === "pass" ? colors.green + " \u2713" : result.status === "fail" ? colors.red + " \u2715" : result.status === "skip" ? colors.yellow + " \u2298" : colors.cyan + " \u25CB";
639
+ console.log(`${icon}${colors.reset} ${result.name}${colors.dim} (${result.duration}ms)${colors.reset}`);
640
+ if (result.status === "fail" && result.error) {
641
+ console.log(`
642
+ ${colors.red} ${result.error.message}${colors.reset}`);
643
+ if (result.error.stack) {
644
+ const lines = result.error.stack.split("\n").slice(1, 4);
645
+ lines.forEach((line) => console.log(`${colors.dim} ${line}${colors.reset}`));
646
+ }
647
+ }
648
+ }
649
+ onRunEnd(results) {
650
+ const passed = results.filter((r) => r.status === "pass").length;
651
+ const failed = results.filter((r) => r.status === "fail").length;
652
+ const skipped = results.filter((r) => r.status === "skip").length;
653
+ console.log(`
654
+ ${colors.dim}${"\u2500".repeat(50)}${colors.reset}
655
+ `);
656
+ if (failed === 0) {
657
+ console.log(`${colors.green}All tests passed!${colors.reset}`);
658
+ console.log(`${colors.dim}${passed} tests${colors.reset}
659
+ `);
660
+ } else {
661
+ console.log(`${colors.red}${failed} tests failed${colors.reset}`);
662
+ console.log(`${colors.green}${passed} tests passed${colors.reset}`);
663
+ if (skipped > 0) {
664
+ console.log(`${colors.yellow}${skipped} tests skipped${colors.reset}`);
665
+ }
666
+ console.log("");
667
+ }
668
+ }
669
+ };
670
+ function formatErrorStack(error) {
671
+ if (!error.stack) return error.message;
672
+ const lines = error.stack.split("\n");
673
+ let formatted = `${error.message}
674
+ `;
675
+ for (const line of lines.slice(1, 6)) {
676
+ formatted += ` ${line.trim()}
677
+ `;
678
+ }
679
+ return formatted;
680
+ }
681
+ function formatProgress(current, total) {
682
+ const percentage = Math.floor(current / total * 100);
683
+ const filled = Math.floor(percentage / 2);
684
+ const empty = 50 - filled;
685
+ const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
686
+ return `[${bar}] ${percentage}% (${current}/${total})`;
687
+ }
688
+ export {
689
+ DotReporter,
690
+ JsonReporter,
691
+ TestReporter,
692
+ VerboseReporter,
693
+ formatErrorStack,
694
+ formatProgress
695
+ };
696
+ //# sourceMappingURL=test-reporter.mjs.map