vitest 4.0.17 → 4.0.18

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.
@@ -1,7 +1,7 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
3
  import { r as resolveTestRunner, a as resolveSnapshotEnvironment, s as setupChaiConfig } from './index.6Qv1eEA6.js';
4
- import { l as loadEnvironment } from './init.C9kljSTm.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner } from './init.B6MLFIaN.js';
5
5
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
6
6
  import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startModuleRunner.DEj0jb3e.js';
7
7
  import { performance as performance$1 } from 'node:perf_hooks';
@@ -158,6 +158,7 @@ async function runBaseTests(method, state, traces) {
158
158
  createImportMeta: createNodeImportMeta,
159
159
  traces
160
160
  });
161
+ emitModuleRunner(moduleRunner);
161
162
  await run(method, ctx.files, ctx.config, moduleRunner, _currentEnvironment, traces);
162
163
  }
163
164
 
@@ -619,7 +619,7 @@ class CAC extends EventEmitter {
619
619
 
620
620
  const cac = (name = "") => new CAC(name);
621
621
 
622
- var version = "4.0.17";
622
+ var version = "4.0.18";
623
623
 
624
624
  const apiConfig = (port) => ({
625
625
  port: {
@@ -1356,7 +1356,7 @@ function normalizeCliOptions(cliFilters, argv) {
1356
1356
  }
1357
1357
  async function start(mode, cliFilters, options) {
1358
1358
  try {
1359
- const { startVitest } = await import('./cli-api.Cx2DW4Bc.js').then(function (n) { return n.q; });
1359
+ const { startVitest } = await import('./cli-api.B7PN_QUv.js').then(function (n) { return n.q; });
1360
1360
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
1361
1361
  if (!ctx.shouldKeepServer()) await ctx.exit();
1362
1362
  } catch (e) {
@@ -1378,7 +1378,7 @@ async function init(project) {
1378
1378
  }
1379
1379
  async function collect(mode, cliFilters, options) {
1380
1380
  try {
1381
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Cx2DW4Bc.js').then(function (n) { return n.q; });
1381
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.B7PN_QUv.js').then(function (n) { return n.q; });
1382
1382
  const ctx = await prepareVitest(mode, {
1383
1383
  ...normalizeCliOptions(cliFilters, options),
1384
1384
  watch: false,
@@ -12,7 +12,7 @@ import * as nodeos from 'node:os';
12
12
  import nodeos__default, { tmpdir } from 'node:os';
13
13
  import { generateHash as generateHash$1, createTaskName, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, getTasks, isTestCase } from '@vitest/runner/utils';
14
14
  import { SnapshotManager } from '@vitest/snapshot/manager';
15
- import { v as version$1 } from './cac.jRCLJDDc.js';
15
+ import { v as version$1 } from './cac.DVeoLl0M.js';
16
16
  import { performance as performance$1 } from 'node:perf_hooks';
17
17
  import { c as createBirpc } from './index.Chj8NDwU.js';
18
18
  import { p as parse, d as stringify, e as createIndexLocationsMap, h as TraceMap, o as originalPositionFor, i as ancestor, j as printError, f as formatProjectName, w as withLabel, k as errorBanner, l as divider, m as Typechecker, n as generateCodeFrame, q as escapeRegExp, r as createDefinesScript, R as ReportersMap, u as groupBy, B as BlobReporter, v as readBlobs, x as convertTasksToEvents, H as HangingProcessReporter, y as wildcardPatternToRegExp, z as stdout } from './index.M8mOzt4Y.js';
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.C9kljSTm.js';
1
+ import { i as init } from './init.B6MLFIaN.js';
2
2
 
3
3
  if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
4
  // Store globals in case tests overwrite them
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.C9kljSTm.js';
2
+ import { i as init } from './init.B6MLFIaN.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {
@@ -65,8 +65,22 @@ async function loadEnvironment(name, root, rpc, traces) {
65
65
  };
66
66
  }
67
67
 
68
+ const cleanupListeners = /* @__PURE__ */ new Set();
69
+ const moduleRunnerListeners = /* @__PURE__ */ new Set();
70
+ function onCleanup(cb) {
71
+ cleanupListeners.add(cb);
72
+ }
73
+ async function cleanup() {
74
+ await Promise.all([...cleanupListeners].map((l) => l()));
75
+ }
76
+ function onModuleRunner(cb) {
77
+ moduleRunnerListeners.add(cb);
78
+ }
79
+ function emitModuleRunner(moduleRunner) {
80
+ moduleRunnerListeners.forEach((l) => l(moduleRunner));
81
+ }
82
+
68
83
  const resolvingModules = /* @__PURE__ */ new Set();
69
- const globalListeners = /* @__PURE__ */ new Set();
70
84
  async function execute(method, ctx, worker, traces) {
71
85
  const prepareStart = performance.now();
72
86
  const cleanups = [setupInspect(ctx)];
@@ -92,7 +106,7 @@ async function execute(method, ctx, worker, traces) {
92
106
  },
93
107
  rpc,
94
108
  onCancel,
95
- onCleanup: (listener) => globalListeners.add(listener),
109
+ onCleanup: onCleanup,
96
110
  providedContext: ctx.providedContext,
97
111
  onFilterStackTrace(stack) {
98
112
  return createStackString(parseStacktrace(stack));
@@ -114,7 +128,7 @@ function collect(ctx, worker, traces) {
114
128
  return execute("collect", ctx, worker, traces);
115
129
  }
116
130
  async function teardown() {
117
- await Promise.all([...globalListeners].map((l) => l()));
131
+ await cleanup();
118
132
  }
119
133
  const env = process.env;
120
134
  function createImportMetaEnvProxy() {
@@ -146,6 +160,7 @@ let traces;
146
160
  /** @experimental */
147
161
  function init(worker) {
148
162
  worker.on(onMessage);
163
+ if (worker.onModuleRunner) onModuleRunner(worker.onModuleRunner);
149
164
  let runPromise;
150
165
  let isRunning = false;
151
166
  let workerTeardown;
@@ -316,4 +331,4 @@ function getFilesWithLocations(files) {
316
331
  });
317
332
  }
318
333
 
319
- export { init as i, loadEnvironment as l };
334
+ export { emitModuleRunner as e, init as i, loadEnvironment as l };
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext, runInContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, resolve } from 'pathe';
4
- import { l as loadEnvironment } from './init.C9kljSTm.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner } from './init.B6MLFIaN.js';
5
5
  import { distDir } from '../path.js';
6
6
  import { createCustomConsole } from './console.Cf-YriPC.js';
7
7
  import fs from 'node:fs';
@@ -716,6 +716,7 @@ async function runVmTests(method, state, traces) {
716
716
  createImportMeta: createNodeImportMeta,
717
717
  traces
718
718
  });
719
+ emitModuleRunner(moduleRunner);
719
720
  Object.defineProperty(context, VITEST_VM_CONTEXT_SYMBOL, {
720
721
  value: {
721
722
  context,
@@ -733,12 +734,8 @@ async function runVmTests(method, state, traces) {
733
734
  }
734
735
  await moduleRunner.mocker.initializeSpyModule();
735
736
  const { run } = await moduleRunner.import(entryFile);
736
- const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
737
- filepath: f,
738
- testLocations: void 0
739
- } : f);
740
737
  try {
741
- await run(method, fileSpecs, ctx.config, moduleRunner, traces);
738
+ await run(method, ctx.files, ctx.config, moduleRunner, traces);
742
739
  } finally {
743
740
  await traces.$("vitest.runtime.environment.teardown", () => vm.teardown?.());
744
741
  }
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createCLI } from './chunks/cac.jRCLJDDc.js';
1
+ import { c as createCLI } from './chunks/cac.DVeoLl0M.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
@@ -1,7 +1,6 @@
1
1
  import { isBuiltin, createRequire } from 'node:module';
2
2
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
3
  import vm from 'node:vm';
4
- import { isAbsolute } from 'pathe';
5
4
  import { ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey } from 'vite/module-runner';
6
5
  import { T as Traces } from './chunks/traces.CCmnQaNT.js';
7
6
 
@@ -163,7 +162,7 @@ class VitestModuleEvaluator {
163
162
  const filename = meta.filename;
164
163
  const dirname = meta.dirname;
165
164
  span.setAttributes({ "code.file.path": filename });
166
- const require = this.createRequire(filename);
165
+ const require = this.createRequire(meta.url);
167
166
  const argumentsList = [
168
167
  ssrModuleExportsKey,
169
168
  ssrImportMetaKey,
@@ -220,9 +219,6 @@ class VitestModuleEvaluator {
220
219
  }
221
220
  }
222
221
  createRequire(filename) {
223
- // \x00 is a rollup convention for virtual files,
224
- // it is not allowed in actual file names
225
- if (filename[0] === "\0" || !isAbsolute(filename)) return () => ({});
226
222
  return this.vm ? this.vm.externalModulesExecutor.createRequire(filename) : createRequire(filename);
227
223
  }
228
224
  shouldInterop(path, mod) {
@@ -4,12 +4,12 @@ export { g as getWorkerState } from './chunks/utils.DvEY5TfP.js';
4
4
  import 'node:module';
5
5
  import 'node:url';
6
6
  import 'node:vm';
7
- import 'pathe';
8
7
  import 'vite/module-runner';
9
8
  import './chunks/traces.CCmnQaNT.js';
10
9
  import 'node:fs';
11
10
  import '@vitest/utils/helpers';
12
11
  import './chunks/modules.BJuCwlRJ.js';
12
+ import 'pathe';
13
13
  import './path.js';
14
14
  import 'node:path';
15
15
  import '@vitest/utils/serialize';
package/dist/node.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as vite from 'vite';
2
2
  import { resolveConfig as resolveConfig$1, mergeConfig } from 'vite';
3
3
  export { esbuildVersion, isCSSRequest, isFileLoadingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
4
- import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.Cx2DW4Bc.js';
5
- export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, p as createDebugger, d as createMethodsRPC, o as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, n as isFileServingAllowed, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.Cx2DW4Bc.js';
6
- export { p as parseCLI } from './chunks/cac.jRCLJDDc.js';
4
+ import { V as Vitest, a as VitestPlugin } from './chunks/cli-api.B7PN_QUv.js';
5
+ export { f as ForksPoolWorker, G as GitNotFoundError, F as TestsNotFoundError, T as ThreadsPoolWorker, h as TypecheckPoolWorker, b as VitestPackageInstaller, j as VmForksPoolWorker, k as VmThreadsPoolWorker, p as createDebugger, d as createMethodsRPC, o as createViteLogger, c as createVitest, e as escapeTestName, l as experimental_getRunnerTask, g as getFilePoolName, n as isFileServingAllowed, i as isValidApiRequest, m as registerConsoleShortcuts, r as resolveFsAllow, s as startVitest } from './chunks/cli-api.B7PN_QUv.js';
6
+ export { p as parseCLI } from './chunks/cac.DVeoLl0M.js';
7
7
  import { r as resolveConfig$2 } from './chunks/coverage.AVPTjMgw.js';
8
8
  export { b as BaseSequencer, a as resolveApiServerConfig } from './chunks/coverage.AVPTjMgw.js';
9
9
  import { slash, deepClone } from '@vitest/utils/helpers';
package/dist/worker.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { W as WorkerGlobalState, a as WorkerSetupContext, B as BirpcOptions } from './chunks/worker.d.Dyxm8DEL.js';
2
2
  import { T as Traces } from './chunks/traces.d.402V_yFI.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
+ import { ModuleRunner } from 'vite/module-runner';
4
5
  import { R as RuntimeRPC } from './chunks/rpc.d.RH3apGEf.js';
5
6
  import '@vitest/runner';
6
- import 'vite/module-runner';
7
7
  import './chunks/config.d.Cy95HiCx.js';
8
8
  import '@vitest/pretty-format';
9
9
  import '@vitest/snapshot';
@@ -19,6 +19,7 @@ type WorkerRpcOptions = Pick<BirpcOptions<RuntimeRPC>, "on" | "off" | "post" | "
19
19
  interface VitestWorker extends WorkerRpcOptions {
20
20
  runTests: (state: WorkerGlobalState, traces: Traces) => Awaitable<unknown>;
21
21
  collectTests: (state: WorkerGlobalState, traces: Traces) => Awaitable<unknown>;
22
+ onModuleRunner?: (moduleRunner: ModuleRunner) => Awaitable<unknown>;
22
23
  setup?: (context: WorkerSetupContext) => Promise<() => Promise<unknown>>;
23
24
  }
24
25
 
package/dist/worker.js CHANGED
@@ -1,5 +1,5 @@
1
- export { r as runBaseTests, s as setupEnvironment } from './chunks/base.XJJQZiKB.js';
2
- export { i as init } from './chunks/init.C9kljSTm.js';
1
+ export { r as runBaseTests, s as setupEnvironment } from './chunks/base.CJ0Y4ePK.js';
2
+ export { i as init } from './chunks/init.B6MLFIaN.js';
3
3
  import 'node:vm';
4
4
  import '@vitest/spy';
5
5
  import './chunks/index.6Qv1eEA6.js';
@@ -1,5 +1,5 @@
1
- import { r as runBaseTests, s as setupEnvironment } from '../chunks/base.XJJQZiKB.js';
2
- import { w as workerInit } from '../chunks/init-forks.BC6ZwHQN.js';
1
+ import { r as runBaseTests, s as setupEnvironment } from '../chunks/base.CJ0Y4ePK.js';
2
+ import { w as workerInit } from '../chunks/init-forks._y3TW739.js';
3
3
  import 'node:vm';
4
4
  import '@vitest/spy';
5
5
  import '../chunks/index.6Qv1eEA6.js';
@@ -23,7 +23,7 @@ import '@vitest/utils/offset';
23
23
  import '@vitest/utils/source-map';
24
24
  import '../chunks/_commonjsHelpers.D26ty3Ew.js';
25
25
  import '../chunks/date.Bq6ZW5rf.js';
26
- import '../chunks/init.C9kljSTm.js';
26
+ import '../chunks/init.B6MLFIaN.js';
27
27
  import 'node:fs';
28
28
  import 'node:module';
29
29
  import 'node:url';
@@ -1,5 +1,5 @@
1
- import { s as setupEnvironment, r as runBaseTests } from '../chunks/base.XJJQZiKB.js';
2
- import { w as workerInit } from '../chunks/init-threads.CxSxLC0N.js';
1
+ import { s as setupEnvironment, r as runBaseTests } from '../chunks/base.CJ0Y4ePK.js';
2
+ import { w as workerInit } from '../chunks/init-threads.DBO2kn-p.js';
3
3
  import 'node:vm';
4
4
  import '@vitest/spy';
5
5
  import '../chunks/index.6Qv1eEA6.js';
@@ -23,7 +23,7 @@ import '@vitest/utils/offset';
23
23
  import '@vitest/utils/source-map';
24
24
  import '../chunks/_commonjsHelpers.D26ty3Ew.js';
25
25
  import '../chunks/date.Bq6ZW5rf.js';
26
- import '../chunks/init.C9kljSTm.js';
26
+ import '../chunks/init.B6MLFIaN.js';
27
27
  import 'node:fs';
28
28
  import 'node:module';
29
29
  import 'node:url';
@@ -1,6 +1,6 @@
1
- import { w as workerInit } from '../chunks/init-forks.BC6ZwHQN.js';
2
- import { r as runVmTests } from '../chunks/vm.CMjifoPa.js';
3
- import '../chunks/init.C9kljSTm.js';
1
+ import { w as workerInit } from '../chunks/init-forks._y3TW739.js';
2
+ import { r as runVmTests } from '../chunks/vm.D3epNOPZ.js';
3
+ import '../chunks/init.B6MLFIaN.js';
4
4
  import 'node:fs';
5
5
  import 'node:module';
6
6
  import 'node:url';
@@ -1,7 +1,7 @@
1
- import { w as workerInit } from '../chunks/init-threads.CxSxLC0N.js';
2
- import { r as runVmTests } from '../chunks/vm.CMjifoPa.js';
1
+ import { w as workerInit } from '../chunks/init-threads.DBO2kn-p.js';
2
+ import { r as runVmTests } from '../chunks/vm.D3epNOPZ.js';
3
3
  import 'node:worker_threads';
4
- import '../chunks/init.C9kljSTm.js';
4
+ import '../chunks/init.B6MLFIaN.js';
5
5
  import 'node:fs';
6
6
  import 'node:module';
7
7
  import 'node:url';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "4.0.17",
4
+ "version": "4.0.18",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -134,10 +134,10 @@
134
134
  "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",
135
135
  "happy-dom": "*",
136
136
  "jsdom": "*",
137
- "@vitest/browser-playwright": "4.0.17",
138
- "@vitest/browser-preview": "4.0.17",
139
- "@vitest/browser-webdriverio": "4.0.17",
140
- "@vitest/ui": "4.0.17"
137
+ "@vitest/browser-playwright": "4.0.18",
138
+ "@vitest/browser-preview": "4.0.18",
139
+ "@vitest/browser-webdriverio": "4.0.18",
140
+ "@vitest/ui": "4.0.18"
141
141
  },
142
142
  "peerDependenciesMeta": {
143
143
  "@edge-runtime/vm": {
@@ -182,13 +182,13 @@
182
182
  "tinyrainbow": "^3.0.3",
183
183
  "vite": "^6.0.0 || ^7.0.0",
184
184
  "why-is-node-running": "^2.3.0",
185
- "@vitest/expect": "4.0.17",
186
- "@vitest/pretty-format": "4.0.17",
187
- "@vitest/mocker": "4.0.17",
188
- "@vitest/runner": "4.0.17",
189
- "@vitest/spy": "4.0.17",
190
- "@vitest/snapshot": "4.0.17",
191
- "@vitest/utils": "4.0.17"
185
+ "@vitest/mocker": "4.0.18",
186
+ "@vitest/expect": "4.0.18",
187
+ "@vitest/runner": "4.0.18",
188
+ "@vitest/pretty-format": "4.0.18",
189
+ "@vitest/snapshot": "4.0.18",
190
+ "@vitest/spy": "4.0.18",
191
+ "@vitest/utils": "4.0.18"
192
192
  },
193
193
  "devDependencies": {
194
194
  "@antfu/install-pkg": "^1.1.0",