vitest 4.0.0-beta.18 → 4.0.0-beta.19

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 (52) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +1 -1
  3. package/dist/{worker-base.js → chunks/base.CtHM3ryk.js} +18 -91
  4. package/dist/chunks/{browser.d.CCG7W26I.d.ts → browser.d.B9iJzZyn.d.ts} +3 -2
  5. package/dist/chunks/{cac.DYnuYoJK.js → cac.DCrQhweU.js} +14 -61
  6. package/dist/chunks/{cli-api.xhe4uqTX.js → cli-api.BjHteKX0.js} +1312 -53
  7. package/dist/chunks/{config.d.C4PpNy7v.d.ts → config.d.u2CUDWwS.d.ts} +2 -16
  8. package/dist/chunks/{coverage.Ds84cgzV.js → coverage.FU3w4IrQ.js} +25 -1241
  9. package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
  10. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  11. package/dist/chunks/{global.d.RTA0rbJI.d.ts → global.d.BgJSTpgQ.d.ts} +1 -1
  12. package/dist/chunks/{globals.CwYe1aG7.js → globals.BGT_RUsD.js} +4 -2
  13. package/dist/chunks/{index.eEkl9h8v.js → index.BdSLhLDZ.js} +1 -1
  14. package/dist/chunks/{index.D2gVI9Ck.js → index.CcRZ6fUh.js} +1506 -11
  15. package/dist/chunks/{index.Bcjk8TKX.js → index.RwjEGCQ0.js} +2 -2
  16. package/dist/chunks/init-forks.DSafeltJ.js +54 -0
  17. package/dist/chunks/init-threads.SUtZ-067.js +17 -0
  18. package/dist/chunks/{worker.CdzokOSx.js → init.B2EESLQM.js} +97 -80
  19. package/dist/chunks/{inspector.Br76Q2Mb.js → inspector.DLZxSeU3.js} +1 -2
  20. package/dist/chunks/{moduleRunner.d.aXWuQhZN.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +1 -1
  21. package/dist/chunks/{plugin.d.XtKKWlOO.d.ts → plugin.d.BB__S31E.d.ts} +1 -1
  22. package/dist/chunks/{reporters.d.BJ_OuJGZ.d.ts → reporters.d.C6nGyY9_.d.ts} +1113 -1152
  23. package/dist/chunks/{resolveSnapshotEnvironment.tw2a5ux8.js → resolveSnapshotEnvironment.DJJKMKxb.js} +1 -1
  24. package/dist/chunks/{setup-common.DgXU7Yho.js → setup-common.DR1sucx6.js} +1 -1
  25. package/dist/chunks/{startModuleRunner.DPBo3mme.js → startModuleRunner.C2tTvmF9.js} +3 -1
  26. package/dist/{worker-vm.js → chunks/vm.DBeOXrP9.js} +6 -66
  27. package/dist/chunks/{worker.d.DSgBAZPX.d.ts → worker.d.BFk-vvBU.d.ts} +79 -4
  28. package/dist/cli.js +8 -9
  29. package/dist/config.cjs +0 -1
  30. package/dist/config.d.ts +6 -7
  31. package/dist/config.js +1 -1
  32. package/dist/coverage.d.ts +4 -4
  33. package/dist/coverage.js +2 -13
  34. package/dist/index.d.ts +13 -9
  35. package/dist/index.js +4 -2
  36. package/dist/module-evaluator.d.ts +3 -3
  37. package/dist/module-runner.js +1 -1
  38. package/dist/node.d.ts +79 -15
  39. package/dist/node.js +25 -26
  40. package/dist/reporters.d.ts +4 -4
  41. package/dist/reporters.js +9 -10
  42. package/dist/runners.d.ts +1 -1
  43. package/dist/worker.d.ts +26 -0
  44. package/dist/worker.js +46 -0
  45. package/dist/workers/forks.js +50 -0
  46. package/dist/workers/runVmTests.js +6 -5
  47. package/dist/workers/threads.js +50 -0
  48. package/dist/workers/vmForks.js +35 -0
  49. package/dist/workers/vmThreads.js +35 -0
  50. package/package.json +16 -13
  51. package/worker.d.ts +1 -0
  52. package/dist/chunks/typechecker.DsKAhua5.js +0 -1522
@@ -1,5 +1,5 @@
1
1
  import { chai } from '@vitest/expect';
2
- import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.DgXU7Yho.js';
2
+ import { l as loadDiffConfig, b as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.DR1sucx6.js';
3
3
  import { r as rpc } from './rpc.cD77ENhU.js';
4
4
  import { g as getWorkerState } from './utils.CG9h5ccR.js';
5
5
  import { V as VitestTestRunner, N as NodeBenchmarkRunner } from './test.C3RPt8JR.js';
@@ -18,7 +18,7 @@ async function stopCoverageInsideWorker(options, loader, runtimeOptions) {
18
18
 
19
19
  let globalSetup = false;
20
20
  async function setupCommonEnv(config) {
21
- if (setupDefines(config), setupEnv(config.env), !globalSetup && (globalSetup = true, setSafeTimers(), config.globals)) (await import('./globals.CwYe1aG7.js')).registerApiGlobally();
21
+ if (setupDefines(config), setupEnv(config.env), !globalSetup && (globalSetup = true, setSafeTimers(), config.globals)) (await import('./globals.BGT_RUsD.js')).registerApiGlobally();
22
22
  }
23
23
  function setupDefines(config) {
24
24
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,5 +1,5 @@
1
1
  import fs from 'node:fs';
2
- import nodeModule, { isBuiltin } from 'node:module';
2
+ import nodeModule, { builtinModules, isBuiltin } from 'node:module';
3
3
  import { isBareImport } from '@vitest/utils/helpers';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { normalize as normalize$1, join as join$1 } from 'pathe';
@@ -428,6 +428,7 @@ function fixLeadingSlashes(id) {
428
428
  return id.startsWith("//") ? id.replace(multipleSlashRe, "/") : id;
429
429
  }
430
430
 
431
+ const nodeBuiltins = builtinModules.filter((id) => !id.includes(":"));
431
432
  class VitestTransport {
432
433
  constructor(options) {
433
434
  this.options = options;
@@ -437,6 +438,7 @@ class VitestTransport {
437
438
  if (event.event !== "vite:invoke") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support ${event.event} event.`) };
438
439
  const { name, data } = event.data;
439
440
  if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
441
+ if (name === "getBuiltins") return { result: [...nodeBuiltins, /^node:/] };
440
442
  try {
441
443
  return { result: await this.options.fetchModule(...data) };
442
444
  } catch (error) {
@@ -1,32 +1,17 @@
1
- import { c as createForksRpcOptions, u as unwrapSerializableConfig, a as createThreadsRpcOptions, e as execute, t as teardown$1 } from './chunks/worker.CdzokOSx.js';
2
- import v8 from 'node:v8';
3
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
2
  import vm, { isContext, runInContext } from 'node:vm';
5
3
  import { dirname, basename, extname, normalize, resolve } from 'pathe';
6
- import { distDir } from './path.js';
7
- import { createCustomConsole } from './chunks/console.CTJL2nuH.js';
4
+ import { distDir } from '../path.js';
5
+ import { createCustomConsole } from './console.CTJL2nuH.js';
8
6
  import fs from 'node:fs';
9
7
  import { createRequire, Module, isBuiltin } from 'node:module';
10
8
  import { toArray, isBareImport } from '@vitest/utils/helpers';
11
9
  import { findNearestPackageData } from '@vitest/utils/resolver';
12
10
  import { dirname as dirname$1 } from 'node:path';
13
11
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
14
- import { getDefaultRequestStubs } from './module-evaluator.js';
15
- import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './chunks/startModuleRunner.DPBo3mme.js';
16
- import { p as provideWorkerState } from './chunks/utils.CG9h5ccR.js';
17
- import '@vitest/utils/source-map';
18
- import 'vite/module-runner';
19
- import './chunks/index.CbWINfS7.js';
20
- import 'node:console';
21
- import './chunks/inspector.Br76Q2Mb.js';
22
- import './chunks/rpc.cD77ENhU.js';
23
- import '@vitest/utils/timers';
24
- import './chunks/index.Bgo3tNWt.js';
25
- import 'node:stream';
26
- import 'tinyrainbow';
27
- import './chunks/date.-jtEtIeV.js';
28
- import '@vitest/utils/serialize';
29
- import '@vitest/mocker';
12
+ import { getDefaultRequestStubs } from '../module-evaluator.js';
13
+ import { s as startVitestModuleRunner, c as createNodeImportMeta, a as VITEST_VM_CONTEXT_SYMBOL } from './startModuleRunner.C2tTvmF9.js';
14
+ import { p as provideWorkerState } from './utils.CG9h5ccR.js';
30
15
 
31
16
  function interopCommonJsModule(interopDefault, mod) {
32
17
  if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) return {
@@ -648,49 +633,4 @@ async function runVmTests(method, state) {
648
633
  }
649
634
  }
650
635
 
651
- class ForksVmWorker {
652
- getRpcOptions() {
653
- return createForksRpcOptions(v8);
654
- }
655
- async executeTests(method, state) {
656
- const exit = process.exit;
657
- state.ctx.config = unwrapSerializableConfig(state.ctx.config);
658
- try {
659
- await runVmTests(method, state);
660
- } finally {
661
- process.exit = exit;
662
- }
663
- }
664
- runTests(state) {
665
- return this.executeTests("run", state);
666
- }
667
- collectTests(state) {
668
- return this.executeTests("collect", state);
669
- }
670
- }
671
- const worker$1 = new ForksVmWorker();
672
-
673
- class ThreadsVmWorker {
674
- getRpcOptions(ctx) {
675
- return createThreadsRpcOptions(ctx);
676
- }
677
- runTests(state) {
678
- return runVmTests("run", state);
679
- }
680
- collectTests(state) {
681
- return runVmTests("collect", state);
682
- }
683
- }
684
- const worker = new ThreadsVmWorker();
685
-
686
- async function run(ctx) {
687
- await execute("run", ctx, ctx.pool === "vmForks" ? worker$1 : worker);
688
- }
689
- async function collect(ctx) {
690
- await execute("collect", ctx, ctx.pool === "vmForks" ? worker$1 : worker);
691
- }
692
- async function teardown() {
693
- await teardown$1();
694
- }
695
-
696
- export { collect, run, teardown };
636
+ export { runVmTests as r };
@@ -1,6 +1,6 @@
1
1
  import { CancelReason, File, TestAnnotation, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
2
2
  import { FetchFunctionOptions, FetchResult, EvaluatedModules } from 'vite/module-runner';
3
- import { S as SerializedConfig } from './config.d.C4PpNy7v.js';
3
+ import { S as SerializedConfig } from './config.d.u2CUDWwS.js';
4
4
  import { E as Environment } from './environment.d.CrsxCzP1.js';
5
5
  import { SnapshotResult } from '@vitest/snapshot';
6
6
 
@@ -43,6 +43,80 @@ type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "c
43
43
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
44
44
  type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
45
45
  type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
46
+ type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
47
+ interface ChannelOptions {
48
+ /**
49
+ * Function to post raw message
50
+ */
51
+ post: (data: any, ...extras: any[]) => any | Promise<any>;
52
+ /**
53
+ * Listener to receive raw message
54
+ */
55
+ on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
56
+ /**
57
+ * Clear the listener when `$close` is called
58
+ */
59
+ off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
60
+ /**
61
+ * Custom function to serialize data
62
+ *
63
+ * by default it passes the data as-is
64
+ */
65
+ serialize?: (data: any) => any;
66
+ /**
67
+ * Custom function to deserialize data
68
+ *
69
+ * by default it passes the data as-is
70
+ */
71
+ deserialize?: (data: any) => any;
72
+ /**
73
+ * Call the methods with the RPC context or the original functions object
74
+ */
75
+ bind?: 'rpc' | 'functions';
76
+ }
77
+ interface EventOptions<Remote> {
78
+ /**
79
+ * Names of remote functions that do not need response.
80
+ */
81
+ eventNames?: (keyof Remote)[];
82
+ /**
83
+ * Maximum timeout for waiting for response, in milliseconds.
84
+ *
85
+ * @default 60_000
86
+ */
87
+ timeout?: number;
88
+ /**
89
+ * Custom resolver to resolve function to be called
90
+ *
91
+ * For advanced use cases only
92
+ */
93
+ resolver?: BirpcResolver;
94
+ /**
95
+ * Custom error handler
96
+ *
97
+ * @deprecated use `onFunctionError` and `onGeneralError` instead
98
+ */
99
+ onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
100
+ /**
101
+ * Custom error handler for errors occurred in local functions being called
102
+ *
103
+ * @returns `true` to prevent the error from being thrown
104
+ */
105
+ onFunctionError?: (error: Error, functionName: string, args: any[]) => boolean | void;
106
+ /**
107
+ * Custom error handler for errors occurred during serialization or messsaging
108
+ *
109
+ * @returns `true` to prevent the error from being thrown
110
+ */
111
+ onGeneralError?: (error: Error, functionName?: string, args?: any[]) => boolean | void;
112
+ /**
113
+ * Custom error handler for timeouts
114
+ *
115
+ * @returns `true` to prevent the error from being thrown
116
+ */
117
+ onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
118
+ }
119
+ type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
46
120
  type BirpcFn<T> = PromisifyFn<T> & {
47
121
  /**
48
122
  * Send event without asking for response
@@ -96,13 +170,14 @@ interface ContextTestEnvironment {
96
170
  type TestExecutionMethod = "run" | "collect";
97
171
  interface ContextRPC {
98
172
  pool: string;
99
- workerId: number;
100
173
  config: SerializedConfig;
101
174
  projectName: string;
102
- files: string[] | FileSpecification[];
175
+ files: FileSpecification[];
103
176
  environment: ContextTestEnvironment;
104
177
  providedContext: Record<string, any>;
105
178
  invalidates?: string[];
179
+ /** Exposed to test runner as `VITEST_WORKER_ID`. Value is unique per each isolated worker. */
180
+ workerId: number;
106
181
  }
107
182
  interface WorkerGlobalState {
108
183
  ctx: ContextRPC;
@@ -133,4 +208,4 @@ interface WorkerGlobalState {
133
208
  onFilterStackTrace?: (trace: string) => string;
134
209
  }
135
210
 
136
- export type { AfterSuiteRunMeta as A, BirpcReturn as B, ContextRPC as C, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RunnerRPC as R, TestExecutionMethod as T, UserConsoleLog as U, WorkerGlobalState as W, RuntimeRPC as a, ContextTestEnvironment as b, ResolveFunctionResult as c };
211
+ export type { AfterSuiteRunMeta as A, BirpcOptions as B, ContextRPC as C, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, TestExecutionMethod as T, UserConsoleLog as U, WorkerGlobalState as W, BirpcReturn as a, RunnerRPC as b, ContextTestEnvironment as c, ResolveFunctionResult as d };
package/dist/cli.js CHANGED
@@ -1,21 +1,14 @@
1
- import { c as createCLI } from './chunks/cac.DYnuYoJK.js';
1
+ import { c as createCLI } from './chunks/cac.DCrQhweU.js';
2
2
  import '@vitest/utils/helpers';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
6
  import './chunks/constants.D_Q9UYh-.js';
7
- import './chunks/index.D2gVI9Ck.js';
7
+ import './chunks/index.CcRZ6fUh.js';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
- import './chunks/typechecker.DsKAhua5.js';
11
- import 'node:os';
12
10
  import 'node:perf_hooks';
13
- import 'tinyexec';
14
- import './path.js';
15
- import 'node:path';
16
- import 'node:url';
17
11
  import '@vitest/runner/utils';
18
- import 'vite';
19
12
  import '@vitest/utils/source-map';
20
13
  import './chunks/env.D4Lgay0q.js';
21
14
  import 'std-env';
@@ -23,6 +16,12 @@ import 'node:util';
23
16
  import 'node:console';
24
17
  import 'node:stream';
25
18
  import '@vitest/utils/display';
19
+ import 'node:os';
20
+ import 'tinyexec';
21
+ import './path.js';
22
+ import 'node:path';
23
+ import 'node:url';
24
+ import 'vite';
26
25
  import '@vitest/utils/offset';
27
26
  import 'node:module';
28
27
 
package/dist/config.cjs CHANGED
@@ -43,7 +43,6 @@ const configDefaults = Object.freeze({
43
43
  watch: !stdEnv.isCI && process.stdin.isTTY,
44
44
  globals: false,
45
45
  environment: "node",
46
- pool: "forks",
47
46
  clearMocks: false,
48
47
  restoreMocks: false,
49
48
  mockReset: false,
package/dist/config.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { HookHandler, ConfigEnv, UserConfig } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.BJ_OuJGZ.js';
4
- export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.BJ_OuJGZ.js';
5
- import { V as VitestPluginContext } from './chunks/plugin.d.XtKKWlOO.js';
6
- import { F as FakeTimerInstallOpts } from './chunks/config.d.C4PpNy7v.js';
3
+ import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.C6nGyY9_.js';
4
+ export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.C6nGyY9_.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.BB__S31E.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.u2CUDWwS.js';
7
7
  import '@vitest/runner';
8
8
  import '@vitest/utils';
9
- import './chunks/worker.d.DSgBAZPX.js';
9
+ import './chunks/worker.d.BFk-vvBU.js';
10
10
  import 'vite/module-runner';
11
11
  import './chunks/environment.d.CrsxCzP1.js';
12
12
  import '@vitest/snapshot';
@@ -14,7 +14,7 @@ import 'node:stream';
14
14
  import '@vitest/mocker';
15
15
  import '@vitest/utils/source-map';
16
16
  import 'vitest/browser';
17
- import './chunks/browser.d.CCG7W26I.js';
17
+ import './chunks/browser.d.B9iJzZyn.js';
18
18
  import '@vitest/pretty-format';
19
19
  import '@vitest/utils/diff';
20
20
  import '@vitest/expect';
@@ -51,7 +51,6 @@ declare const configDefaults: Readonly<{
51
51
  watch: boolean;
52
52
  globals: boolean;
53
53
  environment: "node";
54
- pool: "forks";
55
54
  clearMocks: boolean;
56
55
  restoreMocks: boolean;
57
56
  mockReset: boolean;
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.CXFFjsi8.js';
1
+ export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.BOqNVLsY.js';
2
2
  export { mergeConfig } from 'vite';
3
3
  export { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';
4
4
  import 'node:os';
@@ -1,17 +1,17 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.BJ_OuJGZ.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.C6nGyY9_.js';
2
2
  import { TransformResult } from 'vite';
3
- import { A as AfterSuiteRunMeta } from './chunks/worker.d.DSgBAZPX.js';
3
+ import { A as AfterSuiteRunMeta } from './chunks/worker.d.BFk-vvBU.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
6
6
  import 'node:stream';
7
7
  import '@vitest/mocker';
8
8
  import '@vitest/utils/source-map';
9
9
  import 'vitest/browser';
10
- import './chunks/config.d.C4PpNy7v.js';
10
+ import './chunks/config.d.u2CUDWwS.js';
11
11
  import '@vitest/pretty-format';
12
12
  import '@vitest/snapshot';
13
13
  import '@vitest/utils/diff';
14
- import './chunks/browser.d.CCG7W26I.js';
14
+ import './chunks/browser.d.B9iJzZyn.js';
15
15
  import '@vitest/expect';
16
16
  import 'vitest/optional-types.js';
17
17
  import './chunks/benchmark.d.DAaHLpsq.js';
package/dist/coverage.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseCoverageProvider } from './chunks/coverage.Ds84cgzV.js';
1
+ export { B as BaseCoverageProvider } from './chunks/coverage.FU3w4IrQ.js';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
4
  import '@vitest/utils/helpers';
@@ -6,7 +6,7 @@ import 'pathe';
6
6
  import 'picomatch';
7
7
  import 'tinyglobby';
8
8
  import 'tinyrainbow';
9
- import './chunks/defaults.CXFFjsi8.js';
9
+ import './chunks/defaults.BOqNVLsY.js';
10
10
  import 'node:os';
11
11
  import './chunks/env.D4Lgay0q.js';
12
12
  import 'std-env';
@@ -20,15 +20,4 @@ import 'node:v8';
20
20
  import 'node:util';
21
21
  import 'vite';
22
22
  import './chunks/constants.D_Q9UYh-.js';
23
- import 'node:tty';
24
- import './path.js';
25
- import './chunks/typechecker.DsKAhua5.js';
26
- import 'node:perf_hooks';
27
- import 'tinyexec';
28
- import '@vitest/runner/utils';
29
- import 'debug';
30
- import 'node:events';
31
- import './chunks/index.Bgo3tNWt.js';
32
- import 'tinypool';
33
- import 'node:worker_threads';
34
23
  import './chunks/coverage.D_JHT54q.js';
package/dist/index.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- import { S as SerializedTestSpecification } from './chunks/browser.d.CCG7W26I.js';
2
- export { B as BrowserTesterOptions } from './chunks/browser.d.CCG7W26I.js';
3
- import './chunks/global.d.RTA0rbJI.js';
1
+ import { S as SerializedTestSpecification } from './chunks/browser.d.B9iJzZyn.js';
2
+ export { B as BrowserTesterOptions } from './chunks/browser.d.B9iJzZyn.js';
3
+ import './chunks/global.d.BgJSTpgQ.js';
4
4
  import { File, TestAnnotation, TaskResultPack, TaskEventPack, TaskPopulated } from '@vitest/runner';
5
5
  export { CancelReason, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
6
  import { Awaitable } from '@vitest/utils';
7
7
  export { ParsedStack, SerializedError, TestError } from '@vitest/utils';
8
- import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, B as BirpcReturn, P as ProvidedContext } from './chunks/worker.d.DSgBAZPX.js';
9
- export { A as AfterSuiteRunMeta, C as ContextRPC, b as ContextTestEnvironment, R as RunnerRPC, a as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.DSgBAZPX.js';
10
- import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.C4PpNy7v.js';
11
- export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.C4PpNy7v.js';
8
+ import { U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, a as BirpcReturn, P as ProvidedContext } from './chunks/worker.d.BFk-vvBU.js';
9
+ export { A as AfterSuiteRunMeta, C as ContextRPC, c as ContextTestEnvironment, b as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.BFk-vvBU.js';
10
+ import { S as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.u2CUDWwS.js';
11
+ export { b as RuntimeConfig, a as SerializedCoverageConfig } from './chunks/config.d.u2CUDWwS.js';
12
12
  import { ExpectStatic } from '@vitest/expect';
13
13
  export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers, chai } from '@vitest/expect';
14
14
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
15
15
  export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject } from '@vitest/spy';
16
16
  import { M as MockFactoryWithHelper, a as MockOptions } from './chunks/mocker.d.BE_2ls6u.js';
17
17
  export { b as bench } from './chunks/suite.d.BJWk38HB.js';
18
+ import { EvaluatedModules } from 'vite/module-runner';
18
19
  export { a as BenchFunction, b as Benchmark, c as BenchmarkAPI, B as BenchmarkResult } from './chunks/benchmark.d.DAaHLpsq.js';
19
20
  export { ExpectTypeOf, expectTypeOf } from 'expect-type';
20
21
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
21
22
  export { DiffOptions } from '@vitest/utils/diff';
22
- export { EvaluatedModules } from 'vite/module-runner';
23
23
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
24
24
  import '@vitest/pretty-format';
25
25
  import './chunks/environment.d.CrsxCzP1.js';
@@ -476,6 +476,10 @@ interface VitestUtils {
476
476
  declare const vitest: VitestUtils;
477
477
  declare const vi: VitestUtils;
478
478
 
479
+ declare class VitestEvaluatedModules extends EvaluatedModules {
480
+ getModuleSourceMapById(id: string): any;
481
+ }
482
+
479
483
  interface AssertType {
480
484
  <T>(value: T): void;
481
485
  }
@@ -486,5 +490,5 @@ interface BrowserUI {
486
490
  setIframeViewport: (width: number, height: number) => Promise<void>;
487
491
  }
488
492
 
489
- export { LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
493
+ export { VitestEvaluatedModules as EvaluatedModules, LabelColor, ModuleGraphData, ProvidedContext, SerializedConfig, SerializedTestSpecification, UserConsoleLog, assert, assertType, createExpect, globalExpect as expect, inject, should, vi, vitest };
490
494
  export type { AssertType, BrowserUI, TransformResultWithSource, VitestUtils, WebSocketEvents, WebSocketHandlers, WebSocketRPC };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { b as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, d as vitest } from './chunks/vi.BZvkKVkM.js';
2
2
  export { b as bench } from './chunks/benchmark.DHKMYAts.js';
3
- export { a as assertType } from './chunks/index.Bcjk8TKX.js';
3
+ export { V as EvaluatedModules } from './chunks/evaluatedModules.Dg1zASAC.js';
4
+ export { a as assertType } from './chunks/index.RwjEGCQ0.js';
4
5
  export { expectTypeOf } from 'expect-type';
5
6
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
- export { EvaluatedModules } from 'vite/module-runner';
7
7
  export { chai } from '@vitest/expect';
8
8
  import '@vitest/runner/utils';
9
9
  import './chunks/utils.CG9h5ccR.js';
@@ -16,3 +16,5 @@ import '@vitest/utils/offset';
16
16
  import '@vitest/utils/source-map';
17
17
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
18
18
  import './chunks/date.-jtEtIeV.js';
19
+ import 'pathe';
20
+ import 'vite/module-runner';
@@ -1,10 +1,10 @@
1
1
  import 'vite/module-runner';
2
- export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.aXWuQhZN.js';
2
+ export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.YtNsMIoJ.js';
3
3
  import 'node:vm';
4
4
  import '@vitest/spy';
5
- import './chunks/worker.d.DSgBAZPX.js';
5
+ import './chunks/worker.d.BFk-vvBU.js';
6
6
  import '@vitest/runner';
7
- import './chunks/config.d.C4PpNy7v.js';
7
+ import './chunks/config.d.u2CUDWwS.js';
8
8
  import '@vitest/pretty-format';
9
9
  import '@vitest/snapshot';
10
10
  import '@vitest/utils/diff';
@@ -1,5 +1,5 @@
1
1
  export { VitestModuleEvaluator } from './module-evaluator.js';
2
- export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.DPBo3mme.js';
2
+ export { a as VITEST_VM_CONTEXT_SYMBOL, V as VitestModuleRunner, s as startVitestModuleRunner } from './chunks/startModuleRunner.C2tTvmF9.js';
3
3
  export { g as getWorkerState } from './chunks/utils.CG9h5ccR.js';
4
4
  import 'node:module';
5
5
  import 'node:url';
package/dist/node.d.ts CHANGED
@@ -3,24 +3,23 @@ import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as Res
3
3
  export { vite as Vite };
4
4
  export { esbuildVersion, isCSSRequest, isFileServingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
5
5
  import { IncomingMessage } from 'node:http';
6
- import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as Pool, l as TestSequencer, L as Logger } from './chunks/reporters.d.BJ_OuJGZ.js';
7
- export { ao as BaseCoverageOptions, G as BenchmarkUserOptions, K as BrowserBuiltinProvider, N as BrowserCommand, Q as BrowserCommandContext, X as BrowserConfigOptions, Y as BrowserInstanceOption, Z as BrowserModuleMocker, $ as BrowserOrchestrator, a0 as BrowserProvider, a1 as BrowserProviderOption, a2 as BrowserScript, a3 as BrowserServerFactory, a4 as BrowserServerOptions, a5 as BrowserServerState, a6 as BrowserServerStateSession, ad as BuiltinEnvironment, a7 as CDPSession, ae as CSSModuleScopeStrategy, ap as CoverageIstanbulOptions, aq as CoverageOptions, ar as CoverageProvider, as as CoverageProviderModule, at as CoverageReporter, c as CoverageV8Options, au as CustomProviderOptions, af as DepsOptimizationOptions, ag as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, o as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, m as OnTestsRerunHandler, a8 as ParentProjectBrowser, ah as PoolOptions, a9 as ProjectBrowser, ai as ProjectConfig, b as ReportContext, aw as ReportedHookContext, ax as Reporter, ak as ResolveSnapshotPathHandler, al as ResolveSnapshotPathHandlerContext, aa as ResolvedBrowserOptions, R as ResolvedCoverageOptions, aj as ResolvedProjectConfig, S as SerializedTestProject, p as TaskOptions, q as TestCase, r as TestCollection, s as TestDiagnostic, t as TestModule, u as TestModuleState, v as TestResult, w as TestResultFailed, x as TestResultPassed, y as TestResultSkipped, ay as TestRunEndReason, av as TestRunResult, F as TestSequencerConstructor, z as TestState, B as TestSuite, D as TestSuiteState, ab as ToMatchScreenshotComparators, ac as ToMatchScreenshotOptions, am as TypecheckConfig, U as UserWorkspaceConfig, an as VitestEnvironment, n as VitestPackageInstaller, W as WatcherTriggerPattern, _ as _BrowserNames, E as experimental_getRunnerTask } from './chunks/reporters.d.BJ_OuJGZ.js';
6
+ import { h as ResolvedConfig, f as UserConfig, i as VitestRunMode, j as VitestOptions, V as Vitest, A as ApiConfig, k as TestSpecification, T as TestProject, P as PoolWorker, l as PoolOptions, m as WorkerRequest, n as TestSequencer, L as Logger } from './chunks/reporters.d.C6nGyY9_.js';
7
+ export { at as BaseCoverageOptions, Y as BenchmarkUserOptions, Z as BrowserBuiltinProvider, $ as BrowserCommand, a0 as BrowserCommandContext, a1 as BrowserConfigOptions, a2 as BrowserInstanceOption, a3 as BrowserModuleMocker, a4 as BrowserOrchestrator, a5 as BrowserProvider, a6 as BrowserProviderOption, a7 as BrowserScript, a8 as BrowserServerFactory, a9 as BrowserServerOptions, aa as BrowserServerState, ab as BrowserServerStateSession, ai as BuiltinEnvironment, ac as CDPSession, aj as CSSModuleScopeStrategy, au as CoverageIstanbulOptions, av as CoverageOptions, aw as CoverageProvider, ax as CoverageProviderModule, ay as CoverageReporter, c as CoverageV8Options, az as CustomProviderOptions, ak as DepsOptimizationOptions, al as EnvironmentOptions, H as HTMLOptions, I as InlineConfig, t as JUnitOptions, J as JsonOptions, M as ModuleDiagnostic, O as OnServerRestartHandler, o as OnTestsRerunHandler, ad as ParentProjectBrowser, am as Pool, q as PoolRunnerInitializer, r as PoolTask, ae as ProjectBrowser, an as ProjectConfig, b as ReportContext, aB as ReportedHookContext, aC as Reporter, ap as ResolveSnapshotPathHandler, aq as ResolveSnapshotPathHandlerContext, af as ResolvedBrowserOptions, R as ResolvedCoverageOptions, ao as ResolvedProjectConfig, S as SerializedTestProject, u as TaskOptions, v as TestCase, w as TestCollection, x as TestDiagnostic, y as TestModule, z as TestModuleState, B as TestResult, D as TestResultFailed, E as TestResultPassed, F as TestResultSkipped, aD as TestRunEndReason, aA as TestRunResult, X as TestSequencerConstructor, G as TestState, K as TestSuite, N as TestSuiteState, ag as ToMatchScreenshotComparators, ah as ToMatchScreenshotOptions, ar as TypecheckConfig, U as UserWorkspaceConfig, as as VitestEnvironment, p as VitestPackageInstaller, W as WatcherTriggerPattern, s as WorkerResponse, _ as _BrowserNames, Q as experimental_getRunnerTask } from './chunks/reporters.d.C6nGyY9_.js';
8
8
  import { Awaitable } from '@vitest/utils';
9
9
  export { SerializedError } from '@vitest/utils';
10
- import { a as RuntimeRPC, C as ContextRPC } from './chunks/worker.d.DSgBAZPX.js';
11
- export { T as TestExecutionType } from './chunks/worker.d.DSgBAZPX.js';
10
+ import { R as RuntimeRPC, C as ContextRPC } from './chunks/worker.d.BFk-vvBU.js';
11
+ export { T as TestExecutionType } from './chunks/worker.d.BFk-vvBU.js';
12
12
  import { Writable } from 'node:stream';
13
- export { V as VitestPluginContext } from './chunks/plugin.d.XtKKWlOO.js';
14
- import { MessagePort } from 'node:worker_threads';
13
+ export { V as VitestPluginContext } from './chunks/plugin.d.BB__S31E.js';
15
14
  import { Debugger } from 'debug';
16
- import './chunks/global.d.RTA0rbJI.js';
15
+ import './chunks/global.d.BgJSTpgQ.js';
17
16
  export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
18
- export { b as RuntimeConfig } from './chunks/config.d.C4PpNy7v.js';
17
+ export { b as RuntimeConfig } from './chunks/config.d.u2CUDWwS.js';
19
18
  export { generateFileHash } from '@vitest/runner/utils';
20
19
  import '@vitest/mocker';
21
20
  import '@vitest/utils/source-map';
22
21
  import 'vitest/browser';
23
- import './chunks/browser.d.CCG7W26I.js';
22
+ import './chunks/browser.d.B9iJzZyn.js';
24
23
  import '@vitest/pretty-format';
25
24
  import '@vitest/snapshot';
26
25
  import '@vitest/utils/diff';
@@ -127,14 +126,14 @@ declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$
127
126
 
128
127
  declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
129
128
 
130
- type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Awaitable<void>;
129
+ type RunWithFiles = (files: TestSpecification[], invalidates?: string[]) => Promise<void>;
131
130
  interface ProcessPool {
132
131
  name: string;
133
132
  runTests: RunWithFiles;
134
133
  collectTests: RunWithFiles;
135
134
  close?: () => Awaitable<void>;
136
135
  }
137
- declare function getFilePoolName(project: TestProject): Pool;
136
+ declare function getFilePoolName(project: TestProject): ResolvedConfig["pool"];
138
137
 
139
138
  interface MethodsOptions {
140
139
  cacheFs?: boolean;
@@ -142,6 +141,73 @@ interface MethodsOptions {
142
141
  }
143
142
  declare function createMethodsRPC(project: TestProject, options?: MethodsOptions): RuntimeRPC;
144
143
 
144
+ /** @experimental */
145
+ declare class ForksPoolWorker implements PoolWorker {
146
+ readonly name: string;
147
+ readonly execArgv: string[];
148
+ readonly env: Record<string, string>;
149
+ readonly cacheFs: boolean;
150
+ protected readonly entrypoint: string;
151
+ private _fork?;
152
+ constructor(options: PoolOptions);
153
+ on(event: string, callback: (arg: any) => void): void;
154
+ off(event: string, callback: (arg: any) => void): void;
155
+ send(message: WorkerRequest): void;
156
+ start(): Promise<void>;
157
+ stop(): Promise<void>;
158
+ deserialize(data: unknown): unknown;
159
+ private get fork();
160
+ }
161
+
162
+ /** @experimental */
163
+ declare class ThreadsPoolWorker implements PoolWorker {
164
+ readonly name: string;
165
+ readonly execArgv: string[];
166
+ readonly env: Record<string, string>;
167
+ protected readonly entrypoint: string;
168
+ private _thread?;
169
+ constructor(options: PoolOptions);
170
+ on(event: string, callback: (arg: any) => void): void;
171
+ off(event: string, callback: (arg: any) => void): void;
172
+ send(message: WorkerRequest): void;
173
+ start(): Promise<void>;
174
+ stop(): Promise<void>;
175
+ deserialize(data: unknown): unknown;
176
+ private get thread();
177
+ }
178
+
179
+ /** @experimental */
180
+ declare class TypecheckPoolWorker implements PoolWorker {
181
+ readonly name: string;
182
+ readonly execArgv: string[];
183
+ readonly env: Record<string, string>;
184
+ private readonly project;
185
+ private _eventEmitter;
186
+ constructor(options: PoolOptions);
187
+ start(): Promise<void>;
188
+ stop(): Promise<void>;
189
+ send(message: WorkerRequest): void;
190
+ on(event: string, callback: (arg: any) => any): void;
191
+ off(event: string, callback: (arg: any) => any): void;
192
+ deserialize(data: unknown): unknown;
193
+ }
194
+
195
+ /** @experimental */
196
+ declare class VmForksPoolWorker extends ForksPoolWorker {
197
+ readonly name = "vmForks";
198
+ readonly reportMemory: true;
199
+ protected readonly entrypoint: string;
200
+ constructor(options: PoolOptions);
201
+ }
202
+
203
+ /** @experimental */
204
+ declare class VmThreadsPoolWorker extends ThreadsPoolWorker {
205
+ readonly name = "vmThreads";
206
+ readonly reportMemory: true;
207
+ protected readonly entrypoint: string;
208
+ constructor(options: PoolOptions);
209
+ }
210
+
145
211
  declare class BaseSequencer implements TestSequencer {
146
212
  protected ctx: Vitest;
147
213
  constructor(ctx: Vitest);
@@ -152,9 +218,7 @@ declare class BaseSequencer implements TestSequencer {
152
218
 
153
219
  declare function registerConsoleShortcuts(ctx: Vitest, stdin: NodeJS.ReadStream | undefined, stdout: NodeJS.WriteStream | Writable): () => void;
154
220
 
155
- interface WorkerContext extends ContextRPC {
156
- port: MessagePort;
157
- }
221
+ interface WorkerContext extends ContextRPC {}
158
222
 
159
223
  declare function createViteLogger(console: Logger, level?: LogLevel, options?: LoggerOptions): Logger$1;
160
224
 
@@ -169,5 +233,5 @@ declare const createViteServer: typeof vite.createServer;
169
233
 
170
234
  declare const rolldownVersion: string | undefined;
171
235
 
172
- export { ApiConfig, BaseSequencer, GitNotFoundError, Pool, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, Vitest, VitestOptions, VitestPlugin, VitestRunMode, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
236
+ export { ApiConfig, BaseSequencer, ForksPoolWorker, GitNotFoundError, PoolOptions, PoolWorker, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, ThreadsPoolWorker, TypecheckPoolWorker, Vitest, VitestOptions, VitestPlugin, VitestRunMode, VmForksPoolWorker, VmThreadsPoolWorker, WorkerRequest, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
173
237
  export type { CliParseOptions, ProcessPool, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget, WorkerContext };