vitest 2.0.0-beta.10 → 2.0.0-beta.12

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 (70) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +3 -3
  3. package/dist/chunks/browser-creator.Bw94IHrL.js +673 -0
  4. package/dist/chunks/{environments-node.39w4gmlF.js → environments-node.XE5FbRPQ.js} +1 -1
  5. package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.DSNOaUHv.js} +10 -10
  6. package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
  7. package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.O41g23Zj.js} +26 -11
  8. package/dist/chunks/{runtime-runBaseTests.Cukyr5-I.js → runtime-runBaseTests.BDt9gQFB.js} +41 -33
  9. package/dist/cli.js +3 -3
  10. package/dist/config.cjs +45 -21
  11. package/dist/config.d.ts +1 -1
  12. package/dist/config.js +45 -22
  13. package/dist/coverage.d.ts +5 -4
  14. package/dist/coverage.js +100 -37
  15. package/dist/environments.d.ts +1 -1
  16. package/dist/environments.js +1 -1
  17. package/dist/execute.d.ts +1 -1
  18. package/dist/execute.js +2 -2
  19. package/dist/index.d.ts +37 -11
  20. package/dist/index.js +10 -10
  21. package/dist/node.d.ts +20 -7
  22. package/dist/node.js +29 -20
  23. package/dist/path.js +4 -1
  24. package/dist/{reporters-CYVC6LOl.d.ts → reporters-Cd1vkLMZ.d.ts} +134 -182
  25. package/dist/reporters.d.ts +1 -1
  26. package/dist/reporters.js +8 -8
  27. package/dist/runners.d.ts +1 -1
  28. package/dist/runners.js +99 -61
  29. package/dist/snapshot.js +2 -2
  30. package/dist/{suite-Dpu9EC_k.d.ts → suite-BS2CV79a.d.ts} +1 -1
  31. package/dist/suite.d.ts +2 -2
  32. package/dist/suite.js +3 -3
  33. package/dist/utils.d.ts +1 -5
  34. package/dist/utils.js +1 -6
  35. package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
  36. package/dist/vendor/{base.Dln9yllP.js → base.Cy97mmVC.js} +4 -3
  37. package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.B6pblCp2.js} +13 -14
  38. package/dist/vendor/{cac.CtYFkoSJ.js → cac.DRNUX42m.js} +82 -38
  39. package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.Bu-PSdzx.js} +5908 -13271
  40. package/dist/vendor/{constants.TCjCaw2D.js → constants.BWsVtsAj.js} +5 -22
  41. package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
  42. package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
  43. package/dist/vendor/env.2ltrQNq0.js +8 -0
  44. package/dist/vendor/{execute.BHj6OMh4.js → execute.T3gg2ZK6.js} +174 -60
  45. package/dist/vendor/{index.B5SKBLvV.js → index.B7pSlOSa.js} +18 -10
  46. package/dist/vendor/{index._7XLd8Kd.js → index.BJmtb_7W.js} +3 -2
  47. package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
  48. package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
  49. package/dist/vendor/index.D6GZqexG.js +6575 -0
  50. package/dist/vendor/{index.D3hs2WiI.js → index.Hqvcg1pf.js} +3 -3
  51. package/dist/vendor/{index.BOMEjpjj.js → index.ZtQtNPP2.js} +962 -471
  52. package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
  53. package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
  54. package/dist/vendor/{setup-common.DAu7t7mY.js → setup-common.CWnv_2-5.js} +30 -15
  55. package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
  56. package/dist/vendor/{utils.YuQ3LT2a.js → utils.DSO2UK15.js} +40 -25
  57. package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
  58. package/dist/vendor/{vi.hATFzZbX.js → vi.DXACdGTu.js} +267 -138
  59. package/dist/vendor/{vm.Ow-X2mkS.js → vm.D9wVR14y.js} +152 -87
  60. package/dist/worker.js +31 -15
  61. package/dist/workers/forks.js +4 -4
  62. package/dist/workers/runVmTests.js +15 -14
  63. package/dist/workers/threads.js +4 -4
  64. package/dist/workers/vmForks.js +7 -7
  65. package/dist/workers/vmThreads.js +7 -7
  66. package/dist/workers.d.ts +2 -2
  67. package/dist/workers.js +10 -10
  68. package/package.json +11 -11
  69. package/suppress-warnings.cjs +1 -4
  70. package/dist/vendor/env.bmJgw1qP.js +0 -7
package/dist/coverage.js CHANGED
@@ -1,30 +1,46 @@
1
1
  import { relative } from 'pathe';
2
- import { m as mm } from './vendor/index.CThipSqB.js';
2
+ import { m as mm } from './vendor/index.BMmMjLIQ.js';
3
3
  import './vendor/_commonjsHelpers.BFTU3MAI.js';
4
4
  import 'util';
5
5
  import 'path';
6
6
 
7
- const THRESHOLD_KEYS = ["lines", "functions", "statements", "branches"];
7
+ const THRESHOLD_KEYS = [
8
+ "lines",
9
+ "functions",
10
+ "statements",
11
+ "branches"
12
+ ];
8
13
  const GLOBAL_THRESHOLDS_KEY = "global";
9
14
  class BaseCoverageProvider {
10
15
  /**
11
16
  * Check if current coverage is above configured thresholds and bump the thresholds if needed
12
17
  */
13
- updateThresholds({ thresholds: allThresholds, perFile, configurationFile, onUpdate }) {
18
+ updateThresholds({
19
+ thresholds: allThresholds,
20
+ perFile,
21
+ configurationFile,
22
+ onUpdate
23
+ }) {
14
24
  let updatedThresholds = false;
15
25
  const config = resolveConfig(configurationFile);
16
26
  assertConfigurationModule(config);
17
27
  for (const { coverageMap, thresholds, name } of allThresholds) {
18
- const summaries = perFile ? coverageMap.files().map((file) => coverageMap.fileCoverageFor(file).toSummary()) : [coverageMap.getCoverageSummary()];
28
+ const summaries = perFile ? coverageMap.files().map(
29
+ (file) => coverageMap.fileCoverageFor(file).toSummary()
30
+ ) : [coverageMap.getCoverageSummary()];
19
31
  const thresholdsToUpdate = [];
20
32
  for (const key of THRESHOLD_KEYS) {
21
33
  const threshold = thresholds[key] ?? 100;
22
- const actual = Math.min(...summaries.map((summary) => summary[key].pct));
23
- if (actual > threshold)
34
+ const actual = Math.min(
35
+ ...summaries.map((summary) => summary[key].pct)
36
+ );
37
+ if (actual > threshold) {
24
38
  thresholdsToUpdate.push([key, actual]);
39
+ }
25
40
  }
26
- if (thresholdsToUpdate.length === 0)
41
+ if (thresholdsToUpdate.length === 0) {
27
42
  continue;
43
+ }
28
44
  updatedThresholds = true;
29
45
  for (const [threshold, newValue] of thresholdsToUpdate) {
30
46
  if (name === GLOBAL_THRESHOLDS_KEY) {
@@ -36,14 +52,20 @@ class BaseCoverageProvider {
36
52
  }
37
53
  }
38
54
  if (updatedThresholds) {
39
- console.log("Updating thresholds to configuration file. You may want to push with updated coverage thresholds.");
55
+ console.log(
56
+ "Updating thresholds to configuration file. You may want to push with updated coverage thresholds."
57
+ );
40
58
  onUpdate();
41
59
  }
42
60
  }
43
61
  /**
44
62
  * Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
45
63
  */
46
- checkThresholds({ thresholds: allThresholds, perFile }) {
64
+ checkThresholds({
65
+ thresholds: allThresholds,
66
+ perFile,
67
+ onError
68
+ }) {
47
69
  for (const { coverageMap, thresholds, name } of allThresholds) {
48
70
  if (thresholds.branches === void 0 && thresholds.functions === void 0 && thresholds.lines === void 0 && thresholds.statements === void 0) {
49
71
  continue;
@@ -51,21 +73,32 @@ class BaseCoverageProvider {
51
73
  const summaries = perFile ? coverageMap.files().map((file) => ({
52
74
  file,
53
75
  summary: coverageMap.fileCoverageFor(file).toSummary()
54
- })) : [{
55
- file: null,
56
- summary: coverageMap.getCoverageSummary()
57
- }];
76
+ })) : [
77
+ {
78
+ file: null,
79
+ summary: coverageMap.getCoverageSummary()
80
+ }
81
+ ];
58
82
  for (const { summary, file } of summaries) {
59
- for (const thresholdKey of ["lines", "functions", "statements", "branches"]) {
83
+ for (const thresholdKey of [
84
+ "lines",
85
+ "functions",
86
+ "statements",
87
+ "branches"
88
+ ]) {
60
89
  const threshold = thresholds[thresholdKey];
61
90
  if (threshold !== void 0) {
62
91
  const coverage = summary.data[thresholdKey].pct;
63
92
  if (coverage < threshold) {
64
93
  process.exitCode = 1;
65
94
  let errorMessage = `ERROR: Coverage for ${thresholdKey} (${coverage}%) does not meet ${name === GLOBAL_THRESHOLDS_KEY ? name : `"${name}"`} threshold (${threshold}%)`;
66
- if (perFile && file)
67
- errorMessage += ` for ${relative("./", file).replace(/\\/g, "/")}`;
68
- console.error(errorMessage);
95
+ if (perFile && file) {
96
+ errorMessage += ` for ${relative("./", file).replace(
97
+ /\\/g,
98
+ "/"
99
+ )}`;
100
+ }
101
+ onError(errorMessage);
69
102
  }
70
103
  }
71
104
  }
@@ -77,18 +110,28 @@ class BaseCoverageProvider {
77
110
  * where each threshold set holds their own coverage maps. Threshold set is either
78
111
  * for specific files defined by glob pattern or global for all other files.
79
112
  */
80
- resolveThresholds({ coverageMap, thresholds, createCoverageMap, root }) {
113
+ resolveThresholds({
114
+ coverageMap,
115
+ thresholds,
116
+ createCoverageMap,
117
+ root
118
+ }) {
81
119
  const resolvedThresholds = [];
82
120
  const files = coverageMap.files();
83
121
  const filesMatchedByGlobs = [];
84
122
  const globalCoverageMap = createCoverageMap();
85
- for (const key of Object.keys(thresholds)) {
86
- if (key === "perFile" || key === "autoUpdate" || key === "100" || THRESHOLD_KEYS.includes(key))
123
+ for (const key of Object.keys(
124
+ thresholds
125
+ )) {
126
+ if (key === "perFile" || key === "autoUpdate" || key === "100" || THRESHOLD_KEYS.includes(key)) {
87
127
  continue;
128
+ }
88
129
  const glob = key;
89
130
  const globThresholds = resolveGlobThresholds(thresholds[glob]);
90
131
  const globCoverageMap = createCoverageMap();
91
- const matchingFiles = files.filter((file) => mm.isMatch(relative(root, file), glob));
132
+ const matchingFiles = files.filter(
133
+ (file) => mm.isMatch(relative(root, file), glob)
134
+ );
92
135
  filesMatchedByGlobs.push(...matchingFiles);
93
136
  for (const file of matchingFiles) {
94
137
  const fileCoverage = coverageMap.fileCoverageFor(file);
@@ -100,7 +143,9 @@ class BaseCoverageProvider {
100
143
  thresholds: globThresholds
101
144
  });
102
145
  }
103
- for (const file of files.filter((file2) => !filesMatchedByGlobs.includes(file2))) {
146
+ for (const file of files.filter(
147
+ (file2) => !filesMatchedByGlobs.includes(file2)
148
+ )) {
104
149
  const fileCoverage = coverageMap.fileCoverageFor(file);
105
150
  globalCoverageMap.addFileCoverage(fileCoverage);
106
151
  }
@@ -120,8 +165,9 @@ class BaseCoverageProvider {
120
165
  * Resolve reporters from various configuration options
121
166
  */
122
167
  resolveReporters(configReporters) {
123
- if (!Array.isArray(configReporters))
168
+ if (!Array.isArray(configReporters)) {
124
169
  return [[configReporters, {}]];
170
+ }
125
171
  const resolvedReporters = [];
126
172
  for (const reporter of configReporters) {
127
173
  if (Array.isArray(reporter)) {
@@ -133,24 +179,28 @@ class BaseCoverageProvider {
133
179
  return resolvedReporters;
134
180
  }
135
181
  hasTerminalReporter(reporters) {
136
- return reporters.some(([reporter]) => reporter === "text" || reporter === "text-summary" || reporter === "text-lcov" || reporter === "teamcity");
182
+ return reporters.some(
183
+ ([reporter]) => reporter === "text" || reporter === "text-summary" || reporter === "text-lcov" || reporter === "teamcity"
184
+ );
137
185
  }
138
186
  toSlices(array, size) {
139
187
  return array.reduce((chunks, item) => {
140
188
  const index = Math.max(0, chunks.length - 1);
141
189
  const lastChunk = chunks[index] || [];
142
190
  chunks[index] = lastChunk;
143
- if (lastChunk.length >= size)
191
+ if (lastChunk.length >= size) {
144
192
  chunks.push([item]);
145
- else
193
+ } else {
146
194
  lastChunk.push(item);
195
+ }
147
196
  return chunks;
148
197
  }, []);
149
198
  }
150
199
  }
151
200
  function resolveGlobThresholds(thresholds) {
152
- if (!thresholds || typeof thresholds !== "object")
201
+ if (!thresholds || typeof thresholds !== "object") {
153
202
  return {};
203
+ }
154
204
  return {
155
205
  lines: "lines" in thresholds && typeof thresholds.lines === "number" ? thresholds.lines : void 0,
156
206
  branches: "branches" in thresholds && typeof thresholds.branches === "number" ? thresholds.branches : void 0,
@@ -160,42 +210,54 @@ function resolveGlobThresholds(thresholds) {
160
210
  }
161
211
  function assertConfigurationModule(config) {
162
212
  try {
163
- if (typeof config.test.coverage.thresholds !== "object")
164
- throw new Error("Expected config.test.coverage.thresholds to be an object");
213
+ if (typeof config.test.coverage.thresholds !== "object") {
214
+ throw new TypeError(
215
+ "Expected config.test.coverage.thresholds to be an object"
216
+ );
217
+ }
165
218
  } catch (error) {
166
219
  const message = error instanceof Error ? error.message : String(error);
167
- throw new Error(`Unable to parse thresholds from configuration file: ${message}`);
220
+ throw new Error(
221
+ `Unable to parse thresholds from configuration file: ${message}`
222
+ );
168
223
  }
169
224
  }
170
225
  function resolveConfig(configModule) {
171
226
  const mod = configModule.exports.default;
172
227
  try {
173
- if (mod.$type === "object")
228
+ if (mod.$type === "object") {
174
229
  return mod;
230
+ }
175
231
  let config = resolveDefineConfig(mod);
176
- if (config)
232
+ if (config) {
177
233
  return config;
234
+ }
178
235
  if (mod.$type === "function-call" && mod.$callee === "mergeConfig") {
179
236
  config = resolveMergeConfig(mod);
180
- if (config)
237
+ if (config) {
181
238
  return config;
239
+ }
182
240
  }
183
241
  } catch (error) {
184
242
  throw new Error(error instanceof Error ? error.message : String(error));
185
243
  }
186
- throw new Error("Failed to update coverage thresholds. Configuration file is too complex.");
244
+ throw new Error(
245
+ "Failed to update coverage thresholds. Configuration file is too complex."
246
+ );
187
247
  }
188
248
  function resolveDefineConfig(mod) {
189
249
  if (mod.$type === "function-call" && mod.$callee === "defineConfig") {
190
- if (mod.$args[0].$type === "object")
250
+ if (mod.$args[0].$type === "object") {
191
251
  return mod.$args[0];
252
+ }
192
253
  if (mod.$args[0].$type === "arrow-function-expression") {
193
254
  if (mod.$args[0].$body.$type === "object") {
194
255
  return mod.$args[0].$body;
195
256
  }
196
257
  const config = resolveMergeConfig(mod.$args[0].$body);
197
- if (config)
258
+ if (config) {
198
259
  return config;
260
+ }
199
261
  }
200
262
  }
201
263
  }
@@ -203,8 +265,9 @@ function resolveMergeConfig(mod) {
203
265
  if (mod.$type === "function-call" && mod.$callee === "mergeConfig") {
204
266
  for (const arg of mod.$args) {
205
267
  const config = resolveDefineConfig(arg);
206
- if (config)
268
+ if (config) {
207
269
  return config;
270
+ }
208
271
  }
209
272
  }
210
273
  }
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-CYVC6LOl.js';
1
+ import { E as Environment } from './reporters-Cd1vkLMZ.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.kpsSqFiz.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor/index.D4nqnQWz.js';
2
2
  import 'node:console';
package/dist/execute.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import vm from 'node:vm';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
3
  import { ViteNodeRunnerOptions } from 'vite-node';
4
- import { aF as PendingSuiteMock, aG as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, aH as MockMap } from './reporters-CYVC6LOl.js';
4
+ import { aI as PendingSuiteMock, aJ as MockFactory, e as RuntimeRPC, W as WorkerGlobalState, aK as MockMap } from './reporters-Cd1vkLMZ.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
package/dist/execute.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as VitestExecutor } from './vendor/execute.BHj6OMh4.js';
1
+ export { V as VitestExecutor } from './vendor/execute.T3gg2ZK6.js';
2
2
  import 'node:vm';
3
3
  import 'node:url';
4
4
  import 'node:fs';
@@ -8,4 +8,4 @@ import 'pathe';
8
8
  import '@vitest/utils/error';
9
9
  import './path.js';
10
10
  import '@vitest/utils';
11
- import './vendor/base._gnK9Slw.js';
11
+ import './vendor/base.CTYV4Gnz.js';
package/dist/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { TaskPopulated } from '@vitest/runner';
2
- export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
3
- export { b as bench } from './suite-Dpu9EC_k.js';
1
+ import { TaskPopulated, File, TaskResultPack } from '@vitest/runner';
2
+ export { CancelReason, Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
3
+ export { b as bench } from './suite-BS2CV79a.js';
4
4
  import { ExpectStatic } from '@vitest/expect';
5
- export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
6
- import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, h as RuntimeConfig, P as ProvidedContext } from './reporters-CYVC6LOl.js';
7
- export { Q as AfterSuiteRunMeta, A as ApiConfig, $ as ArgumentsType, _ as Arrayable, Y as Awaitable, B as BaseCoverageOptions, ag as BenchFunction, ae as Benchmark, ah as BenchmarkAPI, af as BenchmarkResult, ad as BenchmarkUserOptions, x as BrowserConfigOptions, w as BrowserScript, p as BuiltinEnvironment, q as CSSModuleScopeStrategy, j as CollectLineNumbers, k as CollectLines, a1 as Constructable, m as Context, f as ContextRPC, G as ContextTestEnvironment, aa as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, a9 as CoverageReporter, ab as CoverageV8Options, ac as CustomProviderOptions, D as DepsOptimizationOptions, E as Environment, r as EnvironmentOptions, a3 as EnvironmentReturn, H as HappyDOMOptions, I as InlineConfig, J as JSDOMOptions, a2 as ModuleCache, a6 as ModuleGraphData, a0 as MutableArray, Z as Nullable, a7 as OnServerRestartHandler, n as Pool, o as PoolOptions, v as ProjectConfig, i as RawErrsMap, a8 as ReportContext, N as Reporter, O as ResolveIdFunction, R as ResolvedConfig, a as ResolvedCoverageOptions, K as ResolvedTestEnvironment, l as RootAndTarget, z as RunnerRPC, e as RuntimeRPC, S as SerializableSpec, t as TransformModePatterns, ai as TransformResultWithSource, T as TscErrorInfo, u as TypecheckConfig, U as UserConfig, a5 as UserConsoleLog, y as UserWorkspaceConfig, L as Vitest, V as VitestEnvironment, s as VitestRunMode, a4 as VmEnvironmentReturn, am as WebSocketBrowserEvents, ak as WebSocketBrowserHandlers, ao as WebSocketBrowserRPC, al as WebSocketEvents, aj as WebSocketHandlers, an as WebSocketRPC, g as WorkerContext, W as WorkerGlobalState, X as WorkerRPC } from './reporters-CYVC6LOl.js';
5
+ export { Assertion, AsymmetricMatchersContaining, ExpectPollOptions, ExpectStatic, JestAssertion } from '@vitest/expect';
6
+ import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, h as RuntimeConfig, P as ProvidedContext, R as ResolvedConfig, i as ModuleGraphData, j as Reporter, k as BirpcReturn } from './reporters-Cd1vkLMZ.js';
7
+ export { Y as AfterSuiteRunMeta, A as ApiConfig, a1 as ArgumentsType, a0 as Arrayable, _ as Awaitable, B as BaseCoverageOptions, ah as BenchFunction, af as Benchmark, ai as BenchmarkAPI, ag as BenchmarkResult, ae as BenchmarkUserOptions, G as BrowserConfigOptions, z as BrowserScript, s as BuiltinEnvironment, t as CSSModuleScopeStrategy, m as CollectLineNumbers, n as CollectLines, a3 as Constructable, p as Context, f as ContextRPC, N as ContextTestEnvironment, ab as CoverageIstanbulOptions, C as CoverageOptions, b as CoverageProvider, c as CoverageProviderModule, aa as CoverageReporter, ac as CoverageV8Options, ad as CustomProviderOptions, D as DepsOptimizationOptions, E as Environment, u as EnvironmentOptions, a5 as EnvironmentReturn, H as HappyDOMOptions, I as InlineConfig, J as JSDOMOptions, a4 as ModuleCache, a2 as MutableArray, $ as Nullable, a8 as OnServerRestartHandler, q as Pool, r as PoolOptions, y as ProjectConfig, l as RawErrsMap, a9 as ReportContext, X as ResolveIdFunction, a as ResolvedCoverageOptions, O as ResolvedTestEnvironment, o as RootAndTarget, L as RunnerRPC, e as RuntimeRPC, S as SerializableSpec, w as TransformModePatterns, T as TscErrorInfo, x as TypecheckConfig, U as UserConfig, a7 as UserConsoleLog, K as UserWorkspaceConfig, Q as Vitest, V as VitestEnvironment, v as VitestRunMode, a6 as VmEnvironmentReturn, g as WorkerContext, W as WorkerGlobalState, Z as WorkerRPC } from './reporters-Cd1vkLMZ.js';
8
8
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
9
- export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
9
+ export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
10
10
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
11
11
  export { DiffOptions } from '@vitest/utils/diff';
12
+ import { TransformResult } from 'vite';
12
13
  import * as chai from 'chai';
13
14
  export { chai };
14
15
  export { assert, should } from 'chai';
15
16
  export { ErrorWithDiff, ParsedStack } from '@vitest/utils';
16
17
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
17
18
  import '@vitest/runner/utils';
18
- import 'vite';
19
19
  import 'vite-node';
20
20
  import 'node:stream';
21
21
  import 'vite-node/client';
@@ -1067,7 +1067,7 @@ interface BrowserUI {
1067
1067
  *
1068
1068
  * @experimental
1069
1069
  */
1070
- declare function runOnce<T>(fn: (() => T), key?: string): T;
1070
+ declare function runOnce<T>(fn: () => T, key?: string): T;
1071
1071
  /**
1072
1072
  * Get a boolean indicates whether the task is running in the first time.
1073
1073
  * Could only be `false` in watch mode.
@@ -1420,6 +1420,32 @@ declare function isWatchMode(): boolean;
1420
1420
  * Gives access to injected context provided from the main thread.
1421
1421
  * This usually returns a value provided by `globalSetup` or an external library.
1422
1422
  */
1423
- declare function inject<T extends keyof ProvidedContext>(key: T): ProvidedContext[T];
1423
+ declare function inject<T extends keyof ProvidedContext & string>(key: T): ProvidedContext[T];
1424
1424
 
1425
- export { type AssertType, type BrowserUI, type ExpectTypeOf, ProvidedContext, RuntimeConfig, type VitestUtils, assertType, createExpect, globalExpect as expect, expectTypeOf, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
1425
+ interface TransformResultWithSource extends TransformResult {
1426
+ source?: string;
1427
+ }
1428
+ interface WebSocketHandlers {
1429
+ onCollected: (files?: File[]) => Promise<void>;
1430
+ onTaskUpdate: (packs: TaskResultPack[]) => void;
1431
+ getFiles: () => File[];
1432
+ getTestFiles: () => Promise<[{
1433
+ name: string;
1434
+ root: string;
1435
+ }, file: string][]>;
1436
+ getPaths: () => string[];
1437
+ getConfig: () => ResolvedConfig;
1438
+ getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
1439
+ getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
1440
+ readTestFile: (id: string) => Promise<string | null>;
1441
+ saveTestFile: (id: string, content: string) => Promise<void>;
1442
+ rerun: (files: string[]) => Promise<void>;
1443
+ updateSnapshot: (file?: File) => Promise<void>;
1444
+ getUnhandledErrors: () => unknown[];
1445
+ }
1446
+ interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected' | 'onSpecsCollected'> {
1447
+ onFinishedReportCoverage: () => void;
1448
+ }
1449
+ type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
1450
+
1451
+ export { type AssertType, type BrowserUI, type ExpectTypeOf, ModuleGraphData, ProvidedContext, Reporter, ResolvedConfig, RuntimeConfig, type TransformResultWithSource, type VitestUtils, type WebSocketEvents, type WebSocketHandlers, type WebSocketRPC, assertType, createExpect, globalExpect as expect, expectTypeOf, getRunningMode, inject, isFirstRun, isWatchMode, runOnce, vi, vitest };
package/dist/index.js CHANGED
@@ -1,27 +1,27 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
- export { b as bench } from './vendor/benchmark.BNLebNi5.js';
3
- export { i as isFirstRun, a as runOnce } from './vendor/run-once.DLomgGUH.js';
4
- export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.hATFzZbX.js';
5
- import { d as dist } from './vendor/index.D3hs2WiI.js';
6
- export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.D3hs2WiI.js';
2
+ export { b as bench } from './vendor/benchmark.B6pblCp2.js';
3
+ export { i as isFirstRun, a as runOnce } from './vendor/run-once.Db8Hgq9X.js';
4
+ export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.DXACdGTu.js';
5
+ import { d as dist } from './vendor/index.Hqvcg1pf.js';
6
+ export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.Hqvcg1pf.js';
7
7
  import * as chai from 'chai';
8
8
  export { chai };
9
9
  export { assert, should } from 'chai';
10
10
  import '@vitest/runner/utils';
11
11
  import '@vitest/utils';
12
- import './vendor/index._7XLd8Kd.js';
12
+ import './vendor/index.BJmtb_7W.js';
13
13
  import 'pathe';
14
14
  import './vendor/global.7bFbnyXl.js';
15
- import './vendor/env.bmJgw1qP.js';
15
+ import './vendor/env.2ltrQNq0.js';
16
16
  import 'std-env';
17
17
  import './vendor/_commonjsHelpers.BFTU3MAI.js';
18
18
  import '@vitest/expect';
19
19
  import '@vitest/snapshot';
20
20
  import '@vitest/utils/error';
21
- import './vendor/tasks.WC7M-K-v.js';
21
+ import './vendor/tasks.DhVtQBtW.js';
22
22
  import '@vitest/utils/source-map';
23
- import './vendor/base._gnK9Slw.js';
24
- import './vendor/date.BKM1wewY.js';
23
+ import './vendor/base.CTYV4Gnz.js';
24
+ import './vendor/date.W2xKR2qe.js';
25
25
  import '@vitest/spy';
26
26
 
27
27
 
package/dist/node.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { s as VitestRunMode, U as UserConfig, ap as VitestOptions, L as Vitest, R as ResolvedConfig, P as ProvidedContext, aq as WorkspaceProject, e as RuntimeRPC, ar as TestSequencer, as as WorkspaceSpec } from './reporters-CYVC6LOl.js';
2
- export { aA as BrowserCommand, aB as BrowserCommandContext, ay as BrowserProvider, ax as BrowserProviderInitializationOptions, az as BrowserProviderOptions, w as BrowserScript, aE as HTMLOptions, aD as JUnitOptions, aC as JsonOptions, at as ProcessPool, aw as TestSequencerConstructor, av as VitestPackageInstaller, au as getFilePoolName } from './reporters-CYVC6LOl.js';
3
- import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
- export { isFileServingAllowed } from 'vite';
1
+ import { v as VitestRunMode, U as UserConfig, aj as VitestOptions, Q as Vitest, R as ResolvedConfig, P as ProvidedContext, ak as WorkspaceProject, e as RuntimeRPC, A as ApiConfig, al as Logger, am as TestSequencer, an as WorkspaceSpec } from './reporters-Cd1vkLMZ.js';
2
+ export { ay as BrowserBuiltinProvider, az as BrowserCommand, aA as BrowserCommandContext, aE as BrowserOrchestrator, at as BrowserProvider, as as BrowserProviderInitializationOptions, av as BrowserProviderModule, ax as BrowserProviderOptions, z as BrowserScript, aB as BrowserServer, aC as BrowserServerState, aD as BrowserServerStateContext, au as CDPSession, aH as HTMLOptions, aG as JUnitOptions, aF as JsonOptions, ao as ProcessPool, aw as ResolvedBrowserOptions, ar as TestSequencerConstructor, aq as VitestPackageInstaller, ap as getFilePoolName } from './reporters-Cd1vkLMZ.js';
3
+ import { UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1 } from 'vite';
4
+ import * as vite from 'vite';
5
+ export { vite as Vite };
6
+ export { createServer, isFileServingAllowed } from 'vite';
5
7
  import { Writable } from 'node:stream';
8
+ import createDebug from 'debug';
6
9
  import '@vitest/runner';
7
10
  import 'vite-node';
8
11
  import '@vitest/snapshot';
@@ -50,10 +53,20 @@ declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream
50
53
 
51
54
  interface GlobalSetupContext {
52
55
  config: ResolvedConfig;
53
- provide: <T extends keyof ProvidedContext>(key: T, value: ProvidedContext[T]) => void;
56
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
54
57
  }
55
58
 
56
- declare function createMethodsRPC(project: WorkspaceProject): RuntimeRPC;
59
+ interface MethodsOptions {
60
+ cacheFs?: boolean;
61
+ }
62
+ declare function createMethodsRPC(project: WorkspaceProject, options?: MethodsOptions): RuntimeRPC;
63
+
64
+ declare function createDebugger(namespace: `vitest:${string}`): createDebug.Debugger | undefined;
65
+
66
+ declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
67
+
68
+ declare function resolveApiServerConfig<Options extends ApiConfig & UserConfig>(options: Options, defaultPort: number): ApiConfig | undefined;
69
+ declare function resolveConfig(mode: VitestRunMode, options: UserConfig, viteConfig: ResolvedConfig$1, logger: Logger): ResolvedConfig;
57
70
 
58
71
  declare const rootDir: string;
59
72
  declare const distDir: string;
@@ -65,4 +78,4 @@ declare class BaseSequencer implements TestSequencer {
65
78
  sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
66
79
  }
67
80
 
68
- export { BaseSequencer, type GlobalSetupContext, TestSequencer, Vitest, VitestPlugin, WorkspaceProject, WorkspaceSpec, createMethodsRPC, createVitest, distDir, parseCLI, registerConsoleShortcuts, rootDir, startVitest };
81
+ export { BaseSequencer, type GlobalSetupContext, TestSequencer, Vitest, VitestPlugin, WorkspaceProject, WorkspaceSpec, createDebugger, createMethodsRPC, createVitest, distDir, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rootDir, startVitest };
package/dist/node.js CHANGED
@@ -1,34 +1,37 @@
1
- export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, g as getFilePoolName, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.CUtJc4r3.js';
2
- export { p as parseCLI } from './vendor/cac.CtYFkoSJ.js';
1
+ export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, g as getFilePoolName, r as registerConsoleShortcuts, e as resolveApiServerConfig, f as resolveConfig, d as resolveFsAllow, s as startVitest } from './vendor/cli-api.Bu-PSdzx.js';
2
+ export { p as parseCLI } from './vendor/cac.DRNUX42m.js';
3
+ import createDebug from 'debug';
3
4
  export { distDir, rootDir } from './path.js';
4
- export { B as BaseSequencer } from './vendor/index.BOMEjpjj.js';
5
- export { isFileServingAllowed } from 'vite';
5
+ export { e as BaseSequencer } from './vendor/index.ZtQtNPP2.js';
6
+ export { createServer, isFileServingAllowed } from 'vite';
6
7
  import 'pathe';
7
- import './vendor/constants.TCjCaw2D.js';
8
- import './vendor/coverage.ChSqD-qS.js';
9
- import './vendor/index.kpsSqFiz.js';
8
+ import './vendor/constants.BWsVtsAj.js';
9
+ import './vendor/coverage.BhYSDdTT.js';
10
+ import './vendor/index.D4nqnQWz.js';
10
11
  import 'node:console';
12
+ import './vendor/index.D6GZqexG.js';
11
13
  import 'node:path';
12
14
  import 'node:url';
13
15
  import 'node:process';
14
16
  import 'node:fs';
15
- import 'node:worker_threads';
16
17
  import './vendor/_commonjsHelpers.BFTU3MAI.js';
18
+ import 'readline';
19
+ import 'events';
20
+ import 'node:worker_threads';
17
21
  import 'os';
18
22
  import 'path';
19
23
  import 'util';
20
- import './vendor/index.CThipSqB.js';
24
+ import './vendor/index.BMmMjLIQ.js';
21
25
  import 'stream';
22
- import 'events';
23
26
  import 'fs';
24
27
  import 'picocolors';
25
28
  import 'vite-node/client';
26
29
  import '@vitest/snapshot/manager';
27
30
  import 'vite-node/server';
28
31
  import '@vitest/runner/utils';
29
- import './vendor/base._gnK9Slw.js';
32
+ import './vendor/base.CTYV4Gnz.js';
30
33
  import '@vitest/utils';
31
- import './vendor/env.bmJgw1qP.js';
34
+ import './vendor/env.2ltrQNq0.js';
32
35
  import 'std-env';
33
36
  import './vendor/index.BpSiYbpB.js';
34
37
  import 'zlib';
@@ -46,24 +49,30 @@ import 'node:events';
46
49
  import 'tinypool';
47
50
  import 'node:crypto';
48
51
  import 'node:fs/promises';
49
- import 'debug';
50
52
  import 'node:module';
51
53
  import 'node:assert';
52
54
  import 'node:util';
53
55
  import 'vite-node/utils';
54
56
  import 'magic-string';
55
57
  import '@vitest/utils/ast';
56
- import '@ampproject/remapping';
57
- import './vendor/index._7XLd8Kd.js';
58
+ import './vendor/index.BJmtb_7W.js';
58
59
  import './vendor/global.7bFbnyXl.js';
59
60
  import 'node:readline';
60
- import 'readline';
61
- import './vendor/utils.YuQ3LT2a.js';
62
- import './vendor/tasks.WC7M-K-v.js';
61
+ import './vendor/utils.DSO2UK15.js';
62
+ import './vendor/tasks.DhVtQBtW.js';
63
63
  import 'node:perf_hooks';
64
- import './chunks/runtime-console.DiVMr5d4.js';
64
+ import './chunks/runtime-console.O41g23Zj.js';
65
65
  import 'node:stream';
66
- import './vendor/date.BKM1wewY.js';
66
+ import './vendor/date.W2xKR2qe.js';
67
67
  import 'execa';
68
68
  import 'module';
69
69
  import 'assert';
70
+
71
+ function createDebugger(namespace) {
72
+ const debug = createDebug(namespace);
73
+ if (debug.enabled) {
74
+ return debug;
75
+ }
76
+ }
77
+
78
+ export { createDebugger };
package/dist/path.js CHANGED
@@ -2,6 +2,9 @@ import url from 'node:url';
2
2
  import { resolve } from 'pathe';
3
3
 
4
4
  const rootDir = resolve(url.fileURLToPath(import.meta.url), "../../");
5
- const distDir = resolve(url.fileURLToPath(import.meta.url), "../../dist");
5
+ const distDir = resolve(
6
+ url.fileURLToPath(import.meta.url),
7
+ "../../dist"
8
+ );
6
9
 
7
10
  export { distDir, rootDir };