vitest 4.0.0-beta.4 → 4.0.0-beta.6

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 (78) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +8 -9
  3. package/dist/browser.js +3 -2
  4. package/dist/chunks/base.BXI97p6t.js +39 -0
  5. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.UW6Ezvxy.js} +6 -8
  6. package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
  7. package/dist/chunks/{cac.CY0IAxC4.js → cac.WE-urWw5.js} +38 -115
  8. package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.CZz3evYC.js} +931 -1439
  9. package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
  10. package/dist/chunks/{console.DoJHFxmj.js → console.B0quX7yH.js} +32 -68
  11. package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
  12. package/dist/chunks/{coverage.C84l9G-M.js → coverage.BPRS6xgn.js} +395 -665
  13. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  14. package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
  15. package/dist/chunks/{creator.yfA2ExGt.js → creator.KEg6n5IC.js} +29 -75
  16. package/dist/chunks/{date.Bq6ZW5rf.js → date.-jtEtIeV.js} +6 -17
  17. package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
  18. package/dist/chunks/{git.BVQ8w_Sw.js → git.BFNcloKD.js} +1 -2
  19. package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
  20. package/dist/chunks/{globals.Dgo-vS5G.js → globals.lgsmH00r.js} +7 -6
  21. package/dist/chunks/{index.D3SKT3tv.js → index.7w0eqmYM.js} +14 -24
  22. package/dist/chunks/{index.D1_MsKEt.js → index.AR8aAkCC.js} +4 -2
  23. package/dist/chunks/{index.CmSc2RE5.js → index.BG0gqZH-.js} +43 -106
  24. package/dist/chunks/{index.CtUvr1c8.js → index.CsFXYRkW.js} +27 -46
  25. package/dist/chunks/{index.Bz6b0Ib7.js → index.VNI-1z5c.js} +276 -604
  26. package/dist/chunks/{inspector.C914Efll.js → inspector.CvQD-Nie.js} +10 -25
  27. package/dist/chunks/moduleRunner.d.8kKUsuDg.d.ts +202 -0
  28. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  29. package/dist/chunks/{node.fjCdwEIl.js → node.BOqcT2jW.js} +1 -1
  30. package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.DuiQJfUL.d.ts} +1 -1
  31. package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CqR9-CDJ.d.ts} +52 -101
  32. package/dist/chunks/resolver.Bx6lE0iq.js +119 -0
  33. package/dist/chunks/{rpc.jnQO9F8a.js → rpc.RpPylpp0.js} +7 -21
  34. package/dist/chunks/runBaseTests.D6sfuWBM.js +99 -0
  35. package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.hLGRxhC8.js} +15 -27
  36. package/dist/chunks/startModuleRunner.C8TW8zTN.js +655 -0
  37. package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.Cd1wvxUM.js} +97 -209
  38. package/dist/chunks/{utils.CcGm2cd1.js → utils.C2YI6McM.js} +4 -13
  39. package/dist/chunks/{utils.XdZDrNZV.js → utils.C7__0Iv5.js} +7 -17
  40. package/dist/chunks/{vi.CA0EPI9Y.js → vi.BfdOiD4j.js} +116 -269
  41. package/dist/chunks/{vm.BUnLJt_P.js → vm.BHBje7cC.js} +101 -225
  42. package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
  43. package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
  44. package/dist/cli.js +4 -4
  45. package/dist/config.cjs +3 -9
  46. package/dist/config.d.ts +10 -12
  47. package/dist/config.js +1 -1
  48. package/dist/coverage.d.ts +10 -11
  49. package/dist/coverage.js +5 -6
  50. package/dist/environments.d.ts +2 -2
  51. package/dist/environments.js +1 -1
  52. package/dist/index.d.ts +10 -9
  53. package/dist/index.js +6 -5
  54. package/dist/module-evaluator.d.ts +12 -0
  55. package/dist/module-evaluator.js +276 -0
  56. package/dist/module-runner.js +15 -0
  57. package/dist/node.d.ts +12 -13
  58. package/dist/node.js +19 -24
  59. package/dist/reporters.d.ts +7 -8
  60. package/dist/reporters.js +3 -3
  61. package/dist/runners.d.ts +3 -3
  62. package/dist/runners.js +35 -57
  63. package/dist/snapshot.js +2 -2
  64. package/dist/suite.js +2 -2
  65. package/dist/worker.js +82 -45
  66. package/dist/workers/forks.js +11 -10
  67. package/dist/workers/runVmTests.js +27 -46
  68. package/dist/workers/threads.js +11 -10
  69. package/dist/workers/vmForks.js +11 -10
  70. package/dist/workers/vmThreads.js +11 -10
  71. package/dist/workers.d.ts +5 -4
  72. package/dist/workers.js +17 -16
  73. package/package.json +22 -17
  74. package/dist/chunks/base.BaCDDRPG.js +0 -38
  75. package/dist/chunks/execute.Dt-pCVcL.js +0 -708
  76. package/dist/chunks/runBaseTests.DBVVLMSb.js +0 -129
  77. package/dist/execute.d.ts +0 -148
  78. package/dist/execute.js +0 -13
@@ -2,55 +2,40 @@ import { createRequire } from 'node:module';
2
2
  import { pathToFileURL } from 'node:url';
3
3
 
4
4
  const __require = createRequire(import.meta.url);
5
- let inspector;
6
- let session;
5
+ let inspector, session;
7
6
  /**
8
7
  * Enables debugging inside `worker_threads` and `child_process`.
9
8
  * Should be called as early as possible when worker/process has been set up.
10
9
  */
11
10
  function setupInspect(ctx) {
12
- const config = ctx.config;
13
- const isEnabled = config.inspector.enabled;
11
+ const config = ctx.config, isEnabled = config.inspector.enabled;
14
12
  if (isEnabled) {
15
13
  inspector = __require("node:inspector");
16
14
  // Inspector may be open already if "isolate: false" is used
17
15
  const isOpen = inspector.url() !== void 0;
18
16
  if (!isOpen) {
19
- inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger);
20
- if (config.inspectBrk) {
17
+ if (inspector.open(config.inspector.port, config.inspector.host, config.inspector.waitForDebugger), config.inspectBrk) {
21
18
  const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
22
19
  // Stop at first test file
23
- if (firstTestFile) {
24
- session = new inspector.Session();
25
- session.connect();
26
- session.post("Debugger.enable");
27
- session.post("Debugger.setBreakpointByUrl", {
28
- lineNumber: 0,
29
- url: pathToFileURL(firstTestFile)
30
- });
31
- }
20
+ if (firstTestFile) session = new inspector.Session(), session.connect(), session.post("Debugger.enable"), session.post("Debugger.setBreakpointByUrl", {
21
+ lineNumber: 0,
22
+ url: pathToFileURL(firstTestFile)
23
+ });
32
24
  }
33
25
  }
34
26
  }
35
27
  const keepOpen = shouldKeepOpen(config);
36
28
  return function cleanup() {
37
- if (isEnabled && !keepOpen && inspector) {
38
- inspector.close();
39
- session?.disconnect();
40
- }
29
+ if (isEnabled && !keepOpen && inspector) inspector.close(), session?.disconnect();
41
30
  };
42
31
  }
43
32
  function closeInspector(config) {
44
33
  const keepOpen = shouldKeepOpen(config);
45
- if (inspector && !keepOpen) {
46
- inspector.close();
47
- session?.disconnect();
48
- }
34
+ if (inspector && !keepOpen) inspector.close(), session?.disconnect();
49
35
  }
50
36
  function shouldKeepOpen(config) {
51
37
  // In watch mode the inspector can persist re-runs if isolation is disabled and a single worker is used
52
- const isIsolatedSingleThread = config.pool === "threads" && config.poolOptions?.threads?.isolate === false && config.poolOptions?.threads?.singleThread;
53
- const isIsolatedSingleFork = config.pool === "forks" && config.poolOptions?.forks?.isolate === false && config.poolOptions?.forks?.singleFork;
38
+ const isIsolatedSingleThread = config.pool === "threads" && config.poolOptions?.threads?.isolate === false && config.poolOptions?.threads?.singleThread, isIsolatedSingleFork = config.pool === "forks" && config.poolOptions?.forks?.isolate === false && config.poolOptions?.forks?.singleFork;
54
39
  return config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
55
40
  }
56
41
 
@@ -0,0 +1,202 @@
1
+ import vm from 'node:vm';
2
+ import { ModuleEvaluator, ModuleRunnerImportMeta, ModuleRunnerContext, EvaluatedModuleNode, FetchFunction, ModuleRunner, EvaluatedModules } from 'vite/module-runner';
3
+ import { R as RuntimeRPC, W as WorkerGlobalState } from './worker.d.D9QWnzAe.js';
4
+ import { R as ResolveFunctionResult } from './environment.d.2fYMoz3o.js';
5
+ import { MockedModule, MockedModuleType } from '@vitest/mocker';
6
+ import { P as PendingSuiteMock, b as MockFactory, a as MockOptions } from './mocker.d.BE_2ls6u.js';
7
+
8
+ declare class FileMap {
9
+ private fsCache;
10
+ private fsBufferCache;
11
+ readFileAsync(path: string): Promise<string>;
12
+ readFile(path: string): string;
13
+ readBuffer(path: string): Buffer;
14
+ }
15
+
16
+ // need to copy paste types for vm
17
+ // because they require latest @types/node which we don't bundle
18
+ interface ModuleEvaluateOptions {
19
+ timeout?: vm.RunningScriptOptions["timeout"] | undefined;
20
+ breakOnSigint?: vm.RunningScriptOptions["breakOnSigint"] | undefined;
21
+ }
22
+ type ModuleLinker = (specifier: string, referencingModule: VMModule, extra: {
23
+ assert: object;
24
+ }) => VMModule | Promise<VMModule>;
25
+ type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
26
+ declare class VMModule {
27
+ dependencySpecifiers: readonly string[];
28
+ error: any;
29
+ identifier: string;
30
+ context: vm.Context;
31
+ namespace: object;
32
+ status: ModuleStatus;
33
+ evaluate(options?: ModuleEvaluateOptions): Promise<void>;
34
+ link(linker: ModuleLinker): Promise<void>;
35
+ }
36
+
37
+ interface ExternalModulesExecutorOptions {
38
+ context: vm.Context;
39
+ fileMap: FileMap;
40
+ packageCache: Map<string, any>;
41
+ transform: RuntimeRPC["transform"];
42
+ interopDefault?: boolean;
43
+ viteClientModule: Record<string, unknown>;
44
+ }
45
+ // TODO: improve Node.js strict mode support in #2854
46
+ declare class ExternalModulesExecutor {
47
+ #private;
48
+ private options;
49
+ private cjs;
50
+ private esm;
51
+ private vite;
52
+ private context;
53
+ private fs;
54
+ private resolvers;
55
+ constructor(options: ExternalModulesExecutorOptions);
56
+ import(identifier: string): Promise<object>;
57
+ require(identifier: string): any;
58
+ createRequire(identifier: string): NodeJS.Require;
59
+ // dynamic import can be used in both ESM and CJS, so we have it in the executor
60
+ importModuleDynamically: (specifier: string, referencer: VMModule) => Promise<VMModule>;
61
+ resolveModule: (specifier: string, referencer: string) => Promise<VMModule>;
62
+ resolve(specifier: string, parent: string): string;
63
+ private getModuleInformation;
64
+ private createModule;
65
+ private get isNetworkSupported();
66
+ }
67
+
68
+ type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
69
+ interface ModuleExecutionInfoEntry {
70
+ startOffset: number;
71
+ /** The duration that was spent executing the module. */
72
+ duration: number;
73
+ /** The time that was spent executing the module itself and externalized imports. */
74
+ selfTime: number;
75
+ }
76
+
77
+ interface VitestModuleEvaluatorOptions {
78
+ interopDefault?: boolean | undefined;
79
+ moduleExecutionInfo?: ModuleExecutionInfo;
80
+ getCurrentTestFilepath?: () => string | undefined;
81
+ compiledFunctionArgumentsNames?: string[];
82
+ compiledFunctionArgumentsValues?: unknown[];
83
+ }
84
+ declare class VitestModuleEvaluator implements ModuleEvaluator {
85
+ private options;
86
+ stubs: Record<string, any>;
87
+ env: ModuleRunnerImportMeta["env"];
88
+ private vm;
89
+ private compiledFunctionArgumentsNames?;
90
+ private compiledFunctionArgumentsValues;
91
+ private primitives;
92
+ private debug;
93
+ constructor(vmOptions?: VitestVmOptions | undefined, options?: VitestModuleEvaluatorOptions);
94
+ private convertIdToImportUrl;
95
+ runExternalModule(id: string): Promise<any>;
96
+ runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
97
+ private createRequire;
98
+ private shouldInterop;
99
+ }
100
+ declare function createImportMetaEnvProxy(): ModuleRunnerImportMeta["env"];
101
+ declare function getDefaultRequestStubs(context?: vm.Context): Record<string, any>;
102
+ declare function isPrimitive(v: any): boolean;
103
+ declare function wrapId(id: string): string;
104
+ declare function unwrapId(id: string): string;
105
+
106
+ interface VitestTransportOptions {
107
+ fetchModule: FetchFunction;
108
+ resolveId: (id: string, importer?: string) => Promise<ResolveFunctionResult | null>;
109
+ }
110
+
111
+ interface MockContext {
112
+ /**
113
+ * When mocking with a factory, this refers to the module that imported the mock.
114
+ */
115
+ callstack: null | string[];
116
+ }
117
+ interface VitestMockerOptions {
118
+ context?: vm.Context;
119
+ root: string;
120
+ moduleDirectories: string[];
121
+ resolveId: (id: string, importer?: string) => Promise<{
122
+ id: string;
123
+ file: string;
124
+ url: string;
125
+ } | null>;
126
+ getCurrentTestFilepath: () => string | undefined;
127
+ }
128
+ declare class VitestMocker {
129
+ moduleRunner: VitestModuleRunner;
130
+ private options;
131
+ static pendingIds: PendingSuiteMock[];
132
+ private spyModule?;
133
+ private primitives;
134
+ private filterPublicKeys;
135
+ private registries;
136
+ private mockContext;
137
+ constructor(moduleRunner: VitestModuleRunner, options: VitestMockerOptions);
138
+ private get root();
139
+ private get evaluatedModules();
140
+ private get moduleDirectories();
141
+ initializeSpyModule(): Promise<void>;
142
+ private getMockerRegistry;
143
+ reset(): void;
144
+ private invalidateModuleById;
145
+ private isModuleDirectory;
146
+ getSuiteFilepath(): string;
147
+ private createError;
148
+ resolveId(rawId: string, importer?: string): Promise<{
149
+ id: string;
150
+ url: string;
151
+ external: string | null;
152
+ }>;
153
+ resolveMocks(): Promise<void>;
154
+ private ensureModule;
155
+ private callFunctionMock;
156
+ // public method to avoid circular dependency
157
+ getMockContext(): MockContext;
158
+ // path used to store mocked dependencies
159
+ getMockPath(dep: string): string;
160
+ getDependencyMock(id: string): MockedModule | undefined;
161
+ findMockRedirect(mockPath: string, external: string | null): string | null;
162
+ mockObject(object: Record<string | symbol, any>, mockExports?: Record<string | symbol, any>, behavior?: "automock" | "autospy"): Record<string | symbol, any>;
163
+ unmockPath(id: string): void;
164
+ mockPath(originalId: string, id: string, url: string, external: string | null, mockType: MockedModuleType | undefined, factory: MockFactory | undefined): void;
165
+ importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
166
+ importMock(rawId: string, importer: string): Promise<any>;
167
+ requestWithMockedModule(url: string, evaluatedNode: EvaluatedModuleNode, callstack: string[], mock: MockedModule): Promise<any>;
168
+ mockedRequest(url: string, evaluatedNode: EvaluatedModuleNode, callstack: string[]): Promise<any>;
169
+ queueMock(id: string, importer: string, factoryOrOptions?: MockFactory | MockOptions): void;
170
+ queueUnmock(id: string, importer: string): void;
171
+ }
172
+ declare module "vite/module-runner" {
173
+ interface EvaluatedModuleNode {
174
+ mockedExports?: Record<string, any>;
175
+ }
176
+ }
177
+
178
+ // @ts-expect-error overriding private method
179
+ declare class VitestModuleRunner extends ModuleRunner {
180
+ private options;
181
+ mocker: VitestMocker;
182
+ moduleExecutionInfo: ModuleExecutionInfo;
183
+ constructor(options: VitestModuleRunnerOptions);
184
+ import(rawId: string): Promise<any>;
185
+ fetchModule(url: string, importer?: string): Promise<EvaluatedModuleNode>;
186
+ private _cachedRequest;
187
+ }
188
+ interface VitestModuleRunnerOptions {
189
+ transport: VitestTransportOptions;
190
+ evaluator: VitestModuleEvaluator;
191
+ evaluatedModules: EvaluatedModules;
192
+ getWorkerState: () => WorkerGlobalState;
193
+ mocker?: VitestMocker;
194
+ vm?: VitestVmOptions;
195
+ }
196
+ interface VitestVmOptions {
197
+ context: vm.Context;
198
+ externalModulesExecutor: ExternalModulesExecutor;
199
+ }
200
+
201
+ export { VitestModuleRunner as V, VitestModuleEvaluator as b, createImportMetaEnvProxy as c, getDefaultRequestStubs as g, isPrimitive as i, unwrapId as u, wrapId as w };
202
+ export type { VitestModuleEvaluatorOptions as a };
@@ -0,0 +1,19 @@
1
+ class VitestTransport {
2
+ constructor(options) {
3
+ this.options = options;
4
+ }
5
+ async invoke(event) {
6
+ if (event.type !== "custom") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support Vite HMR events.`) };
7
+ if (event.event !== "vite:invoke") return { error: /* @__PURE__ */ new Error(`Vitest Module Runner doesn't support ${event.event} event.`) };
8
+ const { name, data } = event.data;
9
+ if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
10
+ try {
11
+ const result = await this.options.fetchModule(...data);
12
+ return { result };
13
+ } catch (error) {
14
+ return { error };
15
+ }
16
+ }
17
+ }
18
+
19
+ export { VitestTransport as V };
@@ -1,5 +1,5 @@
1
1
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
2
- import { g as getWorkerState } from './utils.XdZDrNZV.js';
2
+ import { g as getWorkerState } from './utils.C7__0Iv5.js';
3
3
  import '@vitest/utils';
4
4
 
5
5
  class VitestNodeSnapshotEnvironment extends NodeSnapshotEnvironment {
@@ -1,4 +1,4 @@
1
- import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.DWg40D2B.js';
1
+ import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.CqR9-CDJ.js';
2
2
 
3
3
  interface VitestPluginContext {
4
4
  vitest: Vitest;
@@ -1,21 +1,20 @@
1
- import { Task, CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, TaskResultPack, TaskEventPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
- import { P as ProvidedContext, U as UserConsoleLog, b as Awaitable$1, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor } from './environment.d.Bhm9oc0v.js';
1
+ import { Task, CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, TaskResultPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
3
2
  import { ParsedStack, Awaitable, TestError, SerializedError, Arrayable } from '@vitest/utils';
3
+ import { P as ProvidedContext, U as UserConsoleLog, b as Awaitable$1, c as Arrayable$1, A as AfterSuiteRunMeta, L as LabelColor } from './environment.d.2fYMoz3o.js';
4
4
  import { Writable } from 'node:stream';
5
5
  import { ViteDevServer, ModuleNode, TransformResult as TransformResult$1, DepOptimizationConfig, ServerOptions, UserConfig as UserConfig$1, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { Console } from 'node:console';
7
- import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.BRP8scJf.js';
7
+ import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.Cawq_X_N.js';
8
8
  import { MockedModule } from '@vitest/mocker';
9
9
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
10
- import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.DZo8c7fw.js';
10
+ import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.CKNVOKm0.js';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
14
- import { ViteNodeServerOptions } from 'vite-node';
15
14
  import * as chai from 'chai';
16
15
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
17
16
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
18
- import { a as RuntimeCoverageProviderModule } from './coverage.d.CNYjU4GF.js';
17
+ import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
19
18
  import { SnapshotManager } from '@vitest/snapshot/manager';
20
19
  import { Stats } from 'node:fs';
21
20
 
@@ -152,7 +151,7 @@ interface BrowserProviderModule {
152
151
  }
153
152
  interface BrowserProviderOptions {}
154
153
  type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
155
- type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "testTransformMode" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
154
+ type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
156
155
  interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
157
156
  /**
158
157
  * Name of the browser
@@ -1174,9 +1173,11 @@ declare class BlobReporter implements Reporter {
1174
1173
  start: number;
1175
1174
  ctx: Vitest;
1176
1175
  options: BlobOptions;
1176
+ coverage: unknown | undefined;
1177
1177
  constructor(options: BlobOptions);
1178
1178
  onInit(ctx: Vitest): void;
1179
- onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
1179
+ onCoverage(coverage: unknown): void;
1180
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): Promise<void>;
1180
1181
  }
1181
1182
  interface MergedBlobs {
1182
1183
  files: File[];
@@ -1194,6 +1195,7 @@ declare class StateManager {
1194
1195
  processTimeoutCauses: Set<string>;
1195
1196
  reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1196
1197
  blobs?: MergedBlobs;
1198
+ transformTime: number;
1197
1199
  onUnhandledError?: OnUnhandledErrorCallback;
1198
1200
  constructor(options: {
1199
1201
  onUnhandledError?: OnUnhandledErrorCallback;
@@ -1510,26 +1512,6 @@ interface Reporter {
1510
1512
  * @experimental
1511
1513
  */
1512
1514
  onBrowserInit?: (project: TestProject) => Awaitable$1<void>;
1513
- /**
1514
- * @deprecated use `onTestRunStart` instead
1515
- */
1516
- onPathsCollected?: (paths?: string[]) => Awaitable$1<void>;
1517
- /**
1518
- * @deprecated use `onTestRunStart` instead
1519
- */
1520
- onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable$1<void>;
1521
- /**
1522
- * @deprecated use `onTestModuleCollected` instead
1523
- */
1524
- onCollected?: (files: File[]) => Awaitable$1<void>;
1525
- /**
1526
- * @deprecated use `onTestRunEnd` instead
1527
- */
1528
- onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable$1<void>;
1529
- /**
1530
- * @deprecated use `onTestModuleQueued`, `onTestModuleStart`, `onTestModuleEnd`, `onTestCaseReady`, `onTestCaseResult` instead
1531
- */
1532
- onTaskUpdate?: (packs: TaskResultPack[], events: TaskEventPack[]) => Awaitable$1<void>;
1533
1515
  onTestRemoved?: (trigger?: string) => Awaitable$1<void>;
1534
1516
  onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable$1<void>;
1535
1517
  onWatcherRerun?: (files: string[], trigger?: string) => Awaitable$1<void>;
@@ -1614,7 +1596,7 @@ declare abstract class BaseReporter implements Reporter {
1614
1596
  log(...messages: any): void;
1615
1597
  error(...messages: any): void;
1616
1598
  relative(path: string): string;
1617
- onFinished(files?: File[], errors?: unknown[]): void;
1599
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): void;
1618
1600
  onTestCaseResult(testCase: TestCase): void;
1619
1601
  onTestSuiteResult(testSuite: TestSuite): void;
1620
1602
  onTestModuleEnd(testModule: TestModule): void;
@@ -1650,6 +1632,7 @@ declare class DefaultReporter extends BaseReporter {
1650
1632
  private summary?;
1651
1633
  constructor(options?: DefaultReporterOptions);
1652
1634
  onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
1635
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
1653
1636
  onTestModuleQueued(file: TestModule): void;
1654
1637
  onTestModuleCollected(module: TestModule): void;
1655
1638
  onTestModuleEnd(module: TestModule): void;
@@ -1658,7 +1641,6 @@ declare class DefaultReporter extends BaseReporter {
1658
1641
  onHookStart(hook: ReportedHookContext): void;
1659
1642
  onHookEnd(hook: ReportedHookContext): void;
1660
1643
  onInit(ctx: Vitest): void;
1661
- onTestRunEnd(): void;
1662
1644
  }
1663
1645
 
1664
1646
  interface HTMLOptions {
@@ -1819,10 +1801,11 @@ declare class JsonReporter implements Reporter {
1819
1801
  start: number;
1820
1802
  ctx: Vitest;
1821
1803
  options: JsonOptions$1;
1804
+ coverageMap?: CoverageMap;
1822
1805
  constructor(options: JsonOptions$1);
1823
1806
  onInit(ctx: Vitest): void;
1824
- protected logTasks(files: File[], coverageMap?: CoverageMap | null): Promise<void>;
1825
- onFinished(files?: File[], _errors?: unknown[], coverageMap?: unknown): Promise<void>;
1807
+ onCoverage(coverageMap: unknown): void;
1808
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
1826
1809
  /**
1827
1810
  * Writes the report to an output file if specified in the config,
1828
1811
  * or logs it to the console otherwise.
@@ -1866,7 +1849,7 @@ declare class JUnitReporter implements Reporter {
1866
1849
  writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
1867
1850
  writeLogs(task: Task, type: "err" | "out"): Promise<void>;
1868
1851
  writeTasks(tasks: Task[], filename: string): Promise<void>;
1869
- onFinished(files?: File[]): Promise<void>;
1852
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
1870
1853
  }
1871
1854
 
1872
1855
  declare class DotReporter extends BaseReporter {
@@ -1877,7 +1860,7 @@ declare class DotReporter extends BaseReporter {
1877
1860
  // Ignore default logging of base reporter
1878
1861
  printTestModule(): void;
1879
1862
  onWatcherRerun(files: string[], trigger?: string): void;
1880
- onFinished(files?: File[], errors?: unknown[]): void;
1863
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
1881
1864
  onTestModuleCollected(module: TestModule): void;
1882
1865
  onTestCaseReady(test: TestCase): void;
1883
1866
  onTestCaseResult(test: TestCase): void;
@@ -1894,7 +1877,7 @@ declare class GithubActionsReporter implements Reporter {
1894
1877
  constructor(options?: GithubActionsReporterOptions);
1895
1878
  onInit(ctx: Vitest): void;
1896
1879
  onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void;
1897
- onFinished(files?: File[], errors?: unknown[]): void;
1880
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): void;
1898
1881
  }
1899
1882
 
1900
1883
  declare class HangingProcessReporter implements Reporter {
@@ -1910,12 +1893,12 @@ declare class TapReporter implements Reporter {
1910
1893
  static getComment(task: Task): string;
1911
1894
  private logErrorDetails;
1912
1895
  protected logTasks(tasks: Task[]): void;
1913
- onFinished(files?: File[]): void;
1896
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
1914
1897
  }
1915
1898
 
1916
1899
  declare class TapFlatReporter extends TapReporter {
1917
1900
  onInit(ctx: Vitest): void;
1918
- onFinished(files?: File[]): void;
1901
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
1919
1902
  }
1920
1903
 
1921
1904
  declare class VerboseReporter extends DefaultReporter {
@@ -1950,7 +1933,7 @@ declare class BenchmarkReporter extends DefaultReporter {
1950
1933
  onTestSuiteResult(testSuite: TestSuite): void;
1951
1934
  protected printTestModule(testModule: TestModule): void;
1952
1935
  private printSuiteTable;
1953
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
1936
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): Promise<void>;
1954
1937
  }
1955
1938
 
1956
1939
  declare class VerboseBenchmarkReporter extends BenchmarkReporter {
@@ -2413,31 +2396,11 @@ interface SequenceOptions {
2413
2396
  type DepsOptimizationOptions = Omit<DepOptimizationConfig, "disabled" | "noDiscovery"> & {
2414
2397
  enabled?: boolean;
2415
2398
  };
2416
- interface TransformModePatterns {
2417
- /**
2418
- * Use SSR transform pipeline for all modules inside specified tests.
2419
- * Vite plugins will receive `ssr: true` flag when processing those files.
2420
- *
2421
- * @default tests with node or edge environment
2422
- */
2423
- ssr?: string[];
2424
- /**
2425
- * First do a normal transform pipeline (targeting browser),
2426
- * then then do a SSR rewrite to run the code in Node.
2427
- * Vite plugins will receive `ssr: false` flag when processing those files.
2428
- *
2429
- * @default tests with jsdom or happy-dom environment
2430
- */
2431
- web?: string[];
2432
- }
2433
2399
  interface DepsOptions {
2434
2400
  /**
2435
2401
  * Enable dependency optimization. This can improve the performance of your tests.
2436
2402
  */
2437
- optimizer?: {
2438
- web?: DepsOptimizationOptions;
2439
- ssr?: DepsOptimizationOptions;
2440
- };
2403
+ optimizer?: Partial<Record<"client" | "ssr" | ({} & string), DepsOptimizationOptions>>;
2441
2404
  web?: {
2442
2405
  /**
2443
2406
  * Should Vitest process assets (.png, .svg, .jpg, etc) files and resolve them like Vite does in the browser.
@@ -2471,43 +2434,12 @@ interface DepsOptions {
2471
2434
  transformGlobPattern?: RegExp | RegExp[];
2472
2435
  };
2473
2436
  /**
2474
- * Externalize means that Vite will bypass the package to native Node.
2475
- *
2476
- * Externalized dependencies will not be applied Vite's transformers and resolvers.
2477
- * And does not support HMR on reload.
2478
- *
2479
- * Typically, packages under `node_modules` are externalized.
2480
- *
2481
- * @deprecated If you rely on vite-node directly, use `server.deps.external` instead. Otherwise, consider using `deps.optimizer.{web,ssr}.exclude`.
2482
- */
2483
- external?: (string | RegExp)[];
2484
- /**
2485
- * Vite will process inlined modules.
2486
- *
2487
- * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
2488
- *
2489
- * If `true`, every dependency will be inlined
2490
- *
2491
- * @deprecated If you rely on vite-node directly, use `server.deps.inline` instead. Otherwise, consider using `deps.optimizer.{web,ssr}.include`.
2492
- */
2493
- inline?: (string | RegExp)[] | true;
2494
- /**
2495
2437
  * Interpret CJS module's default as named exports
2496
2438
  *
2497
2439
  * @default true
2498
2440
  */
2499
2441
  interopDefault?: boolean;
2500
2442
  /**
2501
- * When a dependency is a valid ESM package, try to guess the cjs version based on the path.
2502
- * This will significantly improve the performance in huge repo, but might potentially
2503
- * cause some misalignment if a package have different logic in ESM and CJS mode.
2504
- *
2505
- * @default false
2506
- *
2507
- * @deprecated Use `server.deps.fallbackCJS` instead.
2508
- */
2509
- fallbackCJS?: boolean;
2510
- /**
2511
2443
  * A list of directories relative to the config file that should be treated as module directories.
2512
2444
  *
2513
2445
  * @default ['node_modules']
@@ -2554,10 +2486,9 @@ interface InlineConfig {
2554
2486
  *
2555
2487
  */
2556
2488
  deps?: DepsOptions;
2557
- /**
2558
- * Vite-node server options
2559
- */
2560
- server?: Omit<ViteNodeServerOptions, "transformMode">;
2489
+ server?: {
2490
+ deps?: ServerDepsOptions;
2491
+ };
2561
2492
  /**
2562
2493
  * Base directory to scan for the test files
2563
2494
  *
@@ -2694,7 +2625,7 @@ interface InlineConfig {
2694
2625
  */
2695
2626
  globalSetup?: string | string[];
2696
2627
  /**
2697
- * Glob patter of file paths that will trigger the whole suite rerun
2628
+ * Glob pattern of file paths that will trigger the whole suite rerun
2698
2629
  *
2699
2630
  * Useful if you are testing calling CLI commands
2700
2631
  *
@@ -2773,10 +2704,6 @@ interface InlineConfig {
2773
2704
  */
2774
2705
  uiBase?: string;
2775
2706
  /**
2776
- * Determine the transform method for all modules imported inside a test that matches the glob pattern.
2777
- */
2778
- testTransformMode?: TransformModePatterns;
2779
- /**
2780
2707
  * Format options for snapshot testing.
2781
2708
  */
2782
2709
  snapshotFormat?: Omit<PrettyFormatOptions, "plugins" | "compareKeys"> & {
@@ -3194,6 +3121,30 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3194
3121
  minWorkers: number;
3195
3122
  }
3196
3123
  type NonProjectOptions = "shard" | "watch" | "run" | "cache" | "update" | "reporters" | "outputFile" | "teardownTimeout" | "silent" | "forceRerunTriggers" | "testNamePattern" | "ui" | "open" | "uiBase" | "snapshotFormat" | "resolveSnapshotPath" | "passWithNoTests" | "onConsoleLog" | "onStackTrace" | "dangerouslyIgnoreUnhandledErrors" | "slowTestThreshold" | "inspect" | "inspectBrk" | "coverage" | "maxWorkers" | "minWorkers" | "fileParallelism" | "watchTriggerPatterns";
3124
+ interface ServerDepsOptions {
3125
+ /**
3126
+ * Externalize means that Vite will bpass the package to native Node.
3127
+ *
3128
+ * Externalized dependencies will not be applied Vite's transformers and resolvers.
3129
+ * And does not support HMR on reload.
3130
+ *
3131
+ * Typically, packages under `node_modules` are externalized.
3132
+ */
3133
+ external?: (string | RegExp)[];
3134
+ /**
3135
+ * Vite will process inlined modules.
3136
+ *
3137
+ * This could be helpful to handle packages that ship `.js` in ESM format (that Node can't handle).
3138
+ *
3139
+ * If `true`, every dependency will be inlined
3140
+ */
3141
+ inline?: (string | RegExp)[] | true;
3142
+ /**
3143
+ * Try to guess the CJS version of a package when it's invalid ESM
3144
+ * @default false
3145
+ */
3146
+ fallbackCJS?: boolean;
3147
+ }
3197
3148
  type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
3198
3149
  mode?: string;
3199
3150
  sequencer?: Omit<SequenceOptions, "sequencer" | "seed">;
@@ -3221,5 +3172,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3221
3172
  });
3222
3173
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3223
3174
 
3224
- export { CoverageMap as C, TestSuite as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as aB, BenchmarkReportsMap as aC, DefaultReporter as aD, DotReporter as aE, GithubActionsReporter as aF, HangingProcessReporter as aG, JsonReporter as aH, JUnitReporter as aI, ReportersMap as aJ, TapFlatReporter as aK, TapReporter as aL, VerboseBenchmarkReporter as aM, VerboseReporter as aN, BaseReporter as aO, TestSpecification as l, VitestPackageInstaller as n, getFilePoolName as p, TestCase as s, TestCollection as t, TestModule as v };
3225
- export type { BrowserOrchestrator as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, TestSequencerConstructor as G, HTMLOptions as H, InlineConfig as I, JsonOptions$1 as J, BenchmarkUserOptions as K, ModuleDiagnostic as M, BrowserBuiltinProvider as N, OnServerRestartHandler as O, ProcessPool as P, BrowserCommand as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommandContext as X, BrowserConfigOptions as Y, BrowserInstanceOption as Z, BrowserModuleMocker as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderInitializationOptions as a1, BrowserProviderModule as a2, BrowserProviderOptions as a3, BrowserScript as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9, TestRunEndReason as aA, BenchmarkBuiltinReporters as aP, BuiltinReporterOptions as aQ, BuiltinReporters as aR, JsonAssertionResult as aS, JsonTestResult as aT, JsonTestResults as aU, ResolvedBrowserOptions as aa, ToMatchScreenshotComparators as ab, ToMatchScreenshotOptions as ac, BuiltinEnvironment as ad, CSSModuleScopeStrategy as ae, DepsOptimizationOptions as af, EnvironmentOptions as ag, Pool as ah, PoolOptions as ai, ProjectConfig as aj, ResolvedProjectConfig as ak, ResolveSnapshotPathHandler as al, ResolveSnapshotPathHandlerContext as am, TransformModePatterns as an, TypecheckConfig as ao, VitestEnvironment as ap, BaseCoverageOptions as aq, CoverageIstanbulOptions as ar, CoverageOptions as as, CoverageProvider as at, CoverageProviderModule as au, CoverageReporter as av, CustomProviderOptions as aw, TestRunResult as ax, ReportedHookContext as ay, Reporter as az, ReportContext as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, TestSequencer as k, OnTestsRerunHandler as m, WorkspaceSpec as o, JUnitOptions as q, TaskOptions as r, TestDiagnostic as u, TestModuleState as w, TestResult as x, TestResultFailed as y, TestResultPassed as z };
3175
+ export { CoverageMap as C, TestSuite as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReporter as aA, BenchmarkReportsMap as aB, DefaultReporter as aC, DotReporter as aD, GithubActionsReporter as aE, HangingProcessReporter as aF, JsonReporter as aG, JUnitReporter as aH, ReportersMap as aI, TapFlatReporter as aJ, TapReporter as aK, VerboseBenchmarkReporter as aL, VerboseReporter as aM, BaseReporter as aN, TestSpecification as l, VitestPackageInstaller as n, getFilePoolName as p, TestCase as s, TestCollection as t, TestModule as v };
3176
+ export type { BrowserOrchestrator as $, ApiConfig as A, TestResultSkipped as B, TestState as D, TestSuiteState as F, TestSequencerConstructor as G, HTMLOptions as H, InlineConfig as I, JsonOptions$1 as J, BenchmarkUserOptions as K, ModuleDiagnostic as M, BrowserBuiltinProvider as N, OnServerRestartHandler as O, ProcessPool as P, BrowserCommand as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserCommandContext as X, BrowserConfigOptions as Y, BrowserInstanceOption as Z, BrowserModuleMocker as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderInitializationOptions as a1, BrowserProviderModule as a2, BrowserProviderOptions as a3, BrowserScript as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9, BenchmarkBuiltinReporters as aO, BuiltinReporterOptions as aP, BuiltinReporters as aQ, JsonAssertionResult as aR, JsonTestResult as aS, JsonTestResults as aT, ResolvedBrowserOptions as aa, ToMatchScreenshotComparators as ab, ToMatchScreenshotOptions as ac, BuiltinEnvironment as ad, CSSModuleScopeStrategy as ae, DepsOptimizationOptions as af, EnvironmentOptions as ag, Pool as ah, PoolOptions as ai, ProjectConfig as aj, ResolvedProjectConfig as ak, ResolveSnapshotPathHandler as al, ResolveSnapshotPathHandlerContext as am, TypecheckConfig as an, VitestEnvironment as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageOptions as ar, CoverageProvider as as, CoverageProviderModule as at, CoverageReporter as au, CustomProviderOptions as av, TestRunResult as aw, ReportedHookContext as ax, Reporter as ay, TestRunEndReason as az, ReportContext as b, CoverageV8Options as c, UserProjectConfigFn as d, UserProjectConfigExport as e, UserConfig as f, TestProjectInlineConfiguration as g, ResolvedConfig as h, VitestRunMode as i, VitestOptions as j, TestSequencer as k, OnTestsRerunHandler as m, WorkspaceSpec as o, JUnitOptions as q, TaskOptions as r, TestDiagnostic as u, TestModuleState as w, TestResult as x, TestResultFailed as y, TestResultPassed as z };