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.
Files changed (64) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{base.DMfOuRWD.js → base.BXI97p6t.js} +7 -16
  5. package/dist/chunks/{benchmark.CtuRzf-i.js → benchmark.UW6Ezvxy.js} +4 -9
  6. package/dist/chunks/{browser.d.Cawq_X_N.d.ts → browser.d.DOMmqJQx.d.ts} +1 -1
  7. package/dist/chunks/{cac.CKnbxhn2.js → cac.Dsn7ixFt.js} +38 -113
  8. package/dist/chunks/{cli-api.COn58yrl.js → cli-api.DfGJyldU.js} +829 -1232
  9. package/dist/chunks/{config.d.CKNVOKm0.d.ts → config.d._GBBbReY.d.ts} +1 -0
  10. package/dist/chunks/{console.Duv2dVIC.js → console.B0quX7yH.js} +32 -68
  11. package/dist/chunks/{coverage.B6cReEn1.js → coverage.Dvxug1RM.js} +210 -579
  12. package/dist/chunks/{creator.DUVZ6rfm.js → creator.KEg6n5IC.js} +28 -74
  13. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  14. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  15. package/dist/chunks/{globals.CJQ63oO0.js → globals.lgsmH00r.js} +5 -5
  16. package/dist/chunks/{index.QZr3S3vQ.js → index.AR8aAkCC.js} +2 -2
  17. package/dist/chunks/{index.DQhAfQQU.js → index.C3EbxYwt.js} +276 -607
  18. package/dist/chunks/{index.oWRWx-nj.js → index.CsFXYRkW.js} +17 -36
  19. package/dist/chunks/{index.DgN0Zk9a.js → index.D2B6d2vv.js} +14 -24
  20. package/dist/chunks/{index.BRtIe7r8.js → index.DfviD7lX.js} +55 -110
  21. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  22. package/dist/chunks/{moduleRunner.d.mmOmOGrW.d.ts → moduleRunner.d.CX4DuqOx.d.ts} +2 -2
  23. package/dist/chunks/{node.4JV5OXkt.js → node.BOqcT2jW.js} +1 -1
  24. package/dist/chunks/{plugin.d.CvOlgjxK.d.ts → plugin.d.vcD4xbMS.d.ts} +1 -1
  25. package/dist/chunks/{reporters.d.CYE9sT5z.d.ts → reporters.d.BC86JJdB.d.ts} +799 -758
  26. package/dist/chunks/{resolver.D5bG4zy5.js → resolver.Bx6lE0iq.js} +21 -64
  27. package/dist/chunks/{rpc.DGoW_Vl-.js → rpc.RpPylpp0.js} +7 -21
  28. package/dist/chunks/{runBaseTests.B3KcKqlF.js → runBaseTests.D6sfuWBM.js} +25 -54
  29. package/dist/chunks/{setup-common.lgPs-bYv.js → setup-common.hLGRxhC8.js} +9 -22
  30. package/dist/chunks/{startModuleRunner.C8FtT_BY.js → startModuleRunner.C8TW8zTN.js} +83 -205
  31. package/dist/chunks/{typechecker.BgoW4nTA.js → typechecker.DSo_maXz.js} +97 -209
  32. package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
  33. package/dist/chunks/{utils.B9FY3b73.js → utils.C7__0Iv5.js} +5 -14
  34. package/dist/chunks/{vi.DGAfBY4R.js → vi.BfdOiD4j.js} +110 -267
  35. package/dist/chunks/{vm.BKfKvaKl.js → vm.BHBje7cC.js} +73 -177
  36. package/dist/chunks/{worker.d.Db-UVmXc.d.ts → worker.d.BKu8cnnX.d.ts} +1 -1
  37. package/dist/chunks/{worker.d.D9QWnzAe.d.ts → worker.d.DYlqbejz.d.ts} +1 -1
  38. package/dist/cli.js +3 -3
  39. package/dist/config.d.ts +7 -7
  40. package/dist/coverage.d.ts +4 -4
  41. package/dist/coverage.js +2 -2
  42. package/dist/environments.js +1 -1
  43. package/dist/index.d.ts +6 -6
  44. package/dist/index.js +5 -5
  45. package/dist/module-evaluator.d.ts +3 -3
  46. package/dist/module-evaluator.js +33 -84
  47. package/dist/module-runner.js +2 -2
  48. package/dist/node.d.ts +11 -9
  49. package/dist/node.js +16 -27
  50. package/dist/reporters.d.ts +5 -5
  51. package/dist/reporters.js +3 -3
  52. package/dist/runners.d.ts +1 -1
  53. package/dist/runners.js +23 -51
  54. package/dist/snapshot.js +2 -2
  55. package/dist/suite.js +2 -2
  56. package/dist/worker.js +18 -34
  57. package/dist/workers/forks.js +4 -4
  58. package/dist/workers/runVmTests.js +19 -37
  59. package/dist/workers/threads.js +4 -4
  60. package/dist/workers/vmForks.js +7 -7
  61. package/dist/workers/vmThreads.js +7 -7
  62. package/dist/workers.d.ts +3 -3
  63. package/dist/workers.js +11 -11
  64. package/package.json +11 -11
package/dist/runners.js CHANGED
@@ -1,19 +1,19 @@
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.CtuRzf-i.js';
4
- import { g as getWorkerState } from './chunks/utils.B9FY3b73.js';
3
+ import { a as getBenchOptions, g as getBenchFn } from './chunks/benchmark.UW6Ezvxy.js';
4
+ import { g as getWorkerState } from './chunks/utils.C7__0Iv5.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.DGAfBY4R.js';
10
- import { r as rpc } from './chunks/rpc.DGoW_Vl-.js';
9
+ import { g as getSnapshotClient, i as inject, c as createExpect, v as vi } from './chunks/vi.BfdOiD4j.js';
10
+ import { r as rpc } from './chunks/rpc.RpPylpp0.js';
11
11
  import 'chai';
12
12
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
13
13
  import '@vitest/snapshot';
14
14
  import '@vitest/spy';
15
15
  import '@vitest/utils/source-map';
16
- import './chunks/date.Bq6ZW5rf.js';
16
+ import './chunks/date.-jtEtIeV.js';
17
17
  import './chunks/index.Bgo3tNWt.js';
18
18
 
19
19
  function createBenchmarkResult(name) {
@@ -26,10 +26,7 @@ function createBenchmarkResult(name) {
26
26
  }
27
27
  const benchmarkTasks = /* @__PURE__ */ new WeakMap();
28
28
  async function runBenchmarkSuite(suite, runner) {
29
- const { Task, Bench } = await runner.importTinybench();
30
- const start = performance.now();
31
- const benchmarkGroup = [];
32
- const benchmarkSuiteGroup = [];
29
+ const { Task, Bench } = await runner.importTinybench(), start = performance.now(), benchmarkGroup = [], benchmarkSuiteGroup = [];
33
30
  for (const task of suite.tasks) {
34
31
  if (task.mode !== "run" && task.mode !== "queued") continue;
35
32
  if (task.meta?.benchmark) benchmarkGroup.push(task);
@@ -43,55 +40,38 @@ async function runBenchmarkSuite(suite, runner) {
43
40
  state: "run",
44
41
  startTime: start,
45
42
  benchmark: createBenchmarkResult(suite.name)
46
- };
47
- updateTask$1("suite-prepare", suite);
43
+ }, updateTask$1("suite-prepare", suite);
48
44
  const addBenchTaskListener = (task, benchmark) => {
49
45
  task.addEventListener("complete", (e) => {
50
- const task = e.task;
51
- const taskRes = task.result;
52
- const result = benchmark.result.benchmark;
53
- benchmark.result.state = "pass";
54
- Object.assign(result, taskRes);
46
+ const task = e.task, taskRes = task.result, result = benchmark.result.benchmark;
47
+ benchmark.result.state = "pass", Object.assign(result, taskRes);
55
48
  // compute extra stats and free raw samples as early as possible
56
49
  const samples = result.samples;
57
- result.sampleCount = samples.length;
58
- result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2;
59
- if (!runner.config.benchmark?.includeSamples) result.samples.length = 0;
50
+ if (result.sampleCount = samples.length, result.median = samples.length % 2 ? samples[Math.floor(samples.length / 2)] : (samples[samples.length / 2] + samples[samples.length / 2 - 1]) / 2, !runner.config.benchmark?.includeSamples) result.samples.length = 0;
60
51
  updateTask$1("test-finished", benchmark);
61
- }, { once: true });
62
- task.addEventListener("error", (e) => {
52
+ }, { once: true }), task.addEventListener("error", (e) => {
63
53
  const task = e.task;
64
54
  defer.reject(benchmark ? task.result.error : e);
65
55
  }, { once: true });
66
56
  };
67
57
  benchmarkGroup.forEach((benchmark) => {
68
- const options = getBenchOptions(benchmark);
69
- const benchmarkInstance = new Bench(options);
70
- const benchmarkFn = getBenchFn(benchmark);
58
+ const options = getBenchOptions(benchmark), benchmarkInstance = new Bench(options), benchmarkFn = getBenchFn(benchmark);
71
59
  benchmark.result = {
72
60
  state: "run",
73
61
  startTime: start,
74
62
  benchmark: createBenchmarkResult(benchmark.name)
75
63
  };
76
64
  const task = new Task(benchmarkInstance, benchmark.name, benchmarkFn);
77
- benchmarkTasks.set(benchmark, task);
78
- addBenchTaskListener(task, benchmark);
65
+ benchmarkTasks.set(benchmark, task), addBenchTaskListener(task, benchmark);
79
66
  });
80
- const { setTimeout } = getSafeTimers();
81
- const tasks = [];
67
+ const { setTimeout } = getSafeTimers(), tasks = [];
82
68
  for (const benchmark of benchmarkGroup) {
83
69
  const task = benchmarkTasks.get(benchmark);
84
- updateTask$1("test-prepare", benchmark);
85
- await task.warmup();
86
- tasks.push([await new Promise((resolve) => setTimeout(async () => {
70
+ updateTask$1("test-prepare", benchmark), await task.warmup(), tasks.push([await new Promise((resolve) => setTimeout(async () => {
87
71
  resolve(await task.run());
88
72
  })), benchmark]);
89
73
  }
90
- suite.result.duration = performance.now() - start;
91
- suite.result.state = "pass";
92
- updateTask$1("suite-finished", suite);
93
- defer.resolve(null);
94
- await defer;
74
+ suite.result.duration = performance.now() - start, suite.result.state = "pass", updateTask$1("suite-finished", suite), defer.resolve(null), await defer;
95
75
  }
96
76
  function updateTask$1(event, task) {
97
77
  updateTask(event, task, runner);
@@ -147,8 +127,7 @@ class VitestTestRunner {
147
127
  this.workerState.onCleanup(listener);
148
128
  }
149
129
  onAfterRunFiles() {
150
- this.snapshotClient.clear();
151
- this.workerState.current = void 0;
130
+ this.snapshotClient.clear(), this.workerState.current = void 0;
152
131
  }
153
132
  getWorkerContext() {
154
133
  return workerContext;
@@ -165,9 +144,7 @@ class VitestTestRunner {
165
144
  if (this.workerState.config.snapshotOptions.updateSnapshot === "none" && result.unchecked) {
166
145
  let message = `Obsolete snapshots found when no snapshot update is expected.\n`;
167
146
  for (const key of result.uncheckedKeys) message += `· ${key}\n`;
168
- suite.result.errors ??= [];
169
- suite.result.errors.push(processError(new Error(message)));
170
- suite.result.state = "fail";
147
+ suite.result.errors ??= [], suite.result.errors.push(processError(new Error(message))), suite.result.state = "fail";
171
148
  }
172
149
  await rpc().snapshotSaved(result);
173
150
  }
@@ -187,8 +164,7 @@ class VitestTestRunner {
187
164
  }
188
165
  async onBeforeRunTask(test) {
189
166
  if (this.cancelRun) test.mode = "skip";
190
- if (test.mode !== "run" && test.mode !== "queued") return;
191
- this.workerState.current = test;
167
+ test.mode !== "run" && test.mode !== "queued" || (this.workerState.current = test);
192
168
  }
193
169
  async onBeforeRunSuite(suite) {
194
170
  if (this.cancelRun) suite.mode = "skip";
@@ -197,9 +173,7 @@ class VitestTestRunner {
197
173
  this.workerState.current = suite;
198
174
  }
199
175
  onBeforeTryTask(test) {
200
- clearModuleMocks(this.config);
201
- this.snapshotClient.clearTest(test.file.filepath, test.id);
202
- setState({
176
+ clearModuleMocks(this.config), this.snapshotClient.clearTest(test.file.filepath, test.id), setState({
203
177
  assertionCalls: 0,
204
178
  isExpectingAssertions: false,
205
179
  isExpectingAssertionsError: null,
@@ -219,14 +193,12 @@ class VitestTestRunner {
219
193
  // create error during the test initialization so we have a nice stack trace
220
194
  if (this.config.expect.requireAssertions) this.assertionsErrors.set(context.task, /* @__PURE__ */ new Error("expected any number of assertion, but got none"));
221
195
  let _expect;
222
- Object.defineProperty(context, "expect", { get() {
196
+ return Object.defineProperty(context, "expect", { get() {
223
197
  if (!_expect) _expect = createExpect(context.task);
224
198
  return _expect;
225
- } });
226
- Object.defineProperty(context, "_local", { get() {
199
+ } }), Object.defineProperty(context, "_local", { get() {
227
200
  return _expect != null;
228
- } });
229
- return context;
201
+ } }), context;
230
202
  }
231
203
  getImportDurations() {
232
204
  const entries = [...this.workerState.moduleExecutionInfo?.entries() ?? []];
package/dist/snapshot.js CHANGED
@@ -1,4 +1,4 @@
1
- export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.4JV5OXkt.js';
1
+ export { VitestNodeSnapshotEnvironment as VitestSnapshotEnvironment } from './chunks/node.BOqcT2jW.js';
2
2
  import '@vitest/snapshot/environment';
3
- import './chunks/utils.B9FY3b73.js';
3
+ import './chunks/utils.C7__0Iv5.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.CtuRzf-i.js';
1
+ export { g as getBenchFn, a as getBenchOptions } from './chunks/benchmark.UW6Ezvxy.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.B9FY3b73.js';
5
+ import './chunks/utils.C7__0Iv5.js';
package/dist/worker.js CHANGED
@@ -6,11 +6,11 @@ import { readFileSync } from 'node:fs';
6
6
  import { isBuiltin } from 'node:module';
7
7
  import { resolve } from 'pathe';
8
8
  import { V as VitestTransport } from './chunks/moduleTransport.I-bgQy0S.js';
9
- import { e as environments } from './chunks/index.BRtIe7r8.js';
10
- import { s as setupInspect } from './chunks/inspector.C914Efll.js';
11
- import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.DGoW_Vl-.js';
12
- import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.B9FY3b73.js';
13
- import { d as disposeInternalListeners } from './chunks/utils.CcGm2cd1.js';
9
+ import { e as environments } from './chunks/index.DfviD7lX.js';
10
+ import { s as setupInspect } from './chunks/inspector.CvQD-Nie.js';
11
+ import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.RpPylpp0.js';
12
+ import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.C7__0Iv5.js';
13
+ import { d as disposeInternalListeners } from './chunks/utils.C2YI6McM.js';
14
14
  import 'node:console';
15
15
  import '@vitest/utils';
16
16
  import './chunks/index.Bgo3tNWt.js';
@@ -18,8 +18,7 @@ import './chunks/index.Bgo3tNWt.js';
18
18
  function isBuiltinEnvironment(env) {
19
19
  return env in environments;
20
20
  }
21
- const isWindows = process.platform === "win32";
22
- const _loaders = /* @__PURE__ */ new Map();
21
+ const isWindows = process.platform === "win32", _loaders = /* @__PURE__ */ new Map();
23
22
  async function createEnvironmentLoader(root, rpc) {
24
23
  const cachedLoader = _loaders.get(root);
25
24
  if (!cachedLoader || cachedLoader.isClosed()) {
@@ -48,26 +47,20 @@ async function createEnvironmentLoader(root, rpc) {
48
47
  }
49
48
  })
50
49
  });
51
- _loaders.set(root, moduleRunner);
52
- await moduleRunner.import("/@vite/env");
50
+ _loaders.set(root, moduleRunner), await moduleRunner.import("/@vite/env");
53
51
  }
54
52
  return _loaders.get(root);
55
53
  }
56
54
  async function loadEnvironment(ctx, rpc) {
57
55
  const name = ctx.environment.name;
58
56
  if (isBuiltinEnvironment(name)) return { environment: environments[name] };
59
- const root = ctx.config.root;
60
- const loader = await createEnvironmentLoader(root, rpc);
61
- const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolve(`vitest-environment-${name}`, void 0, "__vitest__"))?.id ?? resolve(root, name);
62
- const pkg = await loader.import(packageId);
57
+ const root = ctx.config.root, loader = await createEnvironmentLoader(root, rpc), packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolve(`vitest-environment-${name}`, void 0, "__vitest__"))?.id ?? resolve(root, name), pkg = await loader.import(packageId);
63
58
  if (!pkg || !pkg.default || typeof pkg.default !== "object") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
64
59
  const environment = pkg.default;
65
60
  if (environment.transformMode != null && environment.transformMode !== "web" && environment.transformMode !== "ssr") throw new TypeError(`Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web", received "${environment.transformMode}".`);
66
- if (environment.transformMode) {
67
- console.warn(`The Vitest environment ${environment.name} defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.`);
68
- // keep for backwards compat
69
- environment.viteEnvironment ??= environment.transformMode === "ssr" ? "ssr" : "client";
70
- }
61
+ if (environment.transformMode)
62
+ // keep for backwards compat
63
+ console.warn(`The Vitest environment ${environment.name} defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.`), environment.viteEnvironment ??= environment.transformMode === "ssr" ? "ssr" : "client";
71
64
  return {
72
65
  environment,
73
66
  loader
@@ -96,16 +89,13 @@ const resolvingModules = /* @__PURE__ */ new Set();
96
89
  // this is what every pool executes when running tests
97
90
  async function execute(method, ctx) {
98
91
  disposeInternalListeners();
99
- const prepareStart = performance.now();
100
- const cleanups = [setupInspect(ctx)];
101
- process.env.VITEST_WORKER_ID = String(ctx.workerId);
102
- process.env.VITEST_POOL_ID = String(workerId);
92
+ const prepareStart = performance.now(), cleanups = [setupInspect(ctx)];
93
+ process.env.VITEST_WORKER_ID = String(ctx.workerId), process.env.VITEST_POOL_ID = String(workerId);
103
94
  let environmentLoader;
104
95
  try {
105
96
  // worker is a filepath or URL to a file that exposes a default export with "getRpcOptions" and "runTests" methods
106
97
  if (ctx.worker[0] === ".") throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
107
- const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
108
- const testRunnerModule = await import(file);
98
+ const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString(), testRunnerModule = await import(file);
109
99
  if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
110
100
  const worker = testRunnerModule.default;
111
101
  if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
@@ -117,8 +107,7 @@ async function execute(method, ctx) {
117
107
  reject(/* @__PURE__ */ new Error(`[vitest-worker]: Closing rpc while "${method}" was pending`));
118
108
  }));
119
109
  });
120
- const beforeEnvironmentTime = performance.now();
121
- const { environment, loader } = await loadEnvironment(ctx, rpc);
110
+ const beforeEnvironmentTime = performance.now(), { environment, loader } = await loadEnvironment(ctx, rpc);
122
111
  environmentLoader = loader;
123
112
  const state = {
124
113
  ctx,
@@ -139,14 +128,11 @@ async function execute(method, ctx) {
139
128
  return createStackString(parseStacktrace(stack));
140
129
  },
141
130
  metaEnv: createImportMetaEnvProxy()
142
- };
143
- const methodName = method === "collect" ? "collectTests" : "runTests";
131
+ }, methodName = method === "collect" ? "collectTests" : "runTests";
144
132
  if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
145
133
  await worker[methodName](state);
146
134
  } finally {
147
- await Promise.all(cleanups.map((fn) => fn()));
148
- await rpcDone().catch(() => {});
149
- environmentLoader?.close();
135
+ await Promise.all(cleanups.map((fn) => fn())), await rpcDone().catch(() => {}), environmentLoader?.close();
150
136
  }
151
137
  }
152
138
  function run(ctx) {
@@ -167,9 +153,7 @@ function createImportMetaEnvProxy() {
167
153
  ];
168
154
  return new Proxy(process.env, {
169
155
  get(_, key) {
170
- if (typeof key !== "string") return void 0;
171
- if (booleanKeys.includes(key)) return !!process.env[key];
172
- return process.env[key];
156
+ return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
173
157
  },
174
158
  set(_, key, value) {
175
159
  if (typeof key !== "string") return true;
@@ -1,8 +1,8 @@
1
1
  import v8 from 'node:v8';
2
- import { r as runBaseTests } from '../chunks/base.DMfOuRWD.js';
3
- import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CcGm2cd1.js';
2
+ import { r as runBaseTests } from '../chunks/base.BXI97p6t.js';
3
+ import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.C2YI6McM.js';
4
4
  import 'vite/module-runner';
5
- import '../chunks/startModuleRunner.C8FtT_BY.js';
5
+ import '../chunks/startModuleRunner.C8TW8zTN.js';
6
6
  import 'node:fs';
7
7
  import 'node:module';
8
8
  import '@vitest/utils';
@@ -15,7 +15,7 @@ import '../module-evaluator.js';
15
15
  import 'node:vm';
16
16
  import '@vitest/mocker';
17
17
  import '../chunks/moduleTransport.I-bgQy0S.js';
18
- import '../chunks/utils.B9FY3b73.js';
18
+ import '../chunks/utils.C7__0Iv5.js';
19
19
 
20
20
  class ForksBaseWorker {
21
21
  getRpcOptions() {
@@ -5,77 +5,59 @@ import timersPromises from 'node:timers/promises';
5
5
  import util from 'node:util';
6
6
  import { startTests, collectTests } from '@vitest/runner';
7
7
  import { KNOWN_ASSET_TYPES } from '@vitest/utils';
8
- import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.oWRWx-nj.js';
9
- import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.lgPs-bYv.js';
10
- import { V as VitestIndex } from '../chunks/index.QZr3S3vQ.js';
11
- import { c as closeInspector } from '../chunks/inspector.C914Efll.js';
12
- import { g as getWorkerState } from '../chunks/utils.B9FY3b73.js';
8
+ import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.CsFXYRkW.js';
9
+ import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.hLGRxhC8.js';
10
+ import { V as VitestIndex } from '../chunks/index.AR8aAkCC.js';
11
+ import { c as closeInspector } from '../chunks/inspector.CvQD-Nie.js';
12
+ import { g as getWorkerState } from '../chunks/utils.C7__0Iv5.js';
13
13
  import 'chai';
14
14
  import 'node:path';
15
15
  import '../path.js';
16
16
  import 'node:url';
17
- import '../chunks/rpc.DGoW_Vl-.js';
17
+ import '../chunks/rpc.RpPylpp0.js';
18
18
  import '../chunks/index.Bgo3tNWt.js';
19
19
  import '../chunks/coverage.D_JHT54q.js';
20
20
  import '@vitest/snapshot';
21
- import '../chunks/vi.DGAfBY4R.js';
21
+ import '../chunks/vi.BfdOiD4j.js';
22
22
  import '@vitest/expect';
23
23
  import '@vitest/runner/utils';
24
24
  import '../chunks/_commonjsHelpers.BFTU3MAI.js';
25
25
  import '@vitest/utils/error';
26
26
  import '@vitest/spy';
27
27
  import '@vitest/utils/source-map';
28
- import '../chunks/date.Bq6ZW5rf.js';
29
- import '../chunks/benchmark.CtuRzf-i.js';
28
+ import '../chunks/date.-jtEtIeV.js';
29
+ import '../chunks/benchmark.UW6Ezvxy.js';
30
30
  import 'expect-type';
31
31
  import 'vite/module-runner';
32
32
 
33
33
  async function run(method, files, config, moduleRunner) {
34
34
  const workerState = getWorkerState();
35
- await setupCommonEnv(config);
36
- Object.defineProperty(globalThis, "__vitest_index__", {
35
+ await setupCommonEnv(config), Object.defineProperty(globalThis, "__vitest_index__", {
37
36
  value: VitestIndex,
38
37
  enumerable: false
39
38
  });
40
39
  const viteEnvironment = workerState.environment.viteEnvironment || workerState.environment.name;
41
40
  if (viteEnvironment === "client") {
42
41
  const _require = createRequire(import.meta.url);
43
- // always mock "required" `css` files, because we cannot process them
44
- _require.extensions[".css"] = resolveCss;
45
- _require.extensions[".scss"] = resolveCss;
46
- _require.extensions[".sass"] = resolveCss;
47
- _require.extensions[".less"] = resolveCss;
48
- // since we are using Vite, we can assume how these will be resolved
49
- KNOWN_ASSET_TYPES.forEach((type) => {
42
+ _require.extensions[".css"] = resolveCss, _require.extensions[".scss"] = resolveCss, _require.extensions[".sass"] = resolveCss, _require.extensions[".less"] = resolveCss, KNOWN_ASSET_TYPES.forEach((type) => {
50
43
  _require.extensions[`.${type}`] = resolveAsset;
51
- });
52
- process.env.SSR = "";
44
+ }), process.env.SSR = "";
53
45
  } else process.env.SSR = "1";
54
- // @ts-expect-error not typed global for patched timers
55
- globalThis.__vitest_required__ = {
46
+ if (globalThis.__vitest_required__ = {
56
47
  util,
57
48
  timers,
58
49
  timersPromises
59
- };
60
- await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: false });
61
- if (config.chaiConfig) setupChaiConfig(config.chaiConfig);
50
+ }, await startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: false }), config.chaiConfig) setupChaiConfig(config.chaiConfig);
62
51
  const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config, moduleRunner), resolveSnapshotEnvironment(config, moduleRunner)]);
63
- config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
64
- runner.getWorkerContext = void 0;
65
- workerState.onCancel.then((reason) => {
66
- closeInspector(config);
67
- runner.cancel?.(reason);
68
- });
69
- workerState.durations.prepare = performance.now() - workerState.durations.prepare;
52
+ config.snapshotOptions.snapshotEnvironment = snapshotEnvironment, runner.getWorkerContext = void 0, workerState.onCancel.then((reason) => {
53
+ closeInspector(config), runner.cancel?.(reason);
54
+ }), workerState.durations.prepare = performance.now() - workerState.durations.prepare;
70
55
  const { vi } = VitestIndex;
71
56
  for (const file of files) {
72
- workerState.filepath = file.filepath;
73
- if (method === "run") await startTests([file], runner);
57
+ if (workerState.filepath = file.filepath, method === "run") await startTests([file], runner);
74
58
  else await collectTests([file], runner);
75
- // reset after tests, because user might call `vi.setConfig` in setupFile
76
- vi.resetConfig();
77
59
  // mocks should not affect different files
78
- vi.restoreAllMocks();
60
+ vi.resetConfig(), vi.restoreAllMocks();
79
61
  }
80
62
  await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: false });
81
63
  }
@@ -1,7 +1,7 @@
1
- import { r as runBaseTests } from '../chunks/base.DMfOuRWD.js';
2
- import { a as createThreadsRpcOptions } from '../chunks/utils.CcGm2cd1.js';
1
+ import { r as runBaseTests } from '../chunks/base.BXI97p6t.js';
2
+ import { a as createThreadsRpcOptions } from '../chunks/utils.C2YI6McM.js';
3
3
  import 'vite/module-runner';
4
- import '../chunks/startModuleRunner.C8FtT_BY.js';
4
+ import '../chunks/startModuleRunner.C8TW8zTN.js';
5
5
  import 'node:fs';
6
6
  import 'node:module';
7
7
  import '@vitest/utils';
@@ -14,7 +14,7 @@ import '../module-evaluator.js';
14
14
  import 'node:vm';
15
15
  import '@vitest/mocker';
16
16
  import '../chunks/moduleTransport.I-bgQy0S.js';
17
- import '../chunks/utils.B9FY3b73.js';
17
+ import '../chunks/utils.C7__0Iv5.js';
18
18
 
19
19
  class ThreadsBaseWorker {
20
20
  getRpcOptions(ctx) {
@@ -1,24 +1,24 @@
1
1
  import v8 from 'node:v8';
2
- import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.CcGm2cd1.js';
3
- import { r as runVmTests } from '../chunks/vm.BKfKvaKl.js';
2
+ import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.C2YI6McM.js';
3
+ import { r as runVmTests } from '../chunks/vm.BHBje7cC.js';
4
4
  import '@vitest/utils';
5
5
  import 'node:url';
6
6
  import 'node:vm';
7
7
  import 'pathe';
8
8
  import '../path.js';
9
9
  import 'node:path';
10
- import '../chunks/console.Duv2dVIC.js';
10
+ import '../chunks/console.B0quX7yH.js';
11
11
  import 'node:console';
12
12
  import 'node:stream';
13
13
  import 'tinyrainbow';
14
- import '../chunks/date.Bq6ZW5rf.js';
15
- import '../chunks/utils.B9FY3b73.js';
14
+ import '../chunks/date.-jtEtIeV.js';
15
+ import '../chunks/utils.C7__0Iv5.js';
16
16
  import 'node:fs';
17
17
  import 'node:module';
18
- import '../chunks/resolver.D5bG4zy5.js';
18
+ import '../chunks/resolver.Bx6lE0iq.js';
19
19
  import '../module-evaluator.js';
20
20
  import 'vite/module-runner';
21
- import '../chunks/startModuleRunner.C8FtT_BY.js';
21
+ import '../chunks/startModuleRunner.C8TW8zTN.js';
22
22
  import '@vitest/utils/error';
23
23
  import '@vitest/mocker';
24
24
  import '../chunks/moduleTransport.I-bgQy0S.js';
@@ -1,23 +1,23 @@
1
- import { a as createThreadsRpcOptions } from '../chunks/utils.CcGm2cd1.js';
2
- import { r as runVmTests } from '../chunks/vm.BKfKvaKl.js';
1
+ import { a as createThreadsRpcOptions } from '../chunks/utils.C2YI6McM.js';
2
+ import { r as runVmTests } from '../chunks/vm.BHBje7cC.js';
3
3
  import '@vitest/utils';
4
4
  import 'node:url';
5
5
  import 'node:vm';
6
6
  import 'pathe';
7
7
  import '../path.js';
8
8
  import 'node:path';
9
- import '../chunks/console.Duv2dVIC.js';
9
+ import '../chunks/console.B0quX7yH.js';
10
10
  import 'node:console';
11
11
  import 'node:stream';
12
12
  import 'tinyrainbow';
13
- import '../chunks/date.Bq6ZW5rf.js';
14
- import '../chunks/utils.B9FY3b73.js';
13
+ import '../chunks/date.-jtEtIeV.js';
14
+ import '../chunks/utils.C7__0Iv5.js';
15
15
  import 'node:fs';
16
16
  import 'node:module';
17
- import '../chunks/resolver.D5bG4zy5.js';
17
+ import '../chunks/resolver.Bx6lE0iq.js';
18
18
  import '../module-evaluator.js';
19
19
  import 'vite/module-runner';
20
- import '../chunks/startModuleRunner.C8FtT_BY.js';
20
+ import '../chunks/startModuleRunner.C8TW8zTN.js';
21
21
  import '@vitest/utils/error';
22
22
  import '@vitest/mocker';
23
23
  import '../chunks/moduleTransport.I-bgQy0S.js';
package/dist/workers.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.D9QWnzAe.js';
1
+ import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.DYlqbejz.js';
2
2
  import { Awaitable } from '@vitest/utils';
3
3
  import * as v8 from 'v8';
4
- import { a as SerializedConfig } from './chunks/config.d.CKNVOKm0.js';
5
- import { W as WorkerContext } from './chunks/worker.d.Db-UVmXc.js';
4
+ import { a as SerializedConfig } from './chunks/config.d._GBBbReY.js';
5
+ import { W as WorkerContext } from './chunks/worker.d.BKu8cnnX.js';
6
6
  import '@vitest/runner';
7
7
  import 'vite/module-runner';
8
8
  import './chunks/environment.d.2fYMoz3o.js';
package/dist/workers.js CHANGED
@@ -1,8 +1,8 @@
1
- export { p as provideWorkerState } from './chunks/utils.B9FY3b73.js';
1
+ export { p as provideWorkerState } from './chunks/utils.C7__0Iv5.js';
2
2
  export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
3
- export { r as runBaseTests } from './chunks/base.DMfOuRWD.js';
4
- export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.CcGm2cd1.js';
5
- export { r as runVmTests } from './chunks/vm.BKfKvaKl.js';
3
+ export { r as runBaseTests } from './chunks/base.BXI97p6t.js';
4
+ export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.C2YI6McM.js';
5
+ export { r as runVmTests } from './chunks/vm.BHBje7cC.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import '@vitest/utils/source-map';
@@ -12,20 +12,20 @@ import 'node:fs';
12
12
  import 'node:module';
13
13
  import 'pathe';
14
14
  import './chunks/moduleTransport.I-bgQy0S.js';
15
- import './chunks/index.BRtIe7r8.js';
15
+ import './chunks/index.DfviD7lX.js';
16
16
  import 'node:console';
17
- import './chunks/inspector.C914Efll.js';
18
- import './chunks/rpc.DGoW_Vl-.js';
17
+ import './chunks/inspector.CvQD-Nie.js';
18
+ import './chunks/rpc.RpPylpp0.js';
19
19
  import './chunks/index.Bgo3tNWt.js';
20
- import './chunks/startModuleRunner.C8FtT_BY.js';
20
+ import './chunks/startModuleRunner.C8TW8zTN.js';
21
21
  import './path.js';
22
22
  import 'node:path';
23
23
  import '@vitest/utils/error';
24
24
  import './module-evaluator.js';
25
25
  import 'node:vm';
26
26
  import '@vitest/mocker';
27
- import './chunks/console.Duv2dVIC.js';
27
+ import './chunks/console.B0quX7yH.js';
28
28
  import 'node:stream';
29
29
  import 'tinyrainbow';
30
- import './chunks/date.Bq6ZW5rf.js';
31
- import './chunks/resolver.D5bG4zy5.js';
30
+ import './chunks/date.-jtEtIeV.js';
31
+ import './chunks/resolver.Bx6lE0iq.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.5",
4
+ "version": "4.0.0-beta.7",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -125,8 +125,8 @@
125
125
  "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
126
126
  "happy-dom": "*",
127
127
  "jsdom": "*",
128
- "@vitest/browser": "4.0.0-beta.5",
129
- "@vitest/ui": "4.0.0-beta.5"
128
+ "@vitest/ui": "4.0.0-beta.7",
129
+ "@vitest/browser": "4.0.0-beta.7"
130
130
  },
131
131
  "peerDependenciesMeta": {
132
132
  "@edge-runtime/vm": {
@@ -168,13 +168,13 @@
168
168
  "tinyrainbow": "^2.0.0",
169
169
  "vite": "^6.0.0 || ^7.0.0-0",
170
170
  "why-is-node-running": "^2.3.0",
171
- "@vitest/expect": "4.0.0-beta.5",
172
- "@vitest/pretty-format": "^4.0.0-beta.5",
173
- "@vitest/runner": "4.0.0-beta.5",
174
- "@vitest/mocker": "4.0.0-beta.5",
175
- "@vitest/spy": "4.0.0-beta.5",
176
- "@vitest/snapshot": "4.0.0-beta.5",
177
- "@vitest/utils": "4.0.0-beta.5"
171
+ "@vitest/pretty-format": "^4.0.0-beta.7",
172
+ "@vitest/snapshot": "4.0.0-beta.7",
173
+ "@vitest/expect": "4.0.0-beta.7",
174
+ "@vitest/runner": "4.0.0-beta.7",
175
+ "@vitest/spy": "4.0.0-beta.7",
176
+ "@vitest/mocker": "4.0.0-beta.7",
177
+ "@vitest/utils": "4.0.0-beta.7"
178
178
  },
179
179
  "devDependencies": {
180
180
  "@ampproject/remapping": "^2.3.0",
@@ -187,7 +187,7 @@
187
187
  "@types/istanbul-reports": "^3.0.4",
188
188
  "@types/jsdom": "^21.1.7",
189
189
  "@types/node": "^22.16.5",
190
- "@types/picomatch": "^4.0.1",
190
+ "@types/picomatch": "^4.0.2",
191
191
  "@types/prompts": "^2.4.9",
192
192
  "@types/sinonjs__fake-timers": "^8.1.5",
193
193
  "acorn-walk": "^8.3.4",