vitest 4.0.0-beta.4 → 4.0.0-beta.5
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/dist/browser.d.ts +8 -9
- package/dist/browser.js +3 -2
- package/dist/chunks/base.DMfOuRWD.js +48 -0
- package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CtuRzf-i.js} +4 -1
- package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
- package/dist/chunks/{cac.CY0IAxC4.js → cac.CKnbxhn2.js} +8 -9
- package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.COn58yrl.js} +540 -342
- package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
- package/dist/chunks/{console.DoJHFxmj.js → console.Duv2dVIC.js} +1 -1
- package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
- package/dist/chunks/{coverage.C84l9G-M.js → coverage.B6cReEn1.js} +232 -133
- 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.DUVZ6rfm.js} +1 -1
- package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
- package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
- package/dist/chunks/{globals.Dgo-vS5G.js → globals.CJQ63oO0.js} +6 -5
- package/dist/chunks/{index.CmSc2RE5.js → index.BRtIe7r8.js} +4 -4
- package/dist/chunks/{index.Bz6b0Ib7.js → index.DQhAfQQU.js} +12 -4
- package/dist/chunks/{index.D3SKT3tv.js → index.DgN0Zk9a.js} +1 -1
- package/dist/chunks/{index.D1_MsKEt.js → index.QZr3S3vQ.js} +4 -2
- package/dist/chunks/{index.CtUvr1c8.js → index.oWRWx-nj.js} +18 -18
- package/dist/chunks/moduleRunner.d.mmOmOGrW.d.ts +202 -0
- package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
- package/dist/chunks/{node.fjCdwEIl.js → node.4JV5OXkt.js} +1 -1
- package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.CvOlgjxK.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CYE9sT5z.d.ts} +37 -69
- package/dist/chunks/resolver.D5bG4zy5.js +162 -0
- package/dist/chunks/{rpc.jnQO9F8a.js → rpc.DGoW_Vl-.js} +1 -1
- package/dist/chunks/{runBaseTests.DBVVLMSb.js → runBaseTests.B3KcKqlF.js} +22 -23
- package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.lgPs-bYv.js} +11 -10
- package/dist/chunks/{execute.Dt-pCVcL.js → startModuleRunner.C8FtT_BY.js} +381 -312
- package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.BgoW4nTA.js} +1 -1
- package/dist/chunks/{utils.XdZDrNZV.js → utils.B9FY3b73.js} +7 -8
- package/dist/chunks/{vi.CA0EPI9Y.js → vi.DGAfBY4R.js} +12 -8
- package/dist/chunks/{vm.BUnLJt_P.js → vm.BKfKvaKl.js} +36 -56
- 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 +5 -4
- package/dist/module-evaluator.d.ts +12 -0
- package/dist/module-evaluator.js +327 -0
- package/dist/module-runner.js +15 -0
- package/dist/node.d.ts +12 -13
- package/dist/node.js +15 -14
- package/dist/reporters.d.ts +7 -8
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +3 -3
- package/dist/runners.js +16 -10
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +84 -31
- package/dist/workers/forks.js +10 -9
- package/dist/workers/runVmTests.js +16 -17
- package/dist/workers/threads.js +10 -9
- package/dist/workers/vmForks.js +9 -8
- package/dist/workers/vmThreads.js +9 -8
- package/dist/workers.d.ts +5 -4
- package/dist/workers.js +14 -13
- package/package.json +21 -16
- package/dist/chunks/base.BaCDDRPG.js +0 -38
- package/dist/execute.d.ts +0 -148
- package/dist/execute.js +0 -13
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { isBuiltin, createRequire } from 'node:module';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
import { isAbsolute } from 'pathe';
|
|
5
|
+
import { ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey } from 'vite/module-runner';
|
|
6
|
+
|
|
7
|
+
const performanceNow = performance.now.bind(performance);
|
|
8
|
+
class ModuleDebug {
|
|
9
|
+
executionStack = [];
|
|
10
|
+
startCalculateModuleExecutionInfo(filename, startOffset) {
|
|
11
|
+
const startTime = performanceNow();
|
|
12
|
+
this.executionStack.push({
|
|
13
|
+
filename,
|
|
14
|
+
startTime,
|
|
15
|
+
subImportTime: 0
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
const duration = performanceNow() - startTime;
|
|
19
|
+
const currentExecution = this.executionStack.pop();
|
|
20
|
+
if (currentExecution == null) throw new Error("Execution stack is empty, this should never happen");
|
|
21
|
+
const selfTime = duration - currentExecution.subImportTime;
|
|
22
|
+
if (this.executionStack.length > 0) this.executionStack.at(-1).subImportTime += duration;
|
|
23
|
+
return {
|
|
24
|
+
startOffset,
|
|
25
|
+
duration,
|
|
26
|
+
selfTime
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const isWindows = process.platform === "win32";
|
|
33
|
+
class VitestModuleEvaluator {
|
|
34
|
+
stubs = {};
|
|
35
|
+
env = createImportMetaEnvProxy();
|
|
36
|
+
vm;
|
|
37
|
+
compiledFunctionArgumentsNames;
|
|
38
|
+
compiledFunctionArgumentsValues = [];
|
|
39
|
+
primitives;
|
|
40
|
+
debug = new ModuleDebug();
|
|
41
|
+
constructor(vmOptions, options = {}) {
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.vm = vmOptions;
|
|
44
|
+
this.stubs = getDefaultRequestStubs(vmOptions?.context);
|
|
45
|
+
if (options.compiledFunctionArgumentsNames) this.compiledFunctionArgumentsNames = options.compiledFunctionArgumentsNames;
|
|
46
|
+
if (options.compiledFunctionArgumentsValues) this.compiledFunctionArgumentsValues = options.compiledFunctionArgumentsValues;
|
|
47
|
+
if (vmOptions) this.primitives = vm.runInContext("({ Object, Proxy, Reflect })", vmOptions.context);
|
|
48
|
+
else this.primitives = {
|
|
49
|
+
Object,
|
|
50
|
+
Proxy,
|
|
51
|
+
Reflect
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
convertIdToImportUrl(id) {
|
|
55
|
+
// TODO: vitest returns paths for external modules, but Vite returns file://
|
|
56
|
+
// unfortunetly, there is a bug in Vite where ID is resolved incorrectly, so we can't return files until the fix is merged
|
|
57
|
+
// https://github.com/vitejs/vite/pull/20449
|
|
58
|
+
if (!isWindows || isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id)) return id;
|
|
59
|
+
const [filepath, query] = id.split("?");
|
|
60
|
+
if (query) return `${pathToFileURL(filepath).toString()}?${query}`;
|
|
61
|
+
return pathToFileURL(filepath).toString();
|
|
62
|
+
}
|
|
63
|
+
async runExternalModule(id) {
|
|
64
|
+
if (id in this.stubs) return this.stubs[id];
|
|
65
|
+
const file = this.convertIdToImportUrl(id);
|
|
66
|
+
const namespace = this.vm ? await this.vm.externalModulesExecutor.import(file) : await import(file);
|
|
67
|
+
if (!this.shouldInterop(file, namespace)) return namespace;
|
|
68
|
+
const { mod, defaultExport } = interopModule(namespace);
|
|
69
|
+
const { Proxy, Reflect } = this.primitives;
|
|
70
|
+
const proxy = new Proxy(mod, {
|
|
71
|
+
get(mod, prop) {
|
|
72
|
+
if (prop === "default") return defaultExport;
|
|
73
|
+
return mod[prop] ?? defaultExport?.[prop];
|
|
74
|
+
},
|
|
75
|
+
has(mod, prop) {
|
|
76
|
+
if (prop === "default") return defaultExport !== void 0;
|
|
77
|
+
return prop in mod || defaultExport && prop in defaultExport;
|
|
78
|
+
},
|
|
79
|
+
getOwnPropertyDescriptor(mod, prop) {
|
|
80
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
81
|
+
if (descriptor) return descriptor;
|
|
82
|
+
if (prop === "default" && defaultExport !== void 0) return {
|
|
83
|
+
value: defaultExport,
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return proxy;
|
|
90
|
+
}
|
|
91
|
+
async runInlinedModule(context, code, module) {
|
|
92
|
+
context.__vite_ssr_import_meta__.env = this.env;
|
|
93
|
+
const { Reflect, Proxy, Object } = this.primitives;
|
|
94
|
+
const exportsObject = context[ssrModuleExportsKey];
|
|
95
|
+
const SYMBOL_NOT_DEFINED = Symbol("not defined");
|
|
96
|
+
let moduleExports = SYMBOL_NOT_DEFINED;
|
|
97
|
+
// this proxy is triggered only on exports.{name} and module.exports access
|
|
98
|
+
// inside the module itself. imported module is always "exports"
|
|
99
|
+
const cjsExports = new Proxy(exportsObject, {
|
|
100
|
+
get: (target, p, receiver) => {
|
|
101
|
+
if (Reflect.has(target, p)) return Reflect.get(target, p, receiver);
|
|
102
|
+
return Reflect.get(Object.prototype, p, receiver);
|
|
103
|
+
},
|
|
104
|
+
getPrototypeOf: () => Object.prototype,
|
|
105
|
+
set: (_, p, value) => {
|
|
106
|
+
// treat "module.exports =" the same as "exports.default =" to not have nested "default.default",
|
|
107
|
+
// so "exports.default" becomes the actual module
|
|
108
|
+
if (p === "default" && this.shouldInterop(module.file, { default: value }) && cjsExports !== value) {
|
|
109
|
+
exportAll(cjsExports, value);
|
|
110
|
+
exportsObject.default = value;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (!Reflect.has(exportsObject, "default")) exportsObject.default = {};
|
|
114
|
+
// returns undefined, when accessing named exports, if default is not an object
|
|
115
|
+
// but is still present inside hasOwnKeys, this is Node behaviour for CJS
|
|
116
|
+
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) {
|
|
117
|
+
defineExport(exportsObject, p, () => void 0);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (!isPrimitive(exportsObject.default)) exportsObject.default[p] = value;
|
|
121
|
+
if (p !== "default") defineExport(exportsObject, p, () => value);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const moduleProxy = {
|
|
126
|
+
set exports(value) {
|
|
127
|
+
exportAll(cjsExports, value);
|
|
128
|
+
exportsObject.default = value;
|
|
129
|
+
moduleExports = value;
|
|
130
|
+
},
|
|
131
|
+
get exports() {
|
|
132
|
+
return cjsExports;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const meta = context[ssrImportMetaKey];
|
|
136
|
+
const testFilepath = this.options.getCurrentTestFilepath?.();
|
|
137
|
+
if (testFilepath === module.file) {
|
|
138
|
+
const globalNamespace = this.vm?.context || globalThis;
|
|
139
|
+
Object.defineProperty(meta, "vitest", { get: () => globalNamespace.__vitest_index__ });
|
|
140
|
+
}
|
|
141
|
+
const filename = meta.filename;
|
|
142
|
+
const dirname = meta.dirname;
|
|
143
|
+
const require = this.createRequire(filename);
|
|
144
|
+
const argumentsList = [
|
|
145
|
+
ssrModuleExportsKey,
|
|
146
|
+
ssrImportMetaKey,
|
|
147
|
+
ssrImportKey,
|
|
148
|
+
ssrDynamicImportKey,
|
|
149
|
+
ssrExportAllKey,
|
|
150
|
+
"__vite_ssr_exportName__",
|
|
151
|
+
"__filename",
|
|
152
|
+
"__dirname",
|
|
153
|
+
"module",
|
|
154
|
+
"exports",
|
|
155
|
+
"require"
|
|
156
|
+
];
|
|
157
|
+
if (this.compiledFunctionArgumentsNames) argumentsList.push(...this.compiledFunctionArgumentsNames);
|
|
158
|
+
// add 'use strict' since ESM enables it by default
|
|
159
|
+
const codeDefinition = `'use strict';async (${argumentsList.join(",")})=>{{`;
|
|
160
|
+
const wrappedCode = `${codeDefinition}${code}\n}}`;
|
|
161
|
+
const options = {
|
|
162
|
+
filename: module.file || filename,
|
|
163
|
+
lineOffset: 0,
|
|
164
|
+
columnOffset: -codeDefinition.length
|
|
165
|
+
};
|
|
166
|
+
const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(filename, codeDefinition.length);
|
|
167
|
+
try {
|
|
168
|
+
const initModule = this.vm ? vm.runInContext(wrappedCode, this.vm.context, options) : vm.runInThisContext(wrappedCode, options);
|
|
169
|
+
const dynamicRequest = async (dep, options) => {
|
|
170
|
+
dep = String(dep);
|
|
171
|
+
// TODO: support more edge cases?
|
|
172
|
+
// vite doesn't support dynamic modules by design, but we have to
|
|
173
|
+
if (dep[0] === "#") return context[ssrDynamicImportKey](wrapId(dep), options);
|
|
174
|
+
return context[ssrDynamicImportKey](dep, options);
|
|
175
|
+
};
|
|
176
|
+
await initModule(
|
|
177
|
+
context[ssrModuleExportsKey],
|
|
178
|
+
context[ssrImportMetaKey],
|
|
179
|
+
context[ssrImportKey],
|
|
180
|
+
dynamicRequest,
|
|
181
|
+
context[ssrExportAllKey],
|
|
182
|
+
// vite 7 support, remove when vite 7+ is supported
|
|
183
|
+
context.__vite_ssr_exportName__ || ((name, getter) => Object.defineProperty(exportsObject, name, {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
configurable: true,
|
|
186
|
+
get: getter
|
|
187
|
+
})),
|
|
188
|
+
filename,
|
|
189
|
+
dirname,
|
|
190
|
+
moduleProxy,
|
|
191
|
+
cjsExports,
|
|
192
|
+
require,
|
|
193
|
+
...this.compiledFunctionArgumentsValues
|
|
194
|
+
);
|
|
195
|
+
} finally {
|
|
196
|
+
// moduleExecutionInfo needs to use Node filename instead of the normalized one
|
|
197
|
+
// because we rely on this behaviour in coverage-v8, for example
|
|
198
|
+
this.options.moduleExecutionInfo?.set(filename, finishModuleExecutionInfo());
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
createRequire(filename) {
|
|
202
|
+
// \x00 is a rollup convention for virtual files,
|
|
203
|
+
// it is not allowed in actual file names
|
|
204
|
+
if (filename.startsWith("\0") || !isAbsolute(filename)) return () => ({});
|
|
205
|
+
return this.vm ? this.vm.externalModulesExecutor.createRequire(filename) : createRequire(filename);
|
|
206
|
+
}
|
|
207
|
+
shouldInterop(path, mod) {
|
|
208
|
+
if (this.options.interopDefault === false) return false;
|
|
209
|
+
// never interop ESM modules
|
|
210
|
+
// TODO: should also skip for `.js` with `type="module"`
|
|
211
|
+
return !path.endsWith(".mjs") && "default" in mod;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function createImportMetaEnvProxy() {
|
|
215
|
+
// packages/vitest/src/node/plugins/index.ts:146
|
|
216
|
+
const booleanKeys = [
|
|
217
|
+
"DEV",
|
|
218
|
+
"PROD",
|
|
219
|
+
"SSR"
|
|
220
|
+
];
|
|
221
|
+
return new Proxy(process.env, {
|
|
222
|
+
get(_, key) {
|
|
223
|
+
if (typeof key !== "string") return void 0;
|
|
224
|
+
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
225
|
+
return process.env[key];
|
|
226
|
+
},
|
|
227
|
+
set(_, key, value) {
|
|
228
|
+
if (typeof key !== "string") return true;
|
|
229
|
+
if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
|
|
230
|
+
else process.env[key] = value;
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function updateStyle(id, css) {
|
|
236
|
+
if (typeof document === "undefined") return;
|
|
237
|
+
const element = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
|
238
|
+
if (element) {
|
|
239
|
+
element.textContent = css;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const head = document.querySelector("head");
|
|
243
|
+
const style = document.createElement("style");
|
|
244
|
+
style.setAttribute("type", "text/css");
|
|
245
|
+
style.setAttribute("data-vite-dev-id", id);
|
|
246
|
+
style.textContent = css;
|
|
247
|
+
head?.appendChild(style);
|
|
248
|
+
}
|
|
249
|
+
function removeStyle(id) {
|
|
250
|
+
if (typeof document === "undefined") return;
|
|
251
|
+
const sheet = document.querySelector(`[data-vite-dev-id="${id}"]`);
|
|
252
|
+
if (sheet) document.head.removeChild(sheet);
|
|
253
|
+
}
|
|
254
|
+
const defaultClientStub = {
|
|
255
|
+
injectQuery: (id) => id,
|
|
256
|
+
createHotContext: () => {
|
|
257
|
+
return {
|
|
258
|
+
accept: () => {},
|
|
259
|
+
prune: () => {},
|
|
260
|
+
dispose: () => {},
|
|
261
|
+
decline: () => {},
|
|
262
|
+
invalidate: () => {},
|
|
263
|
+
on: () => {},
|
|
264
|
+
send: () => {}
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
updateStyle: () => {},
|
|
268
|
+
removeStyle: () => {}
|
|
269
|
+
};
|
|
270
|
+
function getDefaultRequestStubs(context) {
|
|
271
|
+
if (!context) {
|
|
272
|
+
const clientStub = {
|
|
273
|
+
...defaultClientStub,
|
|
274
|
+
updateStyle,
|
|
275
|
+
removeStyle
|
|
276
|
+
};
|
|
277
|
+
return { "/@vite/client": clientStub };
|
|
278
|
+
}
|
|
279
|
+
const clientStub = vm.runInContext(`(defaultClient) => ({ ...defaultClient, updateStyle: ${updateStyle.toString()}, removeStyle: ${removeStyle.toString()} })`, context)(defaultClientStub);
|
|
280
|
+
return { "/@vite/client": clientStub };
|
|
281
|
+
}
|
|
282
|
+
function exportAll(exports, sourceModule) {
|
|
283
|
+
// #1120 when a module exports itself it causes
|
|
284
|
+
// call stack error
|
|
285
|
+
if (exports === sourceModule) return;
|
|
286
|
+
if (isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise) return;
|
|
287
|
+
for (const key in sourceModule) if (key !== "default" && !(key in exports)) try {
|
|
288
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
289
|
+
} catch {}
|
|
290
|
+
}
|
|
291
|
+
// keep consistency with Vite on how exports are defined
|
|
292
|
+
function defineExport(exports, key, value) {
|
|
293
|
+
Object.defineProperty(exports, key, {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
configurable: true,
|
|
296
|
+
get: value
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
function isPrimitive(v) {
|
|
300
|
+
const isObject = typeof v === "object" || typeof v === "function";
|
|
301
|
+
return !isObject || v == null;
|
|
302
|
+
}
|
|
303
|
+
function interopModule(mod) {
|
|
304
|
+
if (isPrimitive(mod)) return {
|
|
305
|
+
mod: { default: mod },
|
|
306
|
+
defaultExport: mod
|
|
307
|
+
};
|
|
308
|
+
let defaultExport = "default" in mod ? mod.default : mod;
|
|
309
|
+
if (!isPrimitive(defaultExport) && "__esModule" in defaultExport) {
|
|
310
|
+
mod = defaultExport;
|
|
311
|
+
if ("default" in defaultExport) defaultExport = defaultExport.default;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
mod,
|
|
315
|
+
defaultExport
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
319
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
320
|
+
function wrapId(id) {
|
|
321
|
+
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
322
|
+
}
|
|
323
|
+
function unwrapId(id) {
|
|
324
|
+
return id.startsWith(VALID_ID_PREFIX) ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, "\0") : id;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export { VitestModuleEvaluator, createImportMetaEnvProxy, getDefaultRequestStubs, isPrimitive, unwrapId, wrapId };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { VitestModuleEvaluator } from './module-evaluator.js';
|
|
2
|
+
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.C8FtT_BY.js';
|
|
3
|
+
export { g as getWorkerState } from './chunks/utils.B9FY3b73.js';
|
|
4
|
+
import 'node:module';
|
|
5
|
+
import 'node:url';
|
|
6
|
+
import 'node:vm';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
import 'vite/module-runner';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import '@vitest/utils';
|
|
11
|
+
import './path.js';
|
|
12
|
+
import 'node:path';
|
|
13
|
+
import '@vitest/utils/error';
|
|
14
|
+
import '@vitest/mocker';
|
|
15
|
+
import './chunks/moduleTransport.I-bgQy0S.js';
|
package/dist/node.d.ts
CHANGED
|
@@ -3,36 +3,35 @@ import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as Res
|
|
|
3
3
|
export { vite as Vite };
|
|
4
4
|
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
5
5
|
import { IncomingMessage } from 'node:http';
|
|
6
|
-
import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, k as TestSequencer, l as TestSpecification, L as Logger } from './chunks/reporters.d.
|
|
7
|
-
export {
|
|
8
|
-
import { R as RuntimeRPC } from './chunks/worker.d.
|
|
9
|
-
export { T as TestExecutionType } from './chunks/worker.d.
|
|
6
|
+
import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, T as TestProject, k as TestSequencer, l as TestSpecification, L as Logger } from './chunks/reporters.d.CYE9sT5z.js';
|
|
7
|
+
export { ap as BaseCoverageOptions, K as BenchmarkUserOptions, N as BrowserBuiltinProvider, Q as BrowserCommand, X as BrowserCommandContext, Y as BrowserConfigOptions, Z as BrowserInstanceOption, _ as BrowserModuleMocker, $ as BrowserOrchestrator, a0 as BrowserProvider, a1 as BrowserProviderInitializationOptions, a2 as BrowserProviderModule, a3 as BrowserProviderOptions, a4 as BrowserScript, a5 as BrowserServerState, a6 as BrowserServerStateSession, ad as BuiltinEnvironment, a7 as CDPSession, ae as CSSModuleScopeStrategy, aq as CoverageIstanbulOptions, ar as CoverageOptions, as as CoverageProvider, at as CoverageProviderModule, au as CoverageReporter, c as CoverageV8Options, av as CustomProviderOptions, af as DepsOptimizationOptions, ag as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, q as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, m as OnTestsRerunHandler, a8 as ParentProjectBrowser, ah as Pool, ai as PoolOptions, P as ProcessPool, a9 as ProjectBrowser, aj as ProjectConfig, b as ReportContext, ax as ReportedHookContext, ay as Reporter, al as ResolveSnapshotPathHandler, am as ResolveSnapshotPathHandlerContext, aa as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ak as ResolvedProjectConfig, S as SerializedTestProject, r as TaskOptions, s as TestCase, t as TestCollection, u as TestDiagnostic, v as TestModule, w as TestModuleState, x as TestResult, y as TestResultFailed, z as TestResultPassed, B as TestResultSkipped, az as TestRunEndReason, aw as TestRunResult, G as TestSequencerConstructor, D as TestState, E as TestSuite, F as TestSuiteState, ab as ToMatchScreenshotComparators, ac as ToMatchScreenshotOptions, an as TypecheckConfig, U as UserWorkspaceConfig, ao as VitestEnvironment, n as VitestPackageInstaller, W as WatcherTriggerPattern, o as WorkspaceSpec, p as getFilePoolName } from './chunks/reporters.d.CYE9sT5z.js';
|
|
8
|
+
import { R as RuntimeRPC } from './chunks/worker.d.D9QWnzAe.js';
|
|
9
|
+
export { T as TestExecutionType } from './chunks/worker.d.D9QWnzAe.js';
|
|
10
10
|
import { Writable } from 'node:stream';
|
|
11
|
-
export { V as VitestPluginContext } from './chunks/plugin.d.
|
|
12
|
-
export { W as WorkerContext } from './chunks/worker.d.
|
|
11
|
+
export { V as VitestPluginContext } from './chunks/plugin.d.CvOlgjxK.js';
|
|
12
|
+
export { W as WorkerContext } from './chunks/worker.d.Db-UVmXc.js';
|
|
13
13
|
import { Debugger } from 'debug';
|
|
14
|
-
import './chunks/global.d.
|
|
14
|
+
import './chunks/global.d.K6uBQHzY.js';
|
|
15
15
|
export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
|
|
16
|
-
export { b as RuntimeConfig } from './chunks/config.d.
|
|
16
|
+
export { b as RuntimeConfig } from './chunks/config.d.CKNVOKm0.js';
|
|
17
17
|
export { SerializedError } from '@vitest/utils';
|
|
18
18
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
19
|
-
import './chunks/environment.d.
|
|
19
|
+
import './chunks/environment.d.2fYMoz3o.js';
|
|
20
20
|
import 'node:console';
|
|
21
|
-
import './chunks/browser.d.
|
|
21
|
+
import './chunks/browser.d.Cawq_X_N.js';
|
|
22
22
|
import '@vitest/mocker';
|
|
23
23
|
import '@vitest/utils/source-map';
|
|
24
24
|
import '@vitest/pretty-format';
|
|
25
25
|
import '@vitest/snapshot';
|
|
26
26
|
import '@vitest/utils/diff';
|
|
27
|
-
import 'vite-node';
|
|
28
27
|
import 'chai';
|
|
29
28
|
import 'vitest/optional-types.js';
|
|
30
29
|
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
31
30
|
import 'tinybench';
|
|
32
|
-
import './chunks/coverage.d.
|
|
33
|
-
import 'vite-node/client';
|
|
31
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
34
32
|
import '@vitest/snapshot/manager';
|
|
35
33
|
import 'node:fs';
|
|
34
|
+
import 'vite/module-runner';
|
|
36
35
|
import 'node:worker_threads';
|
|
37
36
|
import '@vitest/expect';
|
|
38
37
|
|
package/dist/node.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
|
|
3
3
|
export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
|
|
4
|
-
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.
|
|
5
|
-
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.
|
|
6
|
-
export { p as parseCLI } from './chunks/cac.
|
|
7
|
-
import { r as resolveConfig$2 } from './chunks/coverage.
|
|
8
|
-
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.
|
|
4
|
+
import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.COn58yrl.js';
|
|
5
|
+
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, e as createViteLogger, c as createVitest, i as isValidApiRequest, d as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.COn58yrl.js';
|
|
6
|
+
export { p as parseCLI } from './chunks/cac.CKnbxhn2.js';
|
|
7
|
+
import { r as resolveConfig$2 } from './chunks/coverage.B6cReEn1.js';
|
|
8
|
+
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.B6cReEn1.js';
|
|
9
9
|
import { slash, deepClone } from '@vitest/utils';
|
|
10
10
|
import { f as findUp } from './chunks/index.X0nbfr6-.js';
|
|
11
11
|
import { resolve } from 'pathe';
|
|
12
|
-
import { c as configFiles } from './chunks/constants.
|
|
12
|
+
import { c as configFiles } from './chunks/constants.D_Q9UYh-.js';
|
|
13
13
|
export { distDir, rootDir } from './path.js';
|
|
14
14
|
import createDebug from 'debug';
|
|
15
15
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
16
16
|
import 'node:fs';
|
|
17
|
-
import './chunks/coverage.
|
|
17
|
+
import './chunks/coverage.D_JHT54q.js';
|
|
18
18
|
import 'node:path';
|
|
19
19
|
import '@vitest/snapshot/manager';
|
|
20
|
-
import 'vite-node/client';
|
|
21
|
-
import 'vite-node/server';
|
|
22
20
|
import './chunks/index.Bgo3tNWt.js';
|
|
23
|
-
import './chunks/index.
|
|
21
|
+
import './chunks/index.DQhAfQQU.js';
|
|
24
22
|
import 'node:fs/promises';
|
|
25
|
-
import './chunks/typechecker.
|
|
23
|
+
import './chunks/typechecker.BgoW4nTA.js';
|
|
26
24
|
import 'node:os';
|
|
27
25
|
import 'node:perf_hooks';
|
|
28
26
|
import '@vitest/utils/source-map';
|
|
@@ -46,14 +44,17 @@ import 'zlib';
|
|
|
46
44
|
import 'buffer';
|
|
47
45
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
48
46
|
import 'node:crypto';
|
|
47
|
+
import '#module-evaluator';
|
|
48
|
+
import 'vite/module-runner';
|
|
49
49
|
import 'node:url';
|
|
50
50
|
import 'picomatch';
|
|
51
51
|
import 'tinyglobby';
|
|
52
|
-
import '
|
|
52
|
+
import 'magic-string';
|
|
53
53
|
import '@vitest/mocker/node';
|
|
54
54
|
import './chunks/defaults.CXFFjsi8.js';
|
|
55
|
-
import '
|
|
56
|
-
import '
|
|
55
|
+
import './chunks/resolver.D5bG4zy5.js';
|
|
56
|
+
import 'es-module-lexer';
|
|
57
|
+
import './chunks/index.DgN0Zk9a.js';
|
|
57
58
|
import 'node:assert';
|
|
58
59
|
import '@vitest/utils/error';
|
|
59
60
|
import 'node:readline';
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aN as BaseReporter, aO as BenchmarkBuiltinReporters, aA as BenchmarkReporter, aB as BenchmarkReportsMap, aP as BuiltinReporterOptions, aQ as BuiltinReporters, aC as DefaultReporter, aD as DotReporter, aE as GithubActionsReporter, aF as HangingProcessReporter, aH as JUnitReporter, aR as JsonAssertionResult, aG as JsonReporter, aS as JsonTestResult, aT as JsonTestResults, ax as ReportedHookContext, ay as Reporter, aI as ReportersMap, aJ as TapFlatReporter, aK as TapReporter, az as TestRunEndReason, aL as VerboseBenchmarkReporter, aM as VerboseReporter } from './chunks/reporters.d.CYE9sT5z.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
|
-
import './chunks/environment.d.
|
|
3
|
+
import './chunks/environment.d.2fYMoz3o.js';
|
|
4
4
|
import '@vitest/utils';
|
|
5
5
|
import 'node:stream';
|
|
6
6
|
import 'vite';
|
|
7
7
|
import 'node:console';
|
|
8
|
-
import './chunks/browser.d.
|
|
9
|
-
import './chunks/worker.d.
|
|
10
|
-
import '
|
|
8
|
+
import './chunks/browser.d.Cawq_X_N.js';
|
|
9
|
+
import './chunks/worker.d.D9QWnzAe.js';
|
|
10
|
+
import 'vite/module-runner';
|
|
11
|
+
import './chunks/config.d.CKNVOKm0.js';
|
|
11
12
|
import '@vitest/pretty-format';
|
|
12
13
|
import '@vitest/snapshot';
|
|
13
14
|
import '@vitest/utils/diff';
|
|
14
15
|
import '@vitest/mocker';
|
|
15
16
|
import '@vitest/utils/source-map';
|
|
16
|
-
import 'vite-node';
|
|
17
17
|
import 'chai';
|
|
18
18
|
import 'vitest/optional-types.js';
|
|
19
19
|
import './chunks/benchmark.d.DAaHLpsq.js';
|
|
20
20
|
import '@vitest/runner/utils';
|
|
21
21
|
import 'tinybench';
|
|
22
|
-
import './chunks/coverage.d.
|
|
23
|
-
import 'vite-node/client';
|
|
22
|
+
import './chunks/coverage.d.BZtK59WP.js';
|
|
24
23
|
import '@vitest/snapshot/manager';
|
|
25
24
|
import 'node:fs';
|
package/dist/reporters.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.
|
|
2
|
-
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.
|
|
1
|
+
export { D as DefaultReporter, a as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, b as JUnitReporter, J as JsonReporter, R as ReportersMap, T as TapFlatReporter, c as TapReporter, V as VerboseReporter } from './chunks/index.DQhAfQQU.js';
|
|
2
|
+
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.DgN0Zk9a.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'pathe';
|
|
6
|
-
import './chunks/typechecker.
|
|
6
|
+
import './chunks/typechecker.BgoW4nTA.js';
|
|
7
7
|
import 'node:os';
|
|
8
8
|
import 'node:perf_hooks';
|
|
9
9
|
import '@vitest/utils/source-map';
|
package/dist/runners.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as tinybench from 'tinybench';
|
|
2
2
|
import { VitestRunner, VitestRunnerImportSource, Suite, File, Task, CancelReason, Test, TestContext, ImportDuration } from '@vitest/runner';
|
|
3
3
|
export { VitestRunner } from '@vitest/runner';
|
|
4
|
-
import { a as SerializedConfig } from './chunks/config.d.
|
|
4
|
+
import { a as SerializedConfig } from './chunks/config.d.CKNVOKm0.js';
|
|
5
5
|
import '@vitest/pretty-format';
|
|
6
6
|
import '@vitest/snapshot';
|
|
7
7
|
import '@vitest/utils/diff';
|
|
8
8
|
|
|
9
9
|
declare class NodeBenchmarkRunner implements VitestRunner {
|
|
10
10
|
config: SerializedConfig;
|
|
11
|
-
private
|
|
11
|
+
private moduleRunner;
|
|
12
12
|
constructor(config: SerializedConfig);
|
|
13
13
|
importTinybench(): Promise<typeof tinybench>;
|
|
14
14
|
importFile(filepath: string, source: VitestRunnerImportSource): unknown;
|
|
@@ -20,7 +20,7 @@ declare class VitestTestRunner implements VitestRunner {
|
|
|
20
20
|
config: SerializedConfig;
|
|
21
21
|
private snapshotClient;
|
|
22
22
|
private workerState;
|
|
23
|
-
private
|
|
23
|
+
private moduleRunner;
|
|
24
24
|
private cancelRun;
|
|
25
25
|
private assertionsErrors;
|
|
26
26
|
pool: string;
|
package/dist/runners.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { updateTask } from '@vitest/runner';
|
|
2
2
|
import { createDefer, getSafeTimers } from '@vitest/utils';
|
|
3
|
-
import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.
|
|
4
|
-
import { g as getWorkerState } from './chunks/utils.
|
|
3
|
+
import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.CtuRzf-i.js';
|
|
4
|
+
import { g as getWorkerState } from './chunks/utils.B9FY3b73.js';
|
|
5
5
|
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
|
|
6
6
|
import { getTests, getNames, getTestName } from '@vitest/runner/utils';
|
|
7
7
|
import { processError } from '@vitest/utils/error';
|
|
8
8
|
import { normalize } from 'pathe';
|
|
9
|
-
import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.
|
|
10
|
-
import { r as rpc } from './chunks/rpc.
|
|
9
|
+
import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.DGAfBY4R.js';
|
|
10
|
+
import { r as rpc } from './chunks/rpc.DGoW_Vl-.js';
|
|
11
11
|
import 'chai';
|
|
12
12
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
13
13
|
import '@vitest/snapshot';
|
|
@@ -98,7 +98,7 @@ async function runBenchmarkSuite(suite, runner) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
class NodeBenchmarkRunner {
|
|
101
|
-
|
|
101
|
+
moduleRunner;
|
|
102
102
|
constructor(config) {
|
|
103
103
|
this.config = config;
|
|
104
104
|
}
|
|
@@ -106,8 +106,11 @@ class NodeBenchmarkRunner {
|
|
|
106
106
|
return await import('tinybench');
|
|
107
107
|
}
|
|
108
108
|
importFile(filepath, source) {
|
|
109
|
-
if (source === "setup")
|
|
110
|
-
|
|
109
|
+
if (source === "setup") {
|
|
110
|
+
const moduleNode = getWorkerState().evaluatedModules.getModuleById(filepath);
|
|
111
|
+
if (moduleNode) getWorkerState().evaluatedModules.invalidateModule(moduleNode);
|
|
112
|
+
}
|
|
113
|
+
return this.moduleRunner.import(filepath);
|
|
111
114
|
}
|
|
112
115
|
async runSuite(suite) {
|
|
113
116
|
await runBenchmarkSuite(suite, this);
|
|
@@ -123,7 +126,7 @@ const workerContext = Object.create(null);
|
|
|
123
126
|
class VitestTestRunner {
|
|
124
127
|
snapshotClient = getSnapshotClient();
|
|
125
128
|
workerState = getWorkerState();
|
|
126
|
-
|
|
129
|
+
moduleRunner;
|
|
127
130
|
cancelRun = false;
|
|
128
131
|
assertionsErrors = /* @__PURE__ */ new WeakMap();
|
|
129
132
|
pool = this.workerState.ctx.pool;
|
|
@@ -131,8 +134,11 @@ class VitestTestRunner {
|
|
|
131
134
|
this.config = config;
|
|
132
135
|
}
|
|
133
136
|
importFile(filepath, source) {
|
|
134
|
-
if (source === "setup")
|
|
135
|
-
|
|
137
|
+
if (source === "setup") {
|
|
138
|
+
const moduleNode = this.workerState.evaluatedModules.getModuleById(filepath);
|
|
139
|
+
if (moduleNode) this.workerState.evaluatedModules.invalidateModule(moduleNode);
|
|
140
|
+
}
|
|
141
|
+
return this.moduleRunner.import(filepath);
|
|
136
142
|
}
|
|
137
143
|
onCollectStart(file) {
|
|
138
144
|
this.workerState.current = file;
|
package/dist/snapshot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.
|
|
1
|
+
export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.4JV5OXkt.js';
|
|
2
2
|
import '@vitest/snapshot/environment';
|
|
3
|
-
import './chunks/utils.
|
|
3
|
+
import './chunks/utils.B9FY3b73.js';
|
|
4
4
|
import '@vitest/utils';
|
package/dist/suite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.
|
|
1
|
+
export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.CtuRzf-i.js';
|
|
2
2
|
export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
|
|
3
3
|
export { createChainable } from '@vitest/runner/utils';
|
|
4
4
|
import '@vitest/utils';
|
|
5
|
-
import './chunks/utils.
|
|
5
|
+
import './chunks/utils.B9FY3b73.js';
|