vitest 3.2.0-beta.3 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +29 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.D4119yLM.js → base.Cg0miDlQ.js} +10 -14
- package/dist/chunks/{benchmark.Cf_PACH1.js → benchmark.CYdenmiT.js} +4 -6
- package/dist/chunks/{cac.DWaWHIIE.js → cac.C8BzMmTW.js} +66 -136
- package/dist/chunks/{cli-api.CnmEXkxs.js → cli-api.DmupRhea.js} +1251 -1336
- package/dist/chunks/{console.Cwr-MFPV.js → console.CtFJOzRO.js} +24 -45
- package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
- package/dist/chunks/{coverage.C73DaDgS.js → coverage.EIiagJJP.js} +484 -1003
- package/dist/chunks/{creator.C8WKy2eW.js → creator.GK6I-cL4.js} +29 -76
- package/dist/chunks/{date.ByMsSlOr.js → date.Bq6ZW5rf.js} +3 -8
- package/dist/chunks/{defaults.DpVH7vbg.js → defaults.B7q_naMc.js} +1 -1
- package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
- package/dist/chunks/{execute.B3q-2LPV.js → execute.B7h3T_Hc.js} +104 -220
- package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
- package/dist/chunks/{global.d.BNLIi6yo.d.ts → global.d.MAmajcmJ.d.ts} +2 -0
- package/dist/chunks/{globals.CI21aWXF.js → globals.DEHgCU4V.js} +5 -5
- package/dist/chunks/{index.Bter3jj9.js → index.BZ0g1JD2.js} +366 -628
- package/dist/chunks/{index.CbT4iuwc.js → index.BbB8_kAK.js} +22 -24
- package/dist/chunks/{index.JOzufsrU.js → index.CIyJn3t1.js} +37 -82
- package/dist/chunks/{index.DNgLEKsQ.js → index.CdQS2e2Q.js} +2 -2
- package/dist/chunks/{index.2jgTs_Q5.js → index.CmSc2RE5.js} +69 -107
- package/dist/chunks/{inspector.BFsh5KO0.js → inspector.C914Efll.js} +1 -1
- package/dist/chunks/{node.Be-ntJnD.js → node.fjCdwEIl.js} +1 -1
- package/dist/chunks/{reporters.d.Bt4IGtsa.d.ts → reporters.d.C1ogPriE.d.ts} +24 -4
- package/dist/chunks/{rpc.BKExFSRG.js → rpc.Iovn4oWe.js} +9 -19
- package/dist/chunks/{runBaseTests.B_M1TTsK.js → runBaseTests.Dd85QTll.js} +18 -31
- package/dist/chunks/{setup-common.CF-O-dZX.js → setup-common.Dd054P77.js} +15 -42
- package/dist/chunks/{typechecker.BgzF-6iO.js → typechecker.DRKU1-1g.js} +106 -186
- package/dist/chunks/{utils.DPCq3gzW.js → utils.CAioKnHs.js} +6 -14
- package/dist/chunks/{utils.BlI4TC7Y.js → utils.XdZDrNZV.js} +5 -13
- package/dist/chunks/{vi.pkoYCV6A.js → vi.bdSIJ99Y.js} +118 -267
- package/dist/chunks/{vite.d.B-Kx3KCF.d.ts → vite.d.DqE4-hhK.d.ts} +1 -1
- package/dist/chunks/{vm.DPYem2so.js → vm.BThCzidc.js} +98 -214
- package/dist/chunks/{worker.d.Bl1O4kuf.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
- package/dist/chunks/{worker.d.BKbBp2ga.d.ts → worker.d.tQu2eJQy.d.ts} +3 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +2 -2
- package/dist/coverage.d.ts +2 -2
- package/dist/coverage.js +5 -5
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.js +5 -5
- package/dist/node.d.ts +7 -7
- package/dist/node.js +12 -14
- package/dist/reporters.d.ts +2 -2
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +5 -2
- package/dist/runners.js +51 -80
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +36 -42
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +15 -21
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +10 -10
- package/package.json +16 -14
|
@@ -3,37 +3,29 @@ import { relative } from 'node:path';
|
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
4
|
import { getSafeTimers } from '@vitest/utils';
|
|
5
5
|
import c from 'tinyrainbow';
|
|
6
|
-
import { R as RealDate } from './date.
|
|
7
|
-
import { g as getWorkerState } from './utils.
|
|
6
|
+
import { R as RealDate } from './date.Bq6ZW5rf.js';
|
|
7
|
+
import { g as getWorkerState } from './utils.XdZDrNZV.js';
|
|
8
8
|
|
|
9
9
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
10
10
|
function getTaskIdByStack(root) {
|
|
11
11
|
const stack = new Error("STACK_TRACE_ERROR").stack?.split("\n");
|
|
12
|
-
if (!stack)
|
|
13
|
-
return UNKNOWN_TEST_ID;
|
|
14
|
-
}
|
|
12
|
+
if (!stack) return UNKNOWN_TEST_ID;
|
|
15
13
|
const index = stack.findIndex((line) => line.includes("at Console.value"));
|
|
16
14
|
const line = index === -1 ? null : stack[index + 2];
|
|
17
|
-
if (!line)
|
|
18
|
-
return UNKNOWN_TEST_ID;
|
|
19
|
-
}
|
|
15
|
+
if (!line) return UNKNOWN_TEST_ID;
|
|
20
16
|
const filepath = line.match(/at\s(.*)\s?/)?.[1];
|
|
21
|
-
if (filepath)
|
|
22
|
-
return relative(root, filepath);
|
|
23
|
-
}
|
|
17
|
+
if (filepath) return relative(root, filepath);
|
|
24
18
|
return UNKNOWN_TEST_ID;
|
|
25
19
|
}
|
|
26
20
|
function createCustomConsole(defaultState) {
|
|
27
|
-
const stdoutBuffer = new Map();
|
|
28
|
-
const stderrBuffer = new Map();
|
|
29
|
-
const timers = new Map();
|
|
21
|
+
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
22
|
+
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
23
|
+
const timers = /* @__PURE__ */ new Map();
|
|
30
24
|
const { queueMicrotask } = getSafeTimers();
|
|
31
25
|
function queueCancelableMicrotask(callback) {
|
|
32
26
|
let canceled = false;
|
|
33
27
|
queueMicrotask(() => {
|
|
34
|
-
if (!canceled)
|
|
35
|
-
callback();
|
|
36
|
-
}
|
|
28
|
+
if (!canceled) callback();
|
|
37
29
|
});
|
|
38
30
|
return () => {
|
|
39
31
|
canceled = true;
|
|
@@ -64,24 +56,18 @@ function createCustomConsole(defaultState) {
|
|
|
64
56
|
function sendBuffer(type, taskId) {
|
|
65
57
|
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer;
|
|
66
58
|
const buffer = buffers.get(taskId);
|
|
67
|
-
if (!buffer)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
|
73
|
-
});
|
|
74
|
-
} else {
|
|
59
|
+
if (!buffer) return;
|
|
60
|
+
if (state().config.printConsoleTrace) buffer.forEach(([buffer, origin]) => {
|
|
61
|
+
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
|
62
|
+
});
|
|
63
|
+
else {
|
|
75
64
|
const content = buffer.map((i) => String(i[0])).join("");
|
|
76
65
|
sendLog(type, taskId, content, buffer.length);
|
|
77
66
|
}
|
|
78
67
|
const timer = timers.get(taskId);
|
|
79
68
|
buffers.delete(taskId);
|
|
80
|
-
if (type === "stderr")
|
|
81
|
-
|
|
82
|
-
} else {
|
|
83
|
-
timer.stdoutTime = 0;
|
|
84
|
-
}
|
|
69
|
+
if (type === "stderr") timer.stderrTime = 0;
|
|
70
|
+
else timer.stdoutTime = 0;
|
|
85
71
|
}
|
|
86
72
|
function sendLog(type, taskId, content, size, origin) {
|
|
87
73
|
const timer = timers.get(taskId);
|
|
@@ -99,9 +85,8 @@ function createCustomConsole(defaultState) {
|
|
|
99
85
|
const s = state();
|
|
100
86
|
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
101
87
|
let timer = timers.get(id);
|
|
102
|
-
if (timer)
|
|
103
|
-
|
|
104
|
-
} else {
|
|
88
|
+
if (timer) timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
89
|
+
else {
|
|
105
90
|
timer = {
|
|
106
91
|
stdoutTime: RealDate.now(),
|
|
107
92
|
stderrTime: RealDate.now()
|
|
@@ -120,9 +105,7 @@ function createCustomConsole(defaultState) {
|
|
|
120
105
|
const trace = stack?.split("\n").slice(7).join("\n");
|
|
121
106
|
Error.stackTraceLimit = limit;
|
|
122
107
|
buffer.push([data, trace]);
|
|
123
|
-
} else
|
|
124
|
-
buffer.push([data, undefined]);
|
|
125
|
-
}
|
|
108
|
+
} else buffer.push([data, void 0]);
|
|
126
109
|
schedule(id);
|
|
127
110
|
callback();
|
|
128
111
|
} });
|
|
@@ -130,9 +113,8 @@ function createCustomConsole(defaultState) {
|
|
|
130
113
|
const s = state();
|
|
131
114
|
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
132
115
|
let timer = timers.get(id);
|
|
133
|
-
if (timer)
|
|
134
|
-
|
|
135
|
-
} else {
|
|
116
|
+
if (timer) timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
117
|
+
else {
|
|
136
118
|
timer = {
|
|
137
119
|
stderrTime: RealDate.now(),
|
|
138
120
|
stdoutTime: RealDate.now()
|
|
@@ -150,16 +132,13 @@ function createCustomConsole(defaultState) {
|
|
|
150
132
|
const stack = new Error("STACK_TRACE").stack?.split("\n");
|
|
151
133
|
Error.stackTraceLimit = limit;
|
|
152
134
|
const isTrace = stack?.some((line) => line.includes("at Console.trace"));
|
|
153
|
-
if (isTrace)
|
|
154
|
-
|
|
155
|
-
} else {
|
|
135
|
+
if (isTrace) buffer.push([data, void 0]);
|
|
136
|
+
else {
|
|
156
137
|
const trace = stack?.slice(7).join("\n");
|
|
157
138
|
Error.stackTraceLimit = limit;
|
|
158
139
|
buffer.push([data, trace]);
|
|
159
140
|
}
|
|
160
|
-
} else
|
|
161
|
-
buffer.push([data, undefined]);
|
|
162
|
-
}
|
|
141
|
+
} else buffer.push([data, void 0]);
|
|
163
142
|
schedule(id);
|
|
164
143
|
callback();
|
|
165
144
|
} });
|
|
@@ -3,19 +3,13 @@ const CoverageProviderMap = {
|
|
|
3
3
|
istanbul: "@vitest/coverage-istanbul"
|
|
4
4
|
};
|
|
5
5
|
async function resolveCoverageProviderModule(options, loader) {
|
|
6
|
-
if (!options?.enabled || !options.provider)
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
6
|
+
if (!options?.enabled || !options.provider) return null;
|
|
9
7
|
const provider = options.provider;
|
|
10
8
|
if (provider === "v8" || provider === "istanbul") {
|
|
11
9
|
let builtInModule = CoverageProviderMap[provider];
|
|
12
|
-
if (provider === "v8" && loader.isBrowser)
|
|
13
|
-
builtInModule += "/browser";
|
|
14
|
-
}
|
|
10
|
+
if (provider === "v8" && loader.isBrowser) builtInModule += "/browser";
|
|
15
11
|
const { default: coverageModule } = await loader.executeId(builtInModule);
|
|
16
|
-
if (!coverageModule) {
|
|
17
|
-
throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
|
|
18
|
-
}
|
|
12
|
+
if (!coverageModule) throw new Error(`Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`);
|
|
19
13
|
return coverageModule;
|
|
20
14
|
}
|
|
21
15
|
let customProviderModule;
|
|
@@ -24,9 +18,7 @@ async function resolveCoverageProviderModule(options, loader) {
|
|
|
24
18
|
} catch (error) {
|
|
25
19
|
throw new Error(`Failed to load custom CoverageProviderModule from ${options.customProviderModule}`, { cause: error });
|
|
26
20
|
}
|
|
27
|
-
if (customProviderModule.default == null) {
|
|
28
|
-
throw new Error(`Custom CoverageProviderModule loaded from ${options.customProviderModule} was not the default export`);
|
|
29
|
-
}
|
|
21
|
+
if (customProviderModule.default == null) throw new Error(`Custom CoverageProviderModule loaded from ${options.customProviderModule} was not the default export`);
|
|
30
22
|
return customProviderModule.default;
|
|
31
23
|
}
|
|
32
24
|
|