vitest 3.1.0-beta.1 → 3.1.0-beta.2

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 (85) hide show
  1. package/dist/browser.js +4 -4
  2. package/dist/chunks/base.CylSMlTD.js +41 -0
  3. package/dist/chunks/benchmark.BKUatJGy.js +39 -0
  4. package/dist/chunks/cac.JtTXbKz0.js +1525 -0
  5. package/dist/chunks/{cli-api.BwkkJsRe.js → cli-api.BTtPTYMs.js} +4638 -5072
  6. package/dist/chunks/console.D6t261w0.js +173 -0
  7. package/dist/chunks/constants.BZZyIeIE.js +43 -0
  8. package/dist/chunks/coverage.0iPg4Wrz.js +33 -0
  9. package/dist/chunks/{coverage.gV8doR2Y.js → coverage.C2ohxaN0.js} +2216 -2479
  10. package/dist/chunks/creator.BEXek7yQ.js +640 -0
  11. package/dist/chunks/date.CDOsz-HY.js +53 -0
  12. package/dist/chunks/defaults.DmfNPoe5.js +114 -0
  13. package/dist/chunks/{env.D4Lgay0q.js → env.Dq0hM4Xv.js} +1 -1
  14. package/dist/chunks/execute.DZKwfrTs.js +791 -0
  15. package/dist/chunks/git.DXfdBEfR.js +74 -0
  16. package/dist/chunks/{globals.BEpDe-k3.js → globals.DCbUWjip.js} +10 -10
  17. package/dist/chunks/{index.D7Ny8f_s.js → index.BDobFbcz.js} +6 -7
  18. package/dist/chunks/index.DFXFpH3w.js +607 -0
  19. package/dist/chunks/index.VfYQ6MXY.js +104 -0
  20. package/dist/chunks/index.ZIOEXBQB.js +2382 -0
  21. package/dist/chunks/inspector.DbDkSkFn.js +54 -0
  22. package/dist/chunks/node.IqGoMrm4.js +15 -0
  23. package/dist/chunks/{reporters.d.r7poTZjA.d.ts → reporters.d.5g6jXhoW.d.ts} +14 -3
  24. package/dist/chunks/rpc.DGgL5dw7.js +92 -0
  25. package/dist/chunks/run-once.I7PpBOk1.js +47 -0
  26. package/dist/chunks/runBaseTests.CqmKSG99.js +134 -0
  27. package/dist/chunks/setup-common.DEGDGBiA.js +88 -0
  28. package/dist/chunks/{typechecker.BlF3eHsb.js → typechecker.C2IpOhid.js} +620 -622
  29. package/dist/chunks/utils.BfxieIyZ.js +66 -0
  30. package/dist/chunks/utils.CtocqOoE.js +72 -0
  31. package/dist/chunks/utils.OLmtDstN.js +194 -0
  32. package/dist/chunks/{vi.nSCvwQ7l.js → vi.B-PuvDzu.js} +878 -1019
  33. package/dist/chunks/vite.d.Dh1jE-_V.d.ts +23 -0
  34. package/dist/chunks/vm.BW5voG-u.js +789 -0
  35. package/dist/cli.js +2 -2
  36. package/dist/config.cjs +97 -103
  37. package/dist/config.d.ts +3 -3
  38. package/dist/config.js +6 -6
  39. package/dist/coverage.d.ts +1 -1
  40. package/dist/coverage.js +6 -6
  41. package/dist/environments.js +1 -1
  42. package/dist/execute.js +1 -1
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.js +6 -6
  45. package/dist/node.d.ts +3 -3
  46. package/dist/node.js +36 -45
  47. package/dist/path.js +1 -4
  48. package/dist/reporters.d.ts +1 -1
  49. package/dist/reporters.js +4 -4
  50. package/dist/runners.js +231 -267
  51. package/dist/snapshot.js +2 -2
  52. package/dist/suite.js +2 -2
  53. package/dist/worker.js +98 -114
  54. package/dist/workers/forks.js +22 -22
  55. package/dist/workers/runVmTests.js +61 -66
  56. package/dist/workers/threads.js +13 -13
  57. package/dist/workers/vmForks.js +24 -24
  58. package/dist/workers/vmThreads.js +15 -15
  59. package/dist/workers.js +10 -10
  60. package/package.json +11 -11
  61. package/dist/chunks/base.DV59CbtV.js +0 -45
  62. package/dist/chunks/benchmark.DL72EVN-.js +0 -40
  63. package/dist/chunks/cac.BjmXy7OV.js +0 -1664
  64. package/dist/chunks/console.CN7AiMGV.js +0 -179
  65. package/dist/chunks/constants.DTYd6dNH.js +0 -46
  66. package/dist/chunks/coverage.A3sS5-Wm.js +0 -40
  67. package/dist/chunks/creator.BsBnpTzI.js +0 -670
  68. package/dist/chunks/date.W2xKR2qe.js +0 -53
  69. package/dist/chunks/defaults.C2Ndd9wx.js +0 -119
  70. package/dist/chunks/execute.eDH0aFFd.js +0 -839
  71. package/dist/chunks/git.B5SDxu-n.js +0 -69
  72. package/dist/chunks/index.DOyx6FYJ.js +0 -2551
  73. package/dist/chunks/index.K90BXFOx.js +0 -658
  74. package/dist/chunks/index.uXkkC4xl.js +0 -111
  75. package/dist/chunks/inspector.DKLceBVD.js +0 -54
  76. package/dist/chunks/node.AKq966Jp.js +0 -15
  77. package/dist/chunks/rpc.TVf73xOu.js +0 -102
  78. package/dist/chunks/run-once.2ogXb3JV.js +0 -28
  79. package/dist/chunks/runBaseTests.BVrL_ow3.js +0 -142
  80. package/dist/chunks/setup-common.CPvtqi8q.js +0 -96
  81. package/dist/chunks/utils.C8RiOc4B.js +0 -77
  82. package/dist/chunks/utils.Cn0zI1t3.js +0 -68
  83. package/dist/chunks/utils.bLM2atbD.js +0 -198
  84. package/dist/chunks/vite.d.Fvq-NZoa.d.ts +0 -11
  85. package/dist/chunks/vm.jEFQDlX_.js +0 -852
package/dist/worker.js CHANGED
@@ -4,139 +4,123 @@ import { workerId } from 'tinypool';
4
4
  import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
5
5
  import { readFileSync } from 'node:fs';
6
6
  import { resolve, normalize } from 'pathe';
7
- import { e as environments } from './chunks/index.K90BXFOx.js';
8
- import { s as setupInspect } from './chunks/inspector.DKLceBVD.js';
9
- import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.TVf73xOu.js';
10
- import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.C8RiOc4B.js';
11
- import { d as disposeInternalListeners } from './chunks/utils.Cn0zI1t3.js';
7
+ import { e as environments } from './chunks/index.DFXFpH3w.js';
8
+ import { s as setupInspect } from './chunks/inspector.DbDkSkFn.js';
9
+ import { c as createRuntimeRpc, a as rpcDone } from './chunks/rpc.DGgL5dw7.js';
10
+ import { i as isChildProcess, s as setProcessTitle } from './chunks/utils.CtocqOoE.js';
11
+ import { d as disposeInternalListeners } from './chunks/utils.BfxieIyZ.js';
12
12
  import 'node:console';
13
13
  import 'node:module';
14
14
  import '@vitest/utils';
15
15
  import './chunks/index.68735LiX.js';
16
16
 
17
17
  function isBuiltinEnvironment(env) {
18
- return env in environments;
18
+ return env in environments;
19
19
  }
20
- const _loaders = /* @__PURE__ */ new Map();
20
+ const _loaders = new Map();
21
21
  async function createEnvironmentLoader(options) {
22
- if (!_loaders.has(options.root)) {
23
- const loader = new ViteNodeRunner(options);
24
- await loader.executeId("/@vite/env");
25
- _loaders.set(options.root, loader);
26
- }
27
- return _loaders.get(options.root);
22
+ if (!_loaders.has(options.root)) {
23
+ const loader = new ViteNodeRunner(options);
24
+ await loader.executeId("/@vite/env");
25
+ _loaders.set(options.root, loader);
26
+ }
27
+ return _loaders.get(options.root);
28
28
  }
29
29
  async function loadEnvironment(ctx, rpc) {
30
- const name = ctx.environment.name;
31
- if (isBuiltinEnvironment(name)) {
32
- return environments[name];
33
- }
34
- const loader = await createEnvironmentLoader({
35
- root: ctx.config.root,
36
- fetchModule: async (id) => {
37
- const result = await rpc.fetch(id, "ssr");
38
- if (result.id) {
39
- return { code: readFileSync(result.id, "utf-8") };
40
- }
41
- return result;
42
- },
43
- resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
44
- });
45
- const root = loader.root;
46
- const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolveId(`vitest-environment-${name}`, void 0, "ssr"))?.id ?? resolve(root, name);
47
- const pkg = await loader.executeId(normalize(packageId));
48
- if (!pkg || !pkg.default || typeof pkg.default !== "object") {
49
- throw new TypeError(
50
- `Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`
51
- );
52
- }
53
- const environment = pkg.default;
54
- if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
55
- throw new TypeError(
56
- `Environment "${name}" is not a valid environment. Path "${packageId}" should export default object with a "transformMode" method equal to "ssr" or "web".`
57
- );
58
- }
59
- return environment;
30
+ const name = ctx.environment.name;
31
+ if (isBuiltinEnvironment(name)) {
32
+ return environments[name];
33
+ }
34
+ const loader = await createEnvironmentLoader({
35
+ root: ctx.config.root,
36
+ fetchModule: async (id) => {
37
+ const result = await rpc.fetch(id, "ssr");
38
+ if (result.id) {
39
+ return { code: readFileSync(result.id, "utf-8") };
40
+ }
41
+ return result;
42
+ },
43
+ resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
44
+ });
45
+ const root = loader.root;
46
+ const packageId = name[0] === "." || name[0] === "/" ? resolve(root, name) : (await rpc.resolveId(`vitest-environment-${name}`, undefined, "ssr"))?.id ?? resolve(root, name);
47
+ const pkg = await loader.executeId(normalize(packageId));
48
+ if (!pkg || !pkg.default || typeof pkg.default !== "object") {
49
+ throw new TypeError(`Environment "${name}" is not a valid environment. ` + `Path "${packageId}" should export default object with a "setup" or/and "setupVM" method.`);
50
+ }
51
+ const environment = pkg.default;
52
+ if (environment.transformMode !== "web" && environment.transformMode !== "ssr") {
53
+ 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".`);
54
+ }
55
+ return environment;
60
56
  }
61
57
 
62
58
  if (isChildProcess()) {
63
- setProcessTitle(`vitest ${workerId}`);
64
- const isProfiling = process.execArgv.some(
65
- (execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir")
66
- );
67
- if (isProfiling) {
68
- process.on("SIGTERM", () => {
69
- process.exit();
70
- });
71
- }
59
+ setProcessTitle(`vitest ${workerId}`);
60
+ const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
61
+ if (isProfiling) {
62
+ process.on("SIGTERM", () => {
63
+ process.exit();
64
+ });
65
+ }
72
66
  }
73
67
  async function execute(method, ctx) {
74
- disposeInternalListeners();
75
- const prepareStart = performance.now();
76
- const inspectorCleanup = setupInspect(ctx);
77
- process.env.VITEST_WORKER_ID = String(ctx.workerId);
78
- process.env.VITEST_POOL_ID = String(workerId);
79
- try {
80
- if (ctx.worker[0] === ".") {
81
- throw new Error(
82
- `Path to the test runner cannot be relative, received "${ctx.worker}"`
83
- );
84
- }
85
- const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
86
- const testRunnerModule = await import(file);
87
- if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") {
88
- throw new TypeError(
89
- `Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`
90
- );
91
- }
92
- const worker = testRunnerModule.default;
93
- if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") {
94
- throw new TypeError(
95
- `Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`
96
- );
97
- }
98
- const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
99
- const beforeEnvironmentTime = performance.now();
100
- const environment = await loadEnvironment(ctx, rpc);
101
- if (ctx.environment.transformMode) {
102
- environment.transformMode = ctx.environment.transformMode;
103
- }
104
- const state = {
105
- ctx,
106
- // here we create a new one, workers can reassign this if they need to keep it non-isolated
107
- moduleCache: new ModuleCacheMap(),
108
- moduleExecutionInfo: /* @__PURE__ */ new Map(),
109
- config: ctx.config,
110
- onCancel,
111
- environment,
112
- durations: {
113
- environment: beforeEnvironmentTime,
114
- prepare: prepareStart
115
- },
116
- rpc,
117
- providedContext: ctx.providedContext,
118
- onFilterStackTrace(stack) {
119
- return createStackString(parseStacktrace(stack));
120
- }
121
- };
122
- const methodName = method === "collect" ? "collectTests" : "runTests";
123
- if (!worker[methodName] || typeof worker[methodName] !== "function") {
124
- throw new TypeError(
125
- `Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`
126
- );
127
- }
128
- await worker[methodName](state);
129
- } finally {
130
- await rpcDone().catch(() => {
131
- });
132
- inspectorCleanup();
133
- }
68
+ disposeInternalListeners();
69
+ const prepareStart = performance.now();
70
+ const inspectorCleanup = setupInspect(ctx);
71
+ process.env.VITEST_WORKER_ID = String(ctx.workerId);
72
+ process.env.VITEST_POOL_ID = String(workerId);
73
+ try {
74
+ if (ctx.worker[0] === ".") {
75
+ throw new Error(`Path to the test runner cannot be relative, received "${ctx.worker}"`);
76
+ }
77
+ const file = ctx.worker.startsWith("file:") ? ctx.worker : pathToFileURL(ctx.worker).toString();
78
+ const testRunnerModule = await import(file);
79
+ if (!testRunnerModule.default || typeof testRunnerModule.default !== "object") {
80
+ throw new TypeError(`Test worker object should be exposed as a default export. Received "${typeof testRunnerModule.default}"`);
81
+ }
82
+ const worker = testRunnerModule.default;
83
+ if (!worker.getRpcOptions || typeof worker.getRpcOptions !== "function") {
84
+ throw new TypeError(`Test worker should expose "getRpcOptions" method. Received "${typeof worker.getRpcOptions}".`);
85
+ }
86
+ const { rpc, onCancel } = createRuntimeRpc(worker.getRpcOptions(ctx));
87
+ const beforeEnvironmentTime = performance.now();
88
+ const environment = await loadEnvironment(ctx, rpc);
89
+ if (ctx.environment.transformMode) {
90
+ environment.transformMode = ctx.environment.transformMode;
91
+ }
92
+ const state = {
93
+ ctx,
94
+ moduleCache: new ModuleCacheMap(),
95
+ moduleExecutionInfo: new Map(),
96
+ config: ctx.config,
97
+ onCancel,
98
+ environment,
99
+ durations: {
100
+ environment: beforeEnvironmentTime,
101
+ prepare: prepareStart
102
+ },
103
+ rpc,
104
+ providedContext: ctx.providedContext,
105
+ onFilterStackTrace(stack) {
106
+ return createStackString(parseStacktrace(stack));
107
+ }
108
+ };
109
+ const methodName = method === "collect" ? "collectTests" : "runTests";
110
+ if (!worker[methodName] || typeof worker[methodName] !== "function") {
111
+ throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
112
+ }
113
+ await worker[methodName](state);
114
+ } finally {
115
+ await rpcDone().catch(() => {});
116
+ inspectorCleanup();
117
+ }
134
118
  }
135
119
  function run(ctx) {
136
- return execute("run", ctx);
120
+ return execute("run", ctx);
137
121
  }
138
122
  function collect(ctx) {
139
- return execute("collect", ctx);
123
+ return execute("collect", ctx);
140
124
  }
141
125
 
142
126
  export { collect, run };
@@ -1,8 +1,8 @@
1
1
  import v8 from 'node:v8';
2
- import { r as runBaseTests } from '../chunks/base.DV59CbtV.js';
3
- import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.Cn0zI1t3.js';
2
+ import { r as runBaseTests } from '../chunks/base.CylSMlTD.js';
3
+ import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
4
4
  import 'vite-node/client';
5
- import '../chunks/execute.eDH0aFFd.js';
5
+ import '../chunks/execute.DZKwfrTs.js';
6
6
  import 'node:fs';
7
7
  import 'node:url';
8
8
  import 'node:vm';
@@ -14,27 +14,27 @@ import 'node:path';
14
14
  import '@vitest/mocker';
15
15
  import 'node:module';
16
16
  import '@vitest/utils';
17
- import '../chunks/utils.C8RiOc4B.js';
17
+ import '../chunks/utils.CtocqOoE.js';
18
18
 
19
19
  class ForksBaseWorker {
20
- getRpcOptions() {
21
- return createForksRpcOptions(v8);
22
- }
23
- async executeTests(method, state) {
24
- const exit = process.exit;
25
- state.ctx.config = unwrapSerializableConfig(state.ctx.config);
26
- try {
27
- await runBaseTests(method, state);
28
- } finally {
29
- process.exit = exit;
30
- }
31
- }
32
- runTests(state) {
33
- return this.executeTests("run", state);
34
- }
35
- collectTests(state) {
36
- return this.executeTests("collect", state);
37
- }
20
+ getRpcOptions() {
21
+ return createForksRpcOptions(v8);
22
+ }
23
+ async executeTests(method, state) {
24
+ const exit = process.exit;
25
+ state.ctx.config = unwrapSerializableConfig(state.ctx.config);
26
+ try {
27
+ await runBaseTests(method, state);
28
+ } finally {
29
+ process.exit = exit;
30
+ }
31
+ }
32
+ runTests(state) {
33
+ return this.executeTests("run", state);
34
+ }
35
+ collectTests(state) {
36
+ return this.executeTests("collect", state);
37
+ }
38
38
  }
39
39
  const worker = new ForksBaseWorker();
40
40
 
@@ -6,92 +6,87 @@ import util from 'node:util';
6
6
  import { startTests, collectTests } from '@vitest/runner';
7
7
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
8
8
  import { installSourcemapsSupport } from 'vite-node/source-map';
9
- import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.uXkkC4xl.js';
10
- import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.CPvtqi8q.js';
11
- import { V as VitestIndex } from '../chunks/index.D7Ny8f_s.js';
12
- import { c as closeInspector } from '../chunks/inspector.DKLceBVD.js';
13
- import { g as getWorkerState } from '../chunks/utils.C8RiOc4B.js';
9
+ import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../chunks/index.VfYQ6MXY.js';
10
+ import { c as setupCommonEnv, s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from '../chunks/setup-common.DEGDGBiA.js';
11
+ import { V as VitestIndex } from '../chunks/index.BDobFbcz.js';
12
+ import { c as closeInspector } from '../chunks/inspector.DbDkSkFn.js';
13
+ import { g as getWorkerState } from '../chunks/utils.CtocqOoE.js';
14
14
  import 'chai';
15
15
  import 'node:path';
16
16
  import '../path.js';
17
17
  import 'node:url';
18
- import '../chunks/rpc.TVf73xOu.js';
18
+ import '../chunks/rpc.DGgL5dw7.js';
19
19
  import '@vitest/utils';
20
20
  import '../chunks/index.68735LiX.js';
21
- import '../chunks/coverage.A3sS5-Wm.js';
21
+ import '../chunks/coverage.0iPg4Wrz.js';
22
22
  import '@vitest/snapshot';
23
- import '../chunks/run-once.2ogXb3JV.js';
24
- import '../chunks/vi.nSCvwQ7l.js';
23
+ import '../chunks/run-once.I7PpBOk1.js';
24
+ import '../chunks/vi.B-PuvDzu.js';
25
25
  import '@vitest/expect';
26
26
  import '@vitest/runner/utils';
27
27
  import '../chunks/_commonjsHelpers.BFTU3MAI.js';
28
28
  import '@vitest/utils/error';
29
29
  import '@vitest/spy';
30
30
  import '@vitest/utils/source-map';
31
- import '../chunks/date.W2xKR2qe.js';
32
- import '../chunks/benchmark.DL72EVN-.js';
31
+ import '../chunks/date.CDOsz-HY.js';
32
+ import '../chunks/benchmark.BKUatJGy.js';
33
33
  import 'expect-type';
34
34
 
35
35
  async function run(method, files, config, executor) {
36
- const workerState = getWorkerState();
37
- await setupCommonEnv(config);
38
- Object.defineProperty(globalThis, "__vitest_index__", {
39
- value: VitestIndex,
40
- enumerable: false
41
- });
42
- if (workerState.environment.transformMode === "web") {
43
- const _require = createRequire(import.meta.url);
44
- _require.extensions[".css"] = resolveCss;
45
- _require.extensions[".scss"] = resolveCss;
46
- _require.extensions[".sass"] = resolveCss;
47
- _require.extensions[".less"] = resolveCss;
48
- KNOWN_ASSET_TYPES.forEach((type) => {
49
- _require.extensions[`.${type}`] = resolveAsset;
50
- });
51
- process.env.SSR = "";
52
- } else {
53
- process.env.SSR = "1";
54
- }
55
- globalThis.__vitest_required__ = {
56
- util,
57
- timers,
58
- timersPromises
59
- };
60
- installSourcemapsSupport({
61
- getSourceMap: (source) => workerState.moduleCache.getSourceMap(source)
62
- });
63
- await startCoverageInsideWorker(config.coverage, executor, { isolate: false });
64
- if (config.chaiConfig) {
65
- setupChaiConfig(config.chaiConfig);
66
- }
67
- const [runner, snapshotEnvironment] = await Promise.all([
68
- resolveTestRunner(config, executor),
69
- resolveSnapshotEnvironment(config, executor)
70
- ]);
71
- config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
72
- workerState.onCancel.then((reason) => {
73
- closeInspector(config);
74
- runner.onCancel?.(reason);
75
- });
76
- workerState.durations.prepare = performance.now() - workerState.durations.prepare;
77
- const { vi } = VitestIndex;
78
- for (const file of files) {
79
- workerState.filepath = file.filepath;
80
- if (method === "run") {
81
- await startTests([file], runner);
82
- } else {
83
- await collectTests([file], runner);
84
- }
85
- vi.resetConfig();
86
- vi.restoreAllMocks();
87
- }
88
- await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
36
+ const workerState = getWorkerState();
37
+ await setupCommonEnv(config);
38
+ Object.defineProperty(globalThis, "__vitest_index__", {
39
+ value: VitestIndex,
40
+ enumerable: false
41
+ });
42
+ if (workerState.environment.transformMode === "web") {
43
+ const _require = createRequire(import.meta.url);
44
+ _require.extensions[".css"] = resolveCss;
45
+ _require.extensions[".scss"] = resolveCss;
46
+ _require.extensions[".sass"] = resolveCss;
47
+ _require.extensions[".less"] = resolveCss;
48
+ KNOWN_ASSET_TYPES.forEach((type) => {
49
+ _require.extensions[`.${type}`] = resolveAsset;
50
+ });
51
+ process.env.SSR = "";
52
+ } else {
53
+ process.env.SSR = "1";
54
+ }
55
+ globalThis.__vitest_required__ = {
56
+ util,
57
+ timers,
58
+ timersPromises
59
+ };
60
+ installSourcemapsSupport({ getSourceMap: (source) => workerState.moduleCache.getSourceMap(source) });
61
+ await startCoverageInsideWorker(config.coverage, executor, { isolate: false });
62
+ if (config.chaiConfig) {
63
+ setupChaiConfig(config.chaiConfig);
64
+ }
65
+ const [runner, snapshotEnvironment] = await Promise.all([resolveTestRunner(config, executor), resolveSnapshotEnvironment(config, executor)]);
66
+ config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
67
+ workerState.onCancel.then((reason) => {
68
+ closeInspector(config);
69
+ runner.onCancel?.(reason);
70
+ });
71
+ workerState.durations.prepare = performance.now() - workerState.durations.prepare;
72
+ const { vi } = VitestIndex;
73
+ for (const file of files) {
74
+ workerState.filepath = file.filepath;
75
+ if (method === "run") {
76
+ await startTests([file], runner);
77
+ } else {
78
+ await collectTests([file], runner);
79
+ }
80
+ vi.resetConfig();
81
+ vi.restoreAllMocks();
82
+ }
83
+ await stopCoverageInsideWorker(config.coverage, executor, { isolate: false });
89
84
  }
90
85
  function resolveCss(mod) {
91
- mod.exports = "";
86
+ mod.exports = "";
92
87
  }
93
88
  function resolveAsset(mod, url) {
94
- mod.exports = url;
89
+ mod.exports = url;
95
90
  }
96
91
 
97
92
  export { run };
@@ -1,7 +1,7 @@
1
- import { r as runBaseTests } from '../chunks/base.DV59CbtV.js';
2
- import { a as createThreadsRpcOptions } from '../chunks/utils.Cn0zI1t3.js';
1
+ import { r as runBaseTests } from '../chunks/base.CylSMlTD.js';
2
+ import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
3
3
  import 'vite-node/client';
4
- import '../chunks/execute.eDH0aFFd.js';
4
+ import '../chunks/execute.DZKwfrTs.js';
5
5
  import 'node:fs';
6
6
  import 'node:url';
7
7
  import 'node:vm';
@@ -13,18 +13,18 @@ import 'node:path';
13
13
  import '@vitest/mocker';
14
14
  import 'node:module';
15
15
  import '@vitest/utils';
16
- import '../chunks/utils.C8RiOc4B.js';
16
+ import '../chunks/utils.CtocqOoE.js';
17
17
 
18
18
  class ThreadsBaseWorker {
19
- getRpcOptions(ctx) {
20
- return createThreadsRpcOptions(ctx);
21
- }
22
- runTests(state) {
23
- return runBaseTests("run", state);
24
- }
25
- collectTests(state) {
26
- return runBaseTests("collect", state);
27
- }
19
+ getRpcOptions(ctx) {
20
+ return createThreadsRpcOptions(ctx);
21
+ }
22
+ runTests(state) {
23
+ return runBaseTests("run", state);
24
+ }
25
+ collectTests(state) {
26
+ return runBaseTests("collect", state);
27
+ }
28
28
  }
29
29
  const worker = new ThreadsBaseWorker();
30
30
 
@@ -1,19 +1,19 @@
1
1
  import v8 from 'node:v8';
2
- import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.Cn0zI1t3.js';
3
- import { r as runVmTests } from '../chunks/vm.jEFQDlX_.js';
2
+ import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../chunks/utils.BfxieIyZ.js';
3
+ import { r as runVmTests } from '../chunks/vm.BW5voG-u.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.CN7AiMGV.js';
10
+ import '../chunks/console.D6t261w0.js';
11
11
  import 'node:console';
12
12
  import 'node:stream';
13
13
  import 'tinyrainbow';
14
- import '../chunks/date.W2xKR2qe.js';
15
- import '../chunks/utils.C8RiOc4B.js';
16
- import '../chunks/execute.eDH0aFFd.js';
14
+ import '../chunks/date.CDOsz-HY.js';
15
+ import '../chunks/utils.CtocqOoE.js';
16
+ import '../chunks/execute.DZKwfrTs.js';
17
17
  import 'node:fs';
18
18
  import '@vitest/utils/error';
19
19
  import 'vite-node/client';
@@ -23,24 +23,24 @@ import 'node:module';
23
23
  import 'vite-node/constants';
24
24
 
25
25
  class ForksVmWorker {
26
- getRpcOptions() {
27
- return createForksRpcOptions(v8);
28
- }
29
- async executeTests(method, state) {
30
- const exit = process.exit;
31
- state.ctx.config = unwrapSerializableConfig(state.ctx.config);
32
- try {
33
- await runVmTests(method, state);
34
- } finally {
35
- process.exit = exit;
36
- }
37
- }
38
- runTests(state) {
39
- return this.executeTests("run", state);
40
- }
41
- collectTests(state) {
42
- return this.executeTests("collect", state);
43
- }
26
+ getRpcOptions() {
27
+ return createForksRpcOptions(v8);
28
+ }
29
+ async executeTests(method, state) {
30
+ const exit = process.exit;
31
+ state.ctx.config = unwrapSerializableConfig(state.ctx.config);
32
+ try {
33
+ await runVmTests(method, state);
34
+ } finally {
35
+ process.exit = exit;
36
+ }
37
+ }
38
+ runTests(state) {
39
+ return this.executeTests("run", state);
40
+ }
41
+ collectTests(state) {
42
+ return this.executeTests("collect", state);
43
+ }
44
44
  }
45
45
  const worker = new ForksVmWorker();
46
46
 
@@ -1,18 +1,18 @@
1
- import { a as createThreadsRpcOptions } from '../chunks/utils.Cn0zI1t3.js';
2
- import { r as runVmTests } from '../chunks/vm.jEFQDlX_.js';
1
+ import { a as createThreadsRpcOptions } from '../chunks/utils.BfxieIyZ.js';
2
+ import { r as runVmTests } from '../chunks/vm.BW5voG-u.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.CN7AiMGV.js';
9
+ import '../chunks/console.D6t261w0.js';
10
10
  import 'node:console';
11
11
  import 'node:stream';
12
12
  import 'tinyrainbow';
13
- import '../chunks/date.W2xKR2qe.js';
14
- import '../chunks/utils.C8RiOc4B.js';
15
- import '../chunks/execute.eDH0aFFd.js';
13
+ import '../chunks/date.CDOsz-HY.js';
14
+ import '../chunks/utils.CtocqOoE.js';
15
+ import '../chunks/execute.DZKwfrTs.js';
16
16
  import 'node:fs';
17
17
  import '@vitest/utils/error';
18
18
  import 'vite-node/client';
@@ -22,15 +22,15 @@ import 'node:module';
22
22
  import 'vite-node/constants';
23
23
 
24
24
  class ThreadsVmWorker {
25
- getRpcOptions(ctx) {
26
- return createThreadsRpcOptions(ctx);
27
- }
28
- runTests(state) {
29
- return runVmTests("run", state);
30
- }
31
- collectTests(state) {
32
- return runVmTests("collect", state);
33
- }
25
+ getRpcOptions(ctx) {
26
+ return createThreadsRpcOptions(ctx);
27
+ }
28
+ runTests(state) {
29
+ return runVmTests("run", state);
30
+ }
31
+ collectTests(state) {
32
+ return runVmTests("collect", state);
33
+ }
34
34
  }
35
35
  const worker = new ThreadsVmWorker();
36
36