vitest 4.0.0-beta.4 → 4.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/browser.d.ts +8 -9
- package/dist/browser.js +3 -2
- package/dist/chunks/base.BXI97p6t.js +39 -0
- package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.UW6Ezvxy.js} +6 -8
- package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
- package/dist/chunks/{cac.CY0IAxC4.js → cac.WE-urWw5.js} +38 -115
- package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.CZz3evYC.js} +931 -1439
- package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
- package/dist/chunks/{console.DoJHFxmj.js → console.B0quX7yH.js} +32 -68
- package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
- package/dist/chunks/{coverage.C84l9G-M.js → coverage.BPRS6xgn.js} +395 -665
- package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
- package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
- package/dist/chunks/{creator.yfA2ExGt.js → creator.KEg6n5IC.js} +29 -75
- package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
- package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
- package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
- package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
- package/dist/chunks/{globals.Dgo-vS5G.js → globals.lgsmH00r.js} +7 -6
- package/dist/chunks/{index.D3SKT3tv.js → index.7w0eqmYM.js} +14 -24
- package/dist/chunks/{index.D1_MsKEt.js → index.AR8aAkCC.js} +4 -2
- package/dist/chunks/{index.CmSc2RE5.js → index.BG0gqZH-.js} +43 -106
- package/dist/chunks/{index.CtUvr1c8.js → index.CsFXYRkW.js} +27 -46
- package/dist/chunks/{index.Bz6b0Ib7.js → index.VNI-1z5c.js} +276 -604
- package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
- package/dist/chunks/moduleRunner.d.8kKUsuDg.d.ts +202 -0
- package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
- package/dist/chunks/{node.fjCdwEIl.js → node.BOqcT2jW.js} +1 -1
- package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.DuiQJfUL.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CqR9-CDJ.d.ts} +52 -101
- package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
- package/dist/chunks/{rpc.jnQO9F8a.js → rpc.RpPylpp0.js} +7 -21
- package/dist/chunks/runBaseTests.D6sfuWBM.js +99 -0
- package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.hLGRxhC8.js} +15 -27
- package/dist/chunks/startModuleRunner.C8TW8zTN.js +655 -0
- package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.Cd1wvxUM.js} +97 -209
- package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
- package/dist/chunks/{utils.XdZDrNZV.js → utils.C7__0Iv5.js} +7 -17
- package/dist/chunks/{vi.CA0EPI9Y.js → vi.BfdOiD4j.js} +116 -269
- package/dist/chunks/{vm.BUnLJt_P.js → vm.BHBje7cC.js} +101 -225
- package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
- package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
- package/dist/cli.js +4 -4
- package/dist/config.cjs +3 -9
- package/dist/config.d.ts +10 -12
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +10 -11
- package/dist/coverage.js +5 -6
- package/dist/environments.d.ts +2 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +6 -5
- package/dist/module-evaluator.d.ts +12 -0
- package/dist/module-evaluator.js +276 -0
- package/dist/module-runner.js +15 -0
- package/dist/node.d.ts +12 -13
- package/dist/node.js +19 -24
- package/dist/reporters.d.ts +7 -8
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +35 -57
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +82 -45
- package/dist/workers/forks.js +11 -10
- package/dist/workers/runVmTests.js +27 -46
- package/dist/workers/threads.js +11 -10
- package/dist/workers/vmForks.js +11 -10
- package/dist/workers/vmThreads.js +11 -10
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +17 -16
- package/package.json +22 -17
- package/dist/chunks/base.BaCDDRPG.js +0 -38
- package/dist/chunks/execute.Dt-pCVcL.js +0 -708
- package/dist/chunks/runBaseTests.DBVVLMSb.js +0 -129
- package/dist/execute.d.ts +0 -148
- package/dist/execute.js +0 -13
|
@@ -134,14 +134,9 @@ interface SerializedConfig {
|
|
|
134
134
|
transformCss?: boolean;
|
|
135
135
|
transformGlobPattern?: RegExp | RegExp[];
|
|
136
136
|
};
|
|
137
|
-
optimizer: {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
ssr: {
|
|
142
|
-
enabled: boolean;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
137
|
+
optimizer: Record<string, {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
}>;
|
|
145
140
|
interopDefault: boolean | undefined;
|
|
146
141
|
moduleDirectories: string[] | undefined;
|
|
147
142
|
};
|
|
@@ -3,48 +3,35 @@ 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.-jtEtIeV.js';
|
|
7
|
+
import { g as getWorkerState } from './utils.C7__0Iv5.js';
|
|
8
8
|
|
|
9
9
|
const UNKNOWN_TEST_ID = "__vitest__unknown_test__";
|
|
10
10
|
function getTaskIdByStack(root) {
|
|
11
11
|
const stack = (/* @__PURE__ */ new Error("STACK_TRACE_ERROR")).stack?.split("\n");
|
|
12
12
|
if (!stack) return UNKNOWN_TEST_ID;
|
|
13
|
-
const index = stack.findIndex((line) => line.includes("at Console.value"));
|
|
14
|
-
const line = index === -1 ? null : stack[index + 2];
|
|
13
|
+
const index = stack.findIndex((line) => line.includes("at Console.value")), line = index === -1 ? null : stack[index + 2];
|
|
15
14
|
if (!line) return UNKNOWN_TEST_ID;
|
|
16
15
|
const filepath = line.match(/at\s(.*)\s?/)?.[1];
|
|
17
|
-
|
|
18
|
-
return UNKNOWN_TEST_ID;
|
|
16
|
+
return filepath ? relative(root, filepath) : UNKNOWN_TEST_ID;
|
|
19
17
|
}
|
|
20
18
|
function createCustomConsole(defaultState) {
|
|
21
|
-
const stdoutBuffer = /* @__PURE__ */ new Map();
|
|
22
|
-
const stderrBuffer = /* @__PURE__ */ new Map();
|
|
23
|
-
const timers = /* @__PURE__ */ new Map();
|
|
24
|
-
const { queueMicrotask } = getSafeTimers();
|
|
19
|
+
const stdoutBuffer = /* @__PURE__ */ new Map(), stderrBuffer = /* @__PURE__ */ new Map(), timers = /* @__PURE__ */ new Map(), { queueMicrotask } = getSafeTimers();
|
|
25
20
|
function queueCancelableMicrotask(callback) {
|
|
26
21
|
let canceled = false;
|
|
27
|
-
queueMicrotask(() => {
|
|
22
|
+
return queueMicrotask(() => {
|
|
28
23
|
if (!canceled) callback();
|
|
29
|
-
})
|
|
30
|
-
return () => {
|
|
24
|
+
}), () => {
|
|
31
25
|
canceled = true;
|
|
32
26
|
};
|
|
33
27
|
}
|
|
34
28
|
const state = () => defaultState || getWorkerState();
|
|
35
29
|
// group sync console.log calls with micro task
|
|
36
30
|
function schedule(taskId) {
|
|
37
|
-
const timer = timers.get(taskId);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (stderrTime < stdoutTime) {
|
|
42
|
-
sendStderr(taskId);
|
|
43
|
-
sendStdout(taskId);
|
|
44
|
-
} else {
|
|
45
|
-
sendStdout(taskId);
|
|
46
|
-
sendStderr(taskId);
|
|
47
|
-
}
|
|
31
|
+
const timer = timers.get(taskId), { stdoutTime, stderrTime } = timer;
|
|
32
|
+
timer.cancel?.(), timer.cancel = queueCancelableMicrotask(() => {
|
|
33
|
+
if (stderrTime < stdoutTime) sendStderr(taskId), sendStdout(taskId);
|
|
34
|
+
else sendStdout(taskId), sendStderr(taskId);
|
|
48
35
|
});
|
|
49
36
|
}
|
|
50
37
|
function sendStdout(taskId) {
|
|
@@ -54,8 +41,7 @@ function createCustomConsole(defaultState) {
|
|
|
54
41
|
sendBuffer("stderr", taskId);
|
|
55
42
|
}
|
|
56
43
|
function sendBuffer(type, taskId) {
|
|
57
|
-
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer;
|
|
58
|
-
const buffer = buffers.get(taskId);
|
|
44
|
+
const buffers = type === "stdout" ? stdoutBuffer : stderrBuffer, buffer = buffers.get(taskId);
|
|
59
45
|
if (!buffer) return;
|
|
60
46
|
if (state().config.printConsoleTrace) buffer.forEach(([buffer, origin]) => {
|
|
61
47
|
sendLog(type, taskId, String(buffer), buffer.length, origin);
|
|
@@ -65,13 +51,11 @@ function createCustomConsole(defaultState) {
|
|
|
65
51
|
sendLog(type, taskId, content, buffer.length);
|
|
66
52
|
}
|
|
67
53
|
const timer = timers.get(taskId);
|
|
68
|
-
buffers.delete(taskId);
|
|
69
|
-
if (type === "stderr") timer.stderrTime = 0;
|
|
54
|
+
if (buffers.delete(taskId), type === "stderr") timer.stderrTime = 0;
|
|
70
55
|
else timer.stdoutTime = 0;
|
|
71
56
|
}
|
|
72
57
|
function sendLog(type, taskId, content, size, origin) {
|
|
73
|
-
const timer = timers.get(taskId);
|
|
74
|
-
const time = type === "stderr" ? timer.stderrTime : timer.stdoutTime;
|
|
58
|
+
const timer = timers.get(taskId), time = type === "stderr" ? timer.stderrTime : timer.stdoutTime;
|
|
75
59
|
state().rpc.onUserConsoleLog({
|
|
76
60
|
type,
|
|
77
61
|
content: content || "<empty line>",
|
|
@@ -82,50 +66,32 @@ function createCustomConsole(defaultState) {
|
|
|
82
66
|
});
|
|
83
67
|
}
|
|
84
68
|
const stdout = new Writable({ write(data, encoding, callback) {
|
|
85
|
-
const s = state();
|
|
86
|
-
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
69
|
+
const s = state(), id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
87
70
|
let timer = timers.get(id);
|
|
88
71
|
if (timer) timer.stdoutTime = timer.stdoutTime || RealDate.now();
|
|
89
|
-
else {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
timers.set(id, timer);
|
|
95
|
-
}
|
|
72
|
+
else timer = {
|
|
73
|
+
stdoutTime: RealDate.now(),
|
|
74
|
+
stderrTime: RealDate.now()
|
|
75
|
+
}, timers.set(id, timer);
|
|
96
76
|
let buffer = stdoutBuffer.get(id);
|
|
97
|
-
if (!buffer)
|
|
98
|
-
buffer = [];
|
|
99
|
-
stdoutBuffer.set(id, buffer);
|
|
100
|
-
}
|
|
77
|
+
if (!buffer) buffer = [], stdoutBuffer.set(id, buffer);
|
|
101
78
|
if (state().config.printConsoleTrace) {
|
|
102
79
|
const limit = Error.stackTraceLimit;
|
|
103
80
|
Error.stackTraceLimit = limit + 6;
|
|
104
|
-
const stack = (/* @__PURE__ */ new Error("STACK_TRACE")).stack;
|
|
105
|
-
|
|
106
|
-
Error.stackTraceLimit = limit;
|
|
107
|
-
buffer.push([data, trace]);
|
|
81
|
+
const stack = (/* @__PURE__ */ new Error("STACK_TRACE")).stack, trace = stack?.split("\n").slice(7).join("\n");
|
|
82
|
+
Error.stackTraceLimit = limit, buffer.push([data, trace]);
|
|
108
83
|
} else buffer.push([data, void 0]);
|
|
109
|
-
schedule(id);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const stderr = new Writable({ write(data, encoding, callback) {
|
|
113
|
-
const s = state();
|
|
114
|
-
const id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
84
|
+
schedule(id), callback();
|
|
85
|
+
} }), stderr = new Writable({ write(data, encoding, callback) {
|
|
86
|
+
const s = state(), id = s?.current?.id || s?.current?.suite?.id || s.current?.file.id || getTaskIdByStack(s.config.root);
|
|
115
87
|
let timer = timers.get(id);
|
|
116
88
|
if (timer) timer.stderrTime = timer.stderrTime || RealDate.now();
|
|
117
|
-
else {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
timers.set(id, timer);
|
|
123
|
-
}
|
|
89
|
+
else timer = {
|
|
90
|
+
stderrTime: RealDate.now(),
|
|
91
|
+
stdoutTime: RealDate.now()
|
|
92
|
+
}, timers.set(id, timer);
|
|
124
93
|
let buffer = stderrBuffer.get(id);
|
|
125
|
-
if (!buffer)
|
|
126
|
-
buffer = [];
|
|
127
|
-
stderrBuffer.set(id, buffer);
|
|
128
|
-
}
|
|
94
|
+
if (!buffer) buffer = [], stderrBuffer.set(id, buffer);
|
|
129
95
|
if (state().config.printConsoleTrace) {
|
|
130
96
|
const limit = Error.stackTraceLimit;
|
|
131
97
|
Error.stackTraceLimit = limit + 6;
|
|
@@ -135,12 +101,10 @@ function createCustomConsole(defaultState) {
|
|
|
135
101
|
if (isTrace) buffer.push([data, void 0]);
|
|
136
102
|
else {
|
|
137
103
|
const trace = stack?.slice(7).join("\n");
|
|
138
|
-
Error.stackTraceLimit = limit;
|
|
139
|
-
buffer.push([data, trace]);
|
|
104
|
+
Error.stackTraceLimit = limit, buffer.push([data, trace]);
|
|
140
105
|
}
|
|
141
106
|
} else buffer.push([data, void 0]);
|
|
142
|
-
schedule(id);
|
|
143
|
-
callback();
|
|
107
|
+
schedule(id), callback();
|
|
144
108
|
} });
|
|
145
109
|
return new Console({
|
|
146
110
|
stdout,
|
|
@@ -3,11 +3,6 @@ const defaultPort = 51204;
|
|
|
3
3
|
const defaultBrowserPort = 63315;
|
|
4
4
|
const defaultInspectPort = 9229;
|
|
5
5
|
const API_PATH = "/__vitest_api__";
|
|
6
|
-
const extraInlineDeps = [
|
|
7
|
-
/^(?!.*node_modules).*\.mjs$/,
|
|
8
|
-
/^(?!.*node_modules).*\.cjs\.js$/,
|
|
9
|
-
/vite\w*\/dist\/client\/env.mjs/
|
|
10
|
-
];
|
|
11
6
|
const CONFIG_NAMES = ["vitest.config", "vite.config"];
|
|
12
7
|
const CONFIG_EXTENSIONS = [
|
|
13
8
|
".ts",
|
|
@@ -38,4 +33,4 @@ const globalApis = [
|
|
|
38
33
|
"onTestFailed"
|
|
39
34
|
];
|
|
40
35
|
|
|
41
|
-
export { API_PATH as A, defaultPort as a, defaultInspectPort as b, configFiles as c, defaultBrowserPort as d,
|
|
36
|
+
export { API_PATH as A, defaultPort as a, defaultInspectPort as b, configFiles as c, defaultBrowserPort as d, globalApis as g };
|