vitest 3.2.0-beta.2 → 3.2.0
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 +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.DwtwORaC.js → base.Cg0miDlQ.js} +11 -14
- package/dist/chunks/{benchmark.BoF7jW0Q.js → benchmark.CYdenmiT.js} +4 -6
- package/dist/chunks/{cac.I9MLYfT-.js → cac.6rXCxFY1.js} +76 -143
- package/dist/chunks/{cli-api.d6IK1pnk.js → cli-api.Cej3MBjA.js} +1460 -1344
- package/dist/chunks/{config.d.UqE-KR0o.d.ts → config.d.D2ROskhv.d.ts} +2 -0
- package/dist/chunks/{console.K1NMVOSc.js → console.CtFJOzRO.js} +25 -45
- package/dist/chunks/{constants.BZZyIeIE.js → constants.DnKduX2e.js} +1 -0
- package/dist/chunks/{coverage.0iPg4Wrz.js → coverage.DVF1vEu8.js} +4 -12
- package/dist/chunks/{coverage.OGU09Jbh.js → coverage.EIiagJJP.js} +578 -993
- package/dist/chunks/{creator.DGAdZ4Hj.js → creator.GK6I-cL4.js} +39 -83
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/{defaults.DSxsTG0h.js → defaults.B7q_naMc.js} +2 -1
- package/dist/chunks/{env.Dq0hM4Xv.js → env.D4Lgay0q.js} +1 -1
- package/dist/chunks/{environment.d.D8YDy2v5.d.ts → environment.d.cL3nLXbE.d.ts} +1 -0
- package/dist/chunks/{execute.JlGHLJZT.js → execute.B7h3T_Hc.js} +126 -217
- package/dist/chunks/{git.DXfdBEfR.js → git.BVQ8w_Sw.js} +1 -3
- package/dist/chunks/{global.d.BPa1eL3O.d.ts → global.d.MAmajcmJ.d.ts} +5 -1
- package/dist/chunks/{globals.CpxW8ccg.js → globals.DEHgCU4V.js} +7 -6
- package/dist/chunks/{index.CV36oG_L.js → index.BZ0g1JD2.js} +430 -625
- package/dist/chunks/{index.DswW_LEs.js → index.BbB8_kAK.js} +25 -24
- package/dist/chunks/{index.CmC5OK9L.js → index.CIyJn3t1.js} +38 -82
- package/dist/chunks/{index.CfXMNXHg.js → index.CdQS2e2Q.js} +4 -2
- package/dist/chunks/{index.DFXFpH3w.js → index.CmSc2RE5.js} +85 -105
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/{inspector.DbDkSkFn.js → inspector.C914Efll.js} +4 -1
- package/dist/chunks/{node.3xsWotC9.js → node.fjCdwEIl.js} +1 -1
- package/dist/chunks/{reporters.d.CLC9rhKy.d.ts → reporters.d.C1ogPriE.d.ts} +47 -9
- package/dist/chunks/{rpc.D9_013TY.js → rpc.Iovn4oWe.js} +10 -19
- package/dist/chunks/{runBaseTests.Dn2vyej_.js → runBaseTests.Dd85QTll.js} +27 -31
- package/dist/chunks/{setup-common.CYo3Y0dD.js → setup-common.Dd054P77.js} +16 -42
- package/dist/chunks/{typechecker.DnTrplSJ.js → typechecker.DRKU1-1g.js} +163 -186
- package/dist/chunks/{utils.BfxieIyZ.js → utils.CAioKnHs.js} +9 -14
- package/dist/chunks/{utils.CgTj3MsC.js → utils.XdZDrNZV.js} +6 -13
- package/dist/chunks/{vi.BFR5YIgu.js → vi.bdSIJ99Y.js} +137 -263
- package/dist/chunks/{vite.d.CBZ3M_ru.d.ts → vite.d.DqE4-hhK.d.ts} +3 -1
- package/dist/chunks/{vm.C1HHjtNS.js → vm.BThCzidc.js} +164 -212
- package/dist/chunks/{worker.d.D5Xdi-Zr.d.ts → worker.d.DvqK5Vmu.d.ts} +1 -1
- package/dist/chunks/{worker.d.CoCI7hzP.d.ts → worker.d.tQu2eJQy.d.ts} +5 -3
- package/dist/cli.js +5 -5
- package/dist/config.cjs +3 -1
- package/dist/config.d.ts +7 -6
- package/dist/config.js +3 -3
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +7 -7
- package/dist/environments.d.ts +6 -2
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +9 -3
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +28 -15
- package/dist/index.js +5 -5
- package/dist/node.d.ts +18 -10
- package/dist/node.js +17 -17
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +4 -4
- package/dist/runners.d.ts +6 -3
- package/dist/runners.js +59 -80
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +39 -41
- package/dist/workers/forks.js +6 -4
- package/dist/workers/runVmTests.js +20 -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 +4 -4
- package/dist/workers.js +10 -10
- package/package.json +21 -19
- package/dist/chunks/date.CDOsz-HY.js +0 -53
- package/dist/chunks/index.CK1YOQaa.js +0 -143
|
@@ -94,6 +94,7 @@ interface SerializedConfig {
|
|
|
94
94
|
restoreMocks: boolean;
|
|
95
95
|
unstubGlobals: boolean;
|
|
96
96
|
unstubEnvs: boolean;
|
|
97
|
+
// TODO: make optional
|
|
97
98
|
fakeTimers: FakeTimerInstallOpts;
|
|
98
99
|
maxConcurrency: number;
|
|
99
100
|
defines: Record<string, any>;
|
|
@@ -189,6 +190,7 @@ interface SerializedConfig {
|
|
|
189
190
|
}
|
|
190
191
|
screenshotFailures: boolean
|
|
191
192
|
providerOptions: {
|
|
193
|
+
// for playwright
|
|
192
194
|
actionTimeout?: number
|
|
193
195
|
}
|
|
194
196
|
};
|
|
@@ -3,43 +3,36 @@ 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;
|
|
40
32
|
};
|
|
41
33
|
}
|
|
42
34
|
const state = () => defaultState || getWorkerState();
|
|
35
|
+
// group sync console.log calls with micro task
|
|
43
36
|
function schedule(taskId) {
|
|
44
37
|
const timer = timers.get(taskId);
|
|
45
38
|
const { stdoutTime, stderrTime } = timer;
|
|
@@ -63,24 +56,18 @@ function createCustomConsole(defaultState) {
|
|
|
63
56
|
function sendBuffer(type, taskId) {
|
|
64
57
|
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer;
|
|
65
58
|
const buffer = buffers.get(taskId);
|
|
66
|
-
if (!buffer)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
|
72
|
-
});
|
|
73
|
-
} 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 {
|
|
74
64
|
const content = buffer.map((i) => String(i[0])).join("");
|
|
75
65
|
sendLog(type, taskId, content, buffer.length);
|
|
76
66
|
}
|
|
77
67
|
const timer = timers.get(taskId);
|
|
78
68
|
buffers.delete(taskId);
|
|
79
|
-
if (type === "stderr")
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
timer.stdoutTime = 0;
|
|
83
|
-
}
|
|
69
|
+
if (type === "stderr") timer.stderrTime = 0;
|
|
70
|
+
else timer.stdoutTime = 0;
|
|
84
71
|
}
|
|
85
72
|
function sendLog(type, taskId, content, size, origin) {
|
|
86
73
|
const timer = timers.get(taskId);
|
|
@@ -98,9 +85,8 @@ function createCustomConsole(defaultState) {
|
|
|
98
85
|
const s = state();
|
|
99
86
|
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
100
87
|
let timer = timers.get(id);
|
|
101
|
-
if (timer)
|
|
102
|
-
|
|
103
|
-
} else {
|
|
88
|
+
if (timer) timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
89
|
+
else {
|
|
104
90
|
timer = {
|
|
105
91
|
stdoutTime: RealDate.now(),
|
|
106
92
|
stderrTime: RealDate.now()
|
|
@@ -119,9 +105,7 @@ function createCustomConsole(defaultState) {
|
|
|
119
105
|
const trace = stack?.split("\n").slice(7).join("\n");
|
|
120
106
|
Error.stackTraceLimit = limit;
|
|
121
107
|
buffer.push([data, trace]);
|
|
122
|
-
} else
|
|
123
|
-
buffer.push([data, undefined]);
|
|
124
|
-
}
|
|
108
|
+
} else buffer.push([data, void 0]);
|
|
125
109
|
schedule(id);
|
|
126
110
|
callback();
|
|
127
111
|
} });
|
|
@@ -129,9 +113,8 @@ function createCustomConsole(defaultState) {
|
|
|
129
113
|
const s = state();
|
|
130
114
|
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
131
115
|
let timer = timers.get(id);
|
|
132
|
-
if (timer)
|
|
133
|
-
|
|
134
|
-
} else {
|
|
116
|
+
if (timer) timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
117
|
+
else {
|
|
135
118
|
timer = {
|
|
136
119
|
stderrTime: RealDate.now(),
|
|
137
120
|
stdoutTime: RealDate.now()
|
|
@@ -149,16 +132,13 @@ function createCustomConsole(defaultState) {
|
|
|
149
132
|
const stack = new Error("STACK_TRACE").stack?.split("\n");
|
|
150
133
|
Error.stackTraceLimit = limit;
|
|
151
134
|
const isTrace = stack?.some((line) => line.includes("at Console.trace"));
|
|
152
|
-
if (isTrace)
|
|
153
|
-
|
|
154
|
-
} else {
|
|
135
|
+
if (isTrace) buffer.push([data, void 0]);
|
|
136
|
+
else {
|
|
155
137
|
const trace = stack?.slice(7).join("\n");
|
|
156
138
|
Error.stackTraceLimit = limit;
|
|
157
139
|
buffer.push([data, trace]);
|
|
158
140
|
}
|
|
159
|
-
} else
|
|
160
|
-
buffer.push([data, undefined]);
|
|
161
|
-
}
|
|
141
|
+
} else buffer.push([data, void 0]);
|
|
162
142
|
schedule(id);
|
|
163
143
|
callback();
|
|
164
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
|
|