vitest 4.0.0-beta.5 → 4.0.0-beta.7
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 +3 -3
- package/dist/browser.js +2 -2
- package/dist/chunks/{base.DMfOuRWD.js → base.BXI97p6t.js} +7 -16
- package/dist/chunks/{benchmark.CtuRzf-i.js → benchmark.UW6Ezvxy.js} +4 -9
- package/dist/chunks/{browser.d.Cawq_X_N.d.ts → browser.d.DOMmqJQx.d.ts} +1 -1
- package/dist/chunks/{cac.CKnbxhn2.js → cac.Dsn7ixFt.js} +38 -113
- package/dist/chunks/{cli-api.COn58yrl.js → cli-api.DfGJyldU.js} +829 -1232
- package/dist/chunks/{config.d.CKNVOKm0.d.ts → config.d._GBBbReY.d.ts} +1 -0
- package/dist/chunks/{console.Duv2dVIC.js → console.B0quX7yH.js} +32 -68
- package/dist/chunks/{coverage.B6cReEn1.js → coverage.Dvxug1RM.js} +210 -579
- package/dist/chunks/{creator.DUVZ6rfm.js → creator.KEg6n5IC.js} +28 -74
- package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
- package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
- package/dist/chunks/{globals.CJQ63oO0.js → globals.lgsmH00r.js} +5 -5
- package/dist/chunks/{index.QZr3S3vQ.js → index.AR8aAkCC.js} +2 -2
- package/dist/chunks/{index.DQhAfQQU.js → index.C3EbxYwt.js} +276 -607
- package/dist/chunks/{index.oWRWx-nj.js → index.CsFXYRkW.js} +17 -36
- package/dist/chunks/{index.DgN0Zk9a.js → index.D2B6d2vv.js} +14 -24
- package/dist/chunks/{index.BRtIe7r8.js → index.DfviD7lX.js} +55 -110
- package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
- package/dist/chunks/{moduleRunner.d.mmOmOGrW.d.ts → moduleRunner.d.CX4DuqOx.d.ts} +2 -2
- package/dist/chunks/{node.4JV5OXkt.js → node.BOqcT2jW.js} +1 -1
- package/dist/chunks/{plugin.d.CvOlgjxK.d.ts → plugin.d.vcD4xbMS.d.ts} +1 -1
- package/dist/chunks/{reporters.d.CYE9sT5z.d.ts → reporters.d.BC86JJdB.d.ts} +799 -758
- package/dist/chunks/{resolver.D5bG4zy5.js → resolver.Bx6lE0iq.js} +21 -64
- package/dist/chunks/{rpc.DGoW_Vl-.js → rpc.RpPylpp0.js} +7 -21
- package/dist/chunks/{runBaseTests.B3KcKqlF.js → runBaseTests.D6sfuWBM.js} +25 -54
- package/dist/chunks/{setup-common.lgPs-bYv.js → setup-common.hLGRxhC8.js} +9 -22
- package/dist/chunks/{startModuleRunner.C8FtT_BY.js → startModuleRunner.C8TW8zTN.js} +83 -205
- package/dist/chunks/{typechecker.BgoW4nTA.js → typechecker.DSo_maXz.js} +97 -209
- package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
- package/dist/chunks/{utils.B9FY3b73.js → utils.C7__0Iv5.js} +5 -14
- package/dist/chunks/{vi.DGAfBY4R.js → vi.BfdOiD4j.js} +110 -267
- package/dist/chunks/{vm.BKfKvaKl.js → vm.BHBje7cC.js} +73 -177
- package/dist/chunks/{worker.d.Db-UVmXc.d.ts → worker.d.BKu8cnnX.d.ts} +1 -1
- package/dist/chunks/{worker.d.D9QWnzAe.d.ts → worker.d.DYlqbejz.d.ts} +1 -1
- package/dist/cli.js +3 -3
- package/dist/config.d.ts +7 -7
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +2 -2
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +33 -84
- package/dist/module-runner.js +2 -2
- package/dist/node.d.ts +11 -9
- package/dist/node.js +16 -27
- package/dist/reporters.d.ts +5 -5
- package/dist/reporters.js +3 -3
- package/dist/runners.d.ts +1 -1
- package/dist/runners.js +23 -51
- package/dist/snapshot.js +2 -2
- package/dist/suite.js +2 -2
- package/dist/worker.js +18 -34
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +19 -37
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/dist/workers.d.ts +3 -3
- package/dist/workers.js +11 -11
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as SerializedTestSpecification } from './chunks/browser.d.
|
|
2
|
-
export { B as BrowserTesterOptions } from './chunks/browser.d.
|
|
1
|
+
import { S as SerializedTestSpecification } from './chunks/browser.d.DOMmqJQx.js';
|
|
2
|
+
export { B as BrowserTesterOptions } from './chunks/browser.d.DOMmqJQx.js';
|
|
3
3
|
import './chunks/global.d.K6uBQHzY.js';
|
|
4
4
|
import { File, TestAnnotation, TaskResultPack, TaskEventPack, TaskPopulated } from '@vitest/runner';
|
|
5
5
|
export { CancelReason, HookCleanupCallback, HookListener, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
6
|
-
import { a as BirpcReturn } from './chunks/worker.d.
|
|
7
|
-
export { C as ContextRPC, c as ContextTestEnvironment, b as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.
|
|
8
|
-
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.
|
|
9
|
-
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.
|
|
6
|
+
import { a as BirpcReturn } from './chunks/worker.d.DYlqbejz.js';
|
|
7
|
+
export { C as ContextRPC, c as ContextTestEnvironment, b as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.DYlqbejz.js';
|
|
8
|
+
import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d._GBBbReY.js';
|
|
9
|
+
export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d._GBBbReY.js';
|
|
10
10
|
import { b as Awaitable, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/environment.d.2fYMoz3o.js';
|
|
11
11
|
export { A as AfterSuiteRunMeta } from './chunks/environment.d.2fYMoz3o.js';
|
|
12
12
|
import { ExpectStatic } from '@vitest/expect';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.
|
|
2
|
-
export { b as bench } from './chunks/benchmark.
|
|
3
|
-
export { a as assertType } from './chunks/index.
|
|
1
|
+
export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.BfdOiD4j.js';
|
|
2
|
+
export { b as bench } from './chunks/benchmark.UW6Ezvxy.js';
|
|
3
|
+
export { a as assertType } from './chunks/index.AR8aAkCC.js';
|
|
4
4
|
export { expectTypeOf } from 'expect-type';
|
|
5
5
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
6
6
|
export { EvaluatedModules } from 'vite/module-runner';
|
|
@@ -9,11 +9,11 @@ export { chai };
|
|
|
9
9
|
export { assert, should } from 'chai';
|
|
10
10
|
import '@vitest/expect';
|
|
11
11
|
import '@vitest/runner/utils';
|
|
12
|
-
import './chunks/utils.
|
|
12
|
+
import './chunks/utils.C7__0Iv5.js';
|
|
13
13
|
import '@vitest/utils';
|
|
14
14
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
15
15
|
import '@vitest/snapshot';
|
|
16
16
|
import '@vitest/utils/error';
|
|
17
17
|
import '@vitest/spy';
|
|
18
18
|
import '@vitest/utils/source-map';
|
|
19
|
-
import './chunks/date.
|
|
19
|
+
import './chunks/date.-jtEtIeV.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'vite/module-runner';
|
|
2
|
-
export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.
|
|
2
|
+
export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.CX4DuqOx.js';
|
|
3
3
|
import 'node:vm';
|
|
4
|
-
import './chunks/worker.d.
|
|
4
|
+
import './chunks/worker.d.DYlqbejz.js';
|
|
5
5
|
import '@vitest/runner';
|
|
6
|
-
import './chunks/config.d.
|
|
6
|
+
import './chunks/config.d._GBBbReY.js';
|
|
7
7
|
import '@vitest/pretty-format';
|
|
8
8
|
import '@vitest/snapshot';
|
|
9
9
|
import '@vitest/utils/diff';
|
package/dist/module-evaluator.js
CHANGED
|
@@ -9,14 +9,12 @@ class ModuleDebug {
|
|
|
9
9
|
executionStack = [];
|
|
10
10
|
startCalculateModuleExecutionInfo(filename, startOffset) {
|
|
11
11
|
const startTime = performanceNow();
|
|
12
|
-
this.executionStack.push({
|
|
12
|
+
return this.executionStack.push({
|
|
13
13
|
filename,
|
|
14
14
|
startTime,
|
|
15
15
|
subImportTime: 0
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const duration = performanceNow() - startTime;
|
|
19
|
-
const currentExecution = this.executionStack.pop();
|
|
16
|
+
}), () => {
|
|
17
|
+
const duration = performanceNow() - startTime, currentExecution = this.executionStack.pop();
|
|
20
18
|
if (currentExecution == null) throw new Error("Execution stack is empty, this should never happen");
|
|
21
19
|
const selfTime = duration - currentExecution.subImportTime;
|
|
22
20
|
if (this.executionStack.length > 0) this.executionStack.at(-1).subImportTime += duration;
|
|
@@ -39,10 +37,7 @@ class VitestModuleEvaluator {
|
|
|
39
37
|
primitives;
|
|
40
38
|
debug = new ModuleDebug();
|
|
41
39
|
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;
|
|
40
|
+
if (this.options = options, this.vm = vmOptions, this.stubs = getDefaultRequestStubs(vmOptions?.context), options.compiledFunctionArgumentsNames) this.compiledFunctionArgumentsNames = options.compiledFunctionArgumentsNames;
|
|
46
41
|
if (options.compiledFunctionArgumentsValues) this.compiledFunctionArgumentsValues = options.compiledFunctionArgumentsValues;
|
|
47
42
|
if (vmOptions) this.primitives = vm.runInContext("({ Object, Proxy, Reflect })", vmOptions.context);
|
|
48
43
|
else this.primitives = {
|
|
@@ -57,24 +52,18 @@ class VitestModuleEvaluator {
|
|
|
57
52
|
// https://github.com/vitejs/vite/pull/20449
|
|
58
53
|
if (!isWindows || isBuiltin(id) || /^(?:node:|data:|http:|https:|file:)/.test(id)) return id;
|
|
59
54
|
const [filepath, query] = id.split("?");
|
|
60
|
-
|
|
61
|
-
return pathToFileURL(filepath).toString();
|
|
55
|
+
return query ? `${pathToFileURL(filepath).toString()}?${query}` : pathToFileURL(filepath).toString();
|
|
62
56
|
}
|
|
63
57
|
async runExternalModule(id) {
|
|
64
58
|
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);
|
|
59
|
+
const file = this.convertIdToImportUrl(id), namespace = this.vm ? await this.vm.externalModulesExecutor.import(file) : await import(file);
|
|
67
60
|
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, {
|
|
61
|
+
const { mod, defaultExport } = interopModule(namespace), { Proxy, Reflect } = this.primitives, proxy = new Proxy(mod, {
|
|
71
62
|
get(mod, prop) {
|
|
72
|
-
|
|
73
|
-
return mod[prop] ?? defaultExport?.[prop];
|
|
63
|
+
return prop === "default" ? defaultExport : mod[prop] ?? defaultExport?.[prop];
|
|
74
64
|
},
|
|
75
65
|
has(mod, prop) {
|
|
76
|
-
|
|
77
|
-
return prop in mod || defaultExport && prop in defaultExport;
|
|
66
|
+
return prop === "default" ? defaultExport !== void 0 : prop in mod || defaultExport && prop in defaultExport;
|
|
78
67
|
},
|
|
79
68
|
getOwnPropertyDescriptor(mod, prop) {
|
|
80
69
|
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
@@ -90,58 +79,40 @@ class VitestModuleEvaluator {
|
|
|
90
79
|
}
|
|
91
80
|
async runInlinedModule(context, code, module) {
|
|
92
81
|
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");
|
|
82
|
+
const { Reflect, Proxy, Object } = this.primitives, exportsObject = context[ssrModuleExportsKey], SYMBOL_NOT_DEFINED = Symbol("not defined");
|
|
96
83
|
let moduleExports = SYMBOL_NOT_DEFINED;
|
|
97
84
|
// this proxy is triggered only on exports.{name} and module.exports access
|
|
98
85
|
// inside the module itself. imported module is always "exports"
|
|
99
86
|
const cjsExports = new Proxy(exportsObject, {
|
|
100
87
|
get: (target, p, receiver) => {
|
|
101
|
-
|
|
102
|
-
return Reflect.get(Object.prototype, p, receiver);
|
|
88
|
+
return Reflect.has(target, p) ? Reflect.get(target, p, receiver) : Reflect.get(Object.prototype, p, receiver);
|
|
103
89
|
},
|
|
104
90
|
getPrototypeOf: () => Object.prototype,
|
|
105
91
|
set: (_, p, value) => {
|
|
106
92
|
// treat "module.exports =" the same as "exports.default =" to not have nested "default.default",
|
|
107
93
|
// 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
|
-
}
|
|
94
|
+
if (p === "default" && this.shouldInterop(module.file, { default: value }) && cjsExports !== value) return exportAll(cjsExports, value), exportsObject.default = value, true;
|
|
113
95
|
if (!Reflect.has(exportsObject, "default")) exportsObject.default = {};
|
|
114
96
|
// returns undefined, when accessing named exports, if default is not an object
|
|
115
97
|
// 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
|
-
}
|
|
98
|
+
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) return defineExport(exportsObject, p, () => void 0), true;
|
|
120
99
|
if (!isPrimitive(exportsObject.default)) exportsObject.default[p] = value;
|
|
121
100
|
if (p !== "default") defineExport(exportsObject, p, () => value);
|
|
122
101
|
return true;
|
|
123
102
|
}
|
|
124
|
-
})
|
|
125
|
-
const moduleProxy = {
|
|
103
|
+
}), moduleProxy = {
|
|
126
104
|
set exports(value) {
|
|
127
|
-
exportAll(cjsExports, value);
|
|
128
|
-
exportsObject.default = value;
|
|
129
|
-
moduleExports = value;
|
|
105
|
+
exportAll(cjsExports, value), exportsObject.default = value, moduleExports = value;
|
|
130
106
|
},
|
|
131
107
|
get exports() {
|
|
132
108
|
return cjsExports;
|
|
133
109
|
}
|
|
134
|
-
};
|
|
135
|
-
const meta = context[ssrImportMetaKey];
|
|
136
|
-
const testFilepath = this.options.getCurrentTestFilepath?.();
|
|
110
|
+
}, meta = context[ssrImportMetaKey], testFilepath = this.options.getCurrentTestFilepath?.();
|
|
137
111
|
if (testFilepath === module.file) {
|
|
138
112
|
const globalNamespace = this.vm?.context || globalThis;
|
|
139
113
|
Object.defineProperty(meta, "vitest", { get: () => globalNamespace.__vitest_index__ });
|
|
140
114
|
}
|
|
141
|
-
const filename = meta.filename
|
|
142
|
-
const dirname = meta.dirname;
|
|
143
|
-
const require = this.createRequire(filename);
|
|
144
|
-
const argumentsList = [
|
|
115
|
+
const filename = meta.filename, dirname = meta.dirname, require = this.createRequire(filename), argumentsList = [
|
|
145
116
|
ssrModuleExportsKey,
|
|
146
117
|
ssrImportMetaKey,
|
|
147
118
|
ssrImportKey,
|
|
@@ -156,22 +127,14 @@ class VitestModuleEvaluator {
|
|
|
156
127
|
];
|
|
157
128
|
if (this.compiledFunctionArgumentsNames) argumentsList.push(...this.compiledFunctionArgumentsNames);
|
|
158
129
|
// 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 = {
|
|
130
|
+
const codeDefinition = `'use strict';async (${argumentsList.join(",")})=>{{`, wrappedCode = `${codeDefinition}${code}\n}}`, options = {
|
|
162
131
|
filename: module.file || filename,
|
|
163
132
|
lineOffset: 0,
|
|
164
133
|
columnOffset: -codeDefinition.length
|
|
165
|
-
};
|
|
166
|
-
const finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(filename, codeDefinition.length);
|
|
134
|
+
}, finishModuleExecutionInfo = this.debug.startCalculateModuleExecutionInfo(filename, codeDefinition.length);
|
|
167
135
|
try {
|
|
168
|
-
const initModule = this.vm ? vm.runInContext(wrappedCode, this.vm.context, options) : vm.runInThisContext(wrappedCode, options)
|
|
169
|
-
|
|
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);
|
|
136
|
+
const initModule = this.vm ? vm.runInContext(wrappedCode, this.vm.context, options) : vm.runInThisContext(wrappedCode, options), dynamicRequest = async (dep, options) => {
|
|
137
|
+
return dep = String(dep), dep[0] === "#" ? context[ssrDynamicImportKey](wrapId(dep), options) : context[ssrDynamicImportKey](dep, options);
|
|
175
138
|
};
|
|
176
139
|
await initModule(
|
|
177
140
|
context[ssrModuleExportsKey],
|
|
@@ -199,16 +162,12 @@ class VitestModuleEvaluator {
|
|
|
199
162
|
}
|
|
200
163
|
}
|
|
201
164
|
createRequire(filename) {
|
|
202
|
-
|
|
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);
|
|
165
|
+
return filename.startsWith("\0") || !isAbsolute(filename) ? () => ({}) : this.vm ? this.vm.externalModulesExecutor.createRequire(filename) : createRequire(filename);
|
|
206
166
|
}
|
|
207
167
|
shouldInterop(path, mod) {
|
|
208
|
-
if (this.options.interopDefault === false) return false;
|
|
209
168
|
// never interop ESM modules
|
|
210
169
|
// TODO: should also skip for `.js` with `type="module"`
|
|
211
|
-
return !path.endsWith(".mjs") && "default" in mod;
|
|
170
|
+
return this.options.interopDefault === false ? false : !path.endsWith(".mjs") && "default" in mod;
|
|
212
171
|
}
|
|
213
172
|
}
|
|
214
173
|
function createImportMetaEnvProxy() {
|
|
@@ -220,9 +179,7 @@ function createImportMetaEnvProxy() {
|
|
|
220
179
|
];
|
|
221
180
|
return new Proxy(process.env, {
|
|
222
181
|
get(_, key) {
|
|
223
|
-
|
|
224
|
-
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
225
|
-
return process.env[key];
|
|
182
|
+
return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
|
|
226
183
|
},
|
|
227
184
|
set(_, key, value) {
|
|
228
185
|
if (typeof key !== "string") return true;
|
|
@@ -239,12 +196,8 @@ function updateStyle(id, css) {
|
|
|
239
196
|
element.textContent = css;
|
|
240
197
|
return;
|
|
241
198
|
}
|
|
242
|
-
const head = document.querySelector("head");
|
|
243
|
-
|
|
244
|
-
style.setAttribute("type", "text/css");
|
|
245
|
-
style.setAttribute("data-vite-dev-id", id);
|
|
246
|
-
style.textContent = css;
|
|
247
|
-
head?.appendChild(style);
|
|
199
|
+
const head = document.querySelector("head"), style = document.createElement("style");
|
|
200
|
+
style.setAttribute("type", "text/css"), style.setAttribute("data-vite-dev-id", id), style.textContent = css, head?.appendChild(style);
|
|
248
201
|
}
|
|
249
202
|
function removeStyle(id) {
|
|
250
203
|
if (typeof document === "undefined") return;
|
|
@@ -280,13 +233,11 @@ function getDefaultRequestStubs(context) {
|
|
|
280
233
|
return { "/@vite/client": clientStub };
|
|
281
234
|
}
|
|
282
235
|
function exportAll(exports, sourceModule) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
defineExport(exports, key, () => sourceModule[key]);
|
|
289
|
-
} catch {}
|
|
236
|
+
if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
|
|
237
|
+
for (const key in sourceModule) if (key !== "default" && !(key in exports)) try {
|
|
238
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
239
|
+
} catch {}
|
|
240
|
+
}
|
|
290
241
|
}
|
|
291
242
|
// keep consistency with Vite on how exports are defined
|
|
292
243
|
function defineExport(exports, key, value) {
|
|
@@ -307,16 +258,14 @@ function interopModule(mod) {
|
|
|
307
258
|
};
|
|
308
259
|
let defaultExport = "default" in mod ? mod.default : mod;
|
|
309
260
|
if (!isPrimitive(defaultExport) && "__esModule" in defaultExport) {
|
|
310
|
-
mod = defaultExport;
|
|
311
|
-
if ("default" in defaultExport) defaultExport = defaultExport.default;
|
|
261
|
+
if (mod = defaultExport, "default" in defaultExport) defaultExport = defaultExport.default;
|
|
312
262
|
}
|
|
313
263
|
return {
|
|
314
264
|
mod,
|
|
315
265
|
defaultExport
|
|
316
266
|
};
|
|
317
267
|
}
|
|
318
|
-
const VALID_ID_PREFIX = `/@id
|
|
319
|
-
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
268
|
+
const VALID_ID_PREFIX = `/@id/`, NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
320
269
|
function wrapId(id) {
|
|
321
270
|
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
322
271
|
}
|
package/dist/module-runner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { VitestModuleEvaluator } from './module-evaluator.js';
|
|
2
|
-
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.
|
|
3
|
-
export { g as getWorkerState } from './chunks/utils.
|
|
2
|
+
export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.C8TW8zTN.js';
|
|
3
|
+
export { g as getWorkerState } from './chunks/utils.C7__0Iv5.js';
|
|
4
4
|
import 'node:module';
|
|
5
5
|
import 'node:url';
|
|
6
6
|
import 'node:vm';
|
package/dist/node.d.ts
CHANGED
|
@@ -3,22 +3,22 @@ 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.BC86JJdB.js';
|
|
7
|
+
export { aq as BaseCoverageOptions, N as BenchmarkUserOptions, Q as BrowserBuiltinProvider, X as BrowserCommand, Y as BrowserCommandContext, Z as BrowserConfigOptions, _ as BrowserInstanceOption, $ as BrowserModuleMocker, a0 as BrowserOrchestrator, a1 as BrowserProvider, a2 as BrowserProviderInitializationOptions, a3 as BrowserProviderModule, a4 as BrowserProviderOptions, a5 as BrowserScript, a6 as BrowserServerState, a7 as BrowserServerStateSession, ae as BuiltinEnvironment, a8 as CDPSession, af as CSSModuleScopeStrategy, ar as CoverageIstanbulOptions, as as CoverageOptions, at as CoverageProvider, au as CoverageProviderModule, av as CoverageReporter, c as CoverageV8Options, aw as CustomProviderOptions, ag as DepsOptimizationOptions, ah as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, q as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, m as OnTestsRerunHandler, a9 as ParentProjectBrowser, ai as Pool, aj as PoolOptions, P as ProcessPool, aa as ProjectBrowser, ak as ProjectConfig, b as ReportContext, ay as ReportedHookContext, az as Reporter, am as ResolveSnapshotPathHandler, an as ResolveSnapshotPathHandlerContext, ab as ResolvedBrowserOptions, R as ResolvedCoverageOptions, al 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, aA as TestRunEndReason, ax as TestRunResult, K as TestSequencerConstructor, D as TestState, E as TestSuite, F as TestSuiteState, ac as ToMatchScreenshotComparators, ad as ToMatchScreenshotOptions, ao as TypecheckConfig, U as UserWorkspaceConfig, ap as VitestEnvironment, n as VitestPackageInstaller, W as WatcherTriggerPattern, o as WorkspaceSpec, G as experimental_getRunnerTask, p as getFilePoolName } from './chunks/reporters.d.BC86JJdB.js';
|
|
8
|
+
import { R as RuntimeRPC } from './chunks/worker.d.DYlqbejz.js';
|
|
9
|
+
export { T as TestExecutionType } from './chunks/worker.d.DYlqbejz.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.vcD4xbMS.js';
|
|
12
|
+
export { W as WorkerContext } from './chunks/worker.d.BKu8cnnX.js';
|
|
13
13
|
import { Debugger } from 'debug';
|
|
14
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._GBBbReY.js';
|
|
17
17
|
export { SerializedError } from '@vitest/utils';
|
|
18
18
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
19
19
|
import './chunks/environment.d.2fYMoz3o.js';
|
|
20
20
|
import 'node:console';
|
|
21
|
-
import './chunks/browser.d.
|
|
21
|
+
import './chunks/browser.d.DOMmqJQx.js';
|
|
22
22
|
import '@vitest/mocker';
|
|
23
23
|
import '@vitest/utils/source-map';
|
|
24
24
|
import '@vitest/pretty-format';
|
|
@@ -61,6 +61,8 @@ type Context = RootAndTarget & {
|
|
|
61
61
|
|
|
62
62
|
declare function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean;
|
|
63
63
|
|
|
64
|
+
declare function escapeTestName(label: string, dynamic: boolean): string;
|
|
65
|
+
|
|
64
66
|
interface CliOptions extends UserConfig {
|
|
65
67
|
/**
|
|
66
68
|
* Override the watch mode
|
|
@@ -164,5 +166,5 @@ declare const createViteServer: typeof vite.createServer;
|
|
|
164
166
|
// rolldownVersion is exported only by rolldown-vite
|
|
165
167
|
declare const rolldownVersion: string | undefined;
|
|
166
168
|
|
|
167
|
-
export { ApiConfig, BaseSequencer, GitNotFoundError, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, Vitest, VitestOptions, VitestPlugin, VitestRunMode, TestProject as WorkspaceProject, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
|
|
169
|
+
export { ApiConfig, BaseSequencer, GitNotFoundError, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, Vitest, VitestOptions, VitestPlugin, VitestRunMode, TestProject as WorkspaceProject, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
|
|
168
170
|
export type { CliParseOptions, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget };
|
package/dist/node.js
CHANGED
|
@@ -1,27 +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,
|
|
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.DfGJyldU.js';
|
|
5
|
+
export { G as GitNotFoundError, F as TestsNotFoundError, b as VitestPackageInstaller, h as createDebugger, g as createViteLogger, c as createVitest, e as escapeTestName, d as experimental_getRunnerTask, i as isValidApiRequest, f as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.DfGJyldU.js';
|
|
6
|
+
export { p as parseCLI } from './chunks/cac.Dsn7ixFt.js';
|
|
7
|
+
import { r as resolveConfig$2 } from './chunks/coverage.Dvxug1RM.js';
|
|
8
|
+
export { b as BaseSequencer, c as createMethodsRPC, g as getFilePoolName, a as resolveApiServerConfig } from './chunks/coverage.Dvxug1RM.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
12
|
import { c as configFiles } from './chunks/constants.D_Q9UYh-.js';
|
|
13
13
|
export { distDir, rootDir } from './path.js';
|
|
14
|
-
import createDebug from 'debug';
|
|
15
14
|
export { generateFileHash } from '@vitest/runner/utils';
|
|
16
15
|
import 'node:fs';
|
|
17
16
|
import './chunks/coverage.D_JHT54q.js';
|
|
18
17
|
import 'node:path';
|
|
18
|
+
import 'node:os';
|
|
19
19
|
import '@vitest/snapshot/manager';
|
|
20
20
|
import './chunks/index.Bgo3tNWt.js';
|
|
21
|
-
import './chunks/index.
|
|
21
|
+
import './chunks/index.C3EbxYwt.js';
|
|
22
22
|
import 'node:fs/promises';
|
|
23
|
-
import './chunks/typechecker.
|
|
24
|
-
import 'node:os';
|
|
23
|
+
import './chunks/typechecker.DSo_maXz.js';
|
|
25
24
|
import 'node:perf_hooks';
|
|
26
25
|
import '@vitest/utils/source-map';
|
|
27
26
|
import 'tinyexec';
|
|
@@ -44,6 +43,7 @@ import 'zlib';
|
|
|
44
43
|
import 'buffer';
|
|
45
44
|
import './chunks/_commonjsHelpers.BFTU3MAI.js';
|
|
46
45
|
import 'node:crypto';
|
|
46
|
+
import 'debug';
|
|
47
47
|
import '#module-evaluator';
|
|
48
48
|
import 'vite/module-runner';
|
|
49
49
|
import 'node:url';
|
|
@@ -52,9 +52,9 @@ import 'tinyglobby';
|
|
|
52
52
|
import 'magic-string';
|
|
53
53
|
import '@vitest/mocker/node';
|
|
54
54
|
import './chunks/defaults.CXFFjsi8.js';
|
|
55
|
-
import './chunks/resolver.
|
|
55
|
+
import './chunks/resolver.Bx6lE0iq.js';
|
|
56
56
|
import 'es-module-lexer';
|
|
57
|
-
import './chunks/index.
|
|
57
|
+
import './chunks/index.D2B6d2vv.js';
|
|
58
58
|
import 'node:assert';
|
|
59
59
|
import '@vitest/utils/error';
|
|
60
60
|
import 'node:readline';
|
|
@@ -68,33 +68,22 @@ import 'readline';
|
|
|
68
68
|
|
|
69
69
|
// this is only exported as a public function and not used inside vitest
|
|
70
70
|
async function resolveConfig(options = {}, viteOverrides = {}) {
|
|
71
|
-
const root = slash(resolve(options.root || process.cwd()));
|
|
72
|
-
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
71
|
+
const root = slash(resolve(options.root || process.cwd())), configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
73
72
|
options.config = configPath;
|
|
74
|
-
const vitest = new Vitest("test", deepClone(options))
|
|
75
|
-
const config = await resolveConfig$1(mergeConfig({
|
|
73
|
+
const vitest = new Vitest("test", deepClone(options)), config = await resolveConfig$1(mergeConfig({
|
|
76
74
|
configFile: configPath,
|
|
77
75
|
mode: options.mode || "test",
|
|
78
76
|
plugins: [await VitestPlugin(options, vitest)]
|
|
79
|
-
}, mergeConfig(viteOverrides, { root: options.root })), "serve");
|
|
80
|
-
|
|
81
|
-
const updatedOptions = Reflect.get(config, "_vitest");
|
|
82
|
-
const vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
|
|
83
|
-
await vitest.close();
|
|
84
|
-
return {
|
|
77
|
+
}, mergeConfig(viteOverrides, { root: options.root })), "serve"), updatedOptions = Reflect.get(config, "_vitest"), vitestConfig = resolveConfig$2(vitest, updatedOptions, config);
|
|
78
|
+
return await vitest.close(), {
|
|
85
79
|
viteConfig: config,
|
|
86
80
|
vitestConfig
|
|
87
81
|
};
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
function createDebugger(namespace) {
|
|
91
|
-
const debug = createDebug(namespace);
|
|
92
|
-
if (debug.enabled) return debug;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
84
|
const version = Vitest.version;
|
|
96
85
|
const createViteServer = vite.createServer;
|
|
97
86
|
// rolldownVersion is exported only by rolldown-vite
|
|
98
87
|
const rolldownVersion = vite.rolldownVersion;
|
|
99
88
|
|
|
100
|
-
export { VitestPlugin,
|
|
89
|
+
export { VitestPlugin, createViteServer, resolveConfig, rolldownVersion, version };
|
package/dist/reporters.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aO as BaseReporter, aP as BenchmarkBuiltinReporters, aB as BenchmarkReporter, aC as BenchmarkReportsMap, aQ as BuiltinReporterOptions, aR as BuiltinReporters, aD as DefaultReporter, aE as DotReporter, aF as GithubActionsReporter, aG as HangingProcessReporter, aI as JUnitReporter, aS as JsonAssertionResult, aH as JsonReporter, aT as JsonTestResult, aU as JsonTestResults, ay as ReportedHookContext, az as Reporter, aJ as ReportersMap, aK as TapFlatReporter, aL as TapReporter, aA as TestRunEndReason, aM as VerboseBenchmarkReporter, aN as VerboseReporter } from './chunks/reporters.d.BC86JJdB.js';
|
|
2
2
|
import '@vitest/runner';
|
|
3
|
-
import './chunks/environment.d.2fYMoz3o.js';
|
|
4
3
|
import '@vitest/utils';
|
|
4
|
+
import './chunks/environment.d.2fYMoz3o.js';
|
|
5
5
|
import 'node:stream';
|
|
6
6
|
import 'vite';
|
|
7
7
|
import 'node:console';
|
|
8
|
-
import './chunks/browser.d.
|
|
9
|
-
import './chunks/worker.d.
|
|
8
|
+
import './chunks/browser.d.DOMmqJQx.js';
|
|
9
|
+
import './chunks/worker.d.DYlqbejz.js';
|
|
10
10
|
import 'vite/module-runner';
|
|
11
|
-
import './chunks/config.d.
|
|
11
|
+
import './chunks/config.d._GBBbReY.js';
|
|
12
12
|
import '@vitest/pretty-format';
|
|
13
13
|
import '@vitest/snapshot';
|
|
14
14
|
import '@vitest/utils/diff';
|
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.C3EbxYwt.js';
|
|
2
|
+
export { B as BenchmarkReporter, a as BenchmarkReportsMap, V as VerboseBenchmarkReporter } from './chunks/index.D2B6d2vv.js';
|
|
3
3
|
import 'node:fs';
|
|
4
4
|
import 'node:fs/promises';
|
|
5
5
|
import 'pathe';
|
|
6
|
-
import './chunks/typechecker.
|
|
6
|
+
import './chunks/typechecker.DSo_maXz.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,7 +1,7 @@
|
|
|
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._GBBbReY.js';
|
|
5
5
|
import '@vitest/pretty-format';
|
|
6
6
|
import '@vitest/snapshot';
|
|
7
7
|
import '@vitest/utils/diff';
|