vitest 4.0.0-beta.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE.md +86 -102
  2. package/browser/context.d.ts +7 -0
  3. package/browser/context.js +20 -0
  4. package/dist/browser.d.ts +26 -9
  5. package/dist/browser.js +17 -7
  6. package/dist/chunks/base.CtHM3ryk.js +128 -0
  7. package/dist/chunks/{benchmark.UW6Ezvxy.js → benchmark.DHKMYAts.js} +2 -2
  8. package/dist/chunks/{browser.d.DOMmqJQx.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
  9. package/dist/chunks/{cac.By1HvRIk.js → cac.B99MQg-w.js} +47 -91
  10. package/dist/chunks/{cli-api.C-JHgQgp.js → cli-api.PwHwIMss.js} +1544 -310
  11. package/dist/chunks/{config.d._GBBbReY.d.ts → config.d.u2CUDWwS.d.ts} +6 -19
  12. package/dist/chunks/{console.B0quX7yH.js → console.CTJL2nuH.js} +4 -6
  13. package/dist/chunks/{coverage.DarITf6U.js → coverage.FU3w4IrQ.js} +128 -1142
  14. package/dist/chunks/{creator.KEg6n5IC.js → creator.DucAaYBz.js} +10 -37
  15. package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
  16. package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
  17. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  18. package/dist/chunks/{global.d.K6uBQHzY.d.ts → global.d.BgJSTpgQ.d.ts} +2 -17
  19. package/dist/chunks/{globals.lgsmH00r.js → globals.BGT_RUsD.js} +12 -9
  20. package/dist/chunks/{index.BuwjkI-q.js → index.BdSLhLDZ.js} +3 -3
  21. package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
  22. package/dist/chunks/{index.AzwzFtyi.js → index.CcRZ6fUh.js} +1493 -114
  23. package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
  24. package/dist/chunks/{index.AR8aAkCC.js → index.RwjEGCQ0.js} +7 -8
  25. package/dist/chunks/init-forks.DSafeltJ.js +54 -0
  26. package/dist/chunks/init-threads.SUtZ-067.js +17 -0
  27. package/dist/chunks/init.B2EESLQM.js +213 -0
  28. package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
  29. package/dist/chunks/{moduleRunner.d.CX4DuqOx.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +12 -14
  30. package/dist/chunks/{node.BOqcT2jW.js → node.BwAWWjHZ.js} +3 -4
  31. package/dist/chunks/{plugin.d.CHe6slQs.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
  32. package/dist/chunks/{reporters.d.37tJQ2uV.d.ts → reporters.d.BMKt7f6I.d.ts} +1066 -1030
  33. package/dist/chunks/{index.CsFXYRkW.js → resolveSnapshotEnvironment.DJJKMKxb.js} +18 -24
  34. package/dist/chunks/{rpc.RpPylpp0.js → rpc.cD77ENhU.js} +13 -14
  35. package/dist/chunks/{setup-common.hLGRxhC8.js → setup-common.DR1sucx6.js} +8 -8
  36. package/dist/chunks/{startModuleRunner.C8TW8zTN.js → startModuleRunner.C2tTvmF9.js} +131 -110
  37. package/dist/chunks/test.C3RPt8JR.js +214 -0
  38. package/dist/chunks/{utils.C7__0Iv5.js → utils.CG9h5ccR.js} +3 -15
  39. package/dist/chunks/{vi.BfdOiD4j.js → vi.BZvkKVkM.js} +73 -176
  40. package/dist/chunks/{vm.BHBje7cC.js → vm.DBeOXrP9.js} +29 -33
  41. package/dist/chunks/{worker.d.DYlqbejz.d.ts → worker.d.BFk-vvBU.d.ts} +42 -6
  42. package/dist/cli.js +12 -11
  43. package/dist/config.cjs +0 -1
  44. package/dist/config.d.ts +12 -14
  45. package/dist/config.js +1 -1
  46. package/dist/coverage.d.ts +8 -7
  47. package/dist/coverage.js +3 -14
  48. package/dist/environments.d.ts +3 -6
  49. package/dist/environments.js +1 -1
  50. package/dist/index.d.ts +24 -30
  51. package/dist/index.js +12 -11
  52. package/dist/module-evaluator.d.ts +6 -4
  53. package/dist/module-evaluator.js +14 -16
  54. package/dist/module-runner.js +5 -5
  55. package/dist/node.d.ts +83 -27
  56. package/dist/node.js +23 -20
  57. package/dist/reporters.d.ts +11 -10
  58. package/dist/reporters.js +12 -11
  59. package/dist/runners.d.ts +1 -1
  60. package/dist/runners.js +14 -216
  61. package/dist/snapshot.js +3 -3
  62. package/dist/suite.js +4 -3
  63. package/dist/worker.d.ts +26 -0
  64. package/dist/worker.js +45 -166
  65. package/dist/workers/forks.js +41 -35
  66. package/dist/workers/runVmTests.js +25 -22
  67. package/dist/workers/threads.js +41 -23
  68. package/dist/workers/vmForks.js +26 -39
  69. package/dist/workers/vmThreads.js +26 -29
  70. package/package.json +48 -35
  71. package/worker.d.ts +1 -0
  72. package/browser.d.ts +0 -1
  73. package/dist/chunks/base.BXI97p6t.js +0 -39
  74. package/dist/chunks/environment.d.2fYMoz3o.d.ts +0 -66
  75. package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
  76. package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
  77. package/dist/chunks/runBaseTests.D6sfuWBM.js +0 -99
  78. package/dist/chunks/typechecker.DSo_maXz.js +0 -762
  79. package/dist/chunks/utils.C2YI6McM.js +0 -52
  80. package/dist/chunks/worker.d.BKu8cnnX.d.ts +0 -8
  81. package/dist/workers.d.ts +0 -38
  82. package/dist/workers.js +0 -31
  83. package/execute.d.ts +0 -1
  84. package/utils.d.ts +0 -1
  85. package/workers.d.ts +0 -1
@@ -1,16 +1,17 @@
1
- import { CancelReason, TaskMeta, Suite, File, TestAnnotation, ImportDuration, Test, Task, TaskResultPack, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
- import { Awaitable, ParsedStack, TestError, SerializedError, Arrayable as Arrayable$1 } from '@vitest/utils';
3
- import { P as ProvidedContext, c as Arrayable, A as AfterSuiteRunMeta, U as UserConsoleLog, b as Awaitable$1, L as LabelColor } from './environment.d.2fYMoz3o.js';
1
+ import { TaskMeta, Suite, File, TestAnnotation, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks } from '@vitest/runner';
2
+ import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
+ import { A as AfterSuiteRunMeta, U as UserConsoleLog, P as ProvidedContext, C as ContextRPC, L as LabelColor } from './worker.d.BFk-vvBU.js';
4
4
  import { Writable } from 'node:stream';
5
- import { ViteDevServer, TransformResult as TransformResult$1, DepOptimizationConfig, ServerOptions, UserConfig as UserConfig$1, ConfigEnv, AliasOptions } from 'vite';
5
+ import { TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
6
  import { MockedModule } from '@vitest/mocker';
7
7
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
- import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.DOMmqJQx.js';
9
- import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d._GBBbReY.js';
8
+ import { BrowserCommands } from 'vitest/browser';
9
+ import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.u2CUDWwS.js';
10
+ import { S as SerializedTestSpecification, B as BrowserTesterOptions } from './browser.d.B9iJzZyn.js';
10
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
11
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
12
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
13
- import * as chai from 'chai';
14
+ import { chai } from '@vitest/expect';
14
15
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
15
16
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
16
17
  import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
@@ -69,477 +70,323 @@ interface ConstructorOptionsOverride {
69
70
  resources?: "usable";
70
71
  }
71
72
 
72
- interface BrowserProviderInitializationOptions {
73
- browser: string;
74
- options?: BrowserProviderOptions;
75
- }
76
- interface CDPSession {
77
- send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
78
- on: (event: string, listener: (...args: unknown[]) => void) => void;
79
- once: (event: string, listener: (...args: unknown[]) => void) => void;
80
- off: (event: string, listener: (...args: unknown[]) => void) => void;
81
- }
82
- interface BrowserModuleMocker {
83
- register: (sessionId: string, module: MockedModule) => Promise<void>;
84
- delete: (sessionId: string, url: string) => Promise<void>;
85
- clear: (sessionId: string) => Promise<void>;
86
- }
87
- interface BrowserProvider {
88
- name: string;
89
- mocker?: BrowserModuleMocker;
73
+ declare class ReportedTaskImplementation {
90
74
  /**
91
- * @experimental opt-in into file parallelisation
75
+ * The project associated with the test or suite.
92
76
  */
93
- supportsParallelism: boolean;
94
- getSupportedBrowsers: () => readonly string[];
95
- getCommandsContext: (sessionId: string) => Record<string, unknown>;
96
- openPage: (sessionId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
97
- getCDPSession?: (sessionId: string) => Promise<CDPSession>;
98
- close: () => Awaitable<void>;
99
- // eslint-disable-next-line ts/method-signature-style -- we want to allow extended options
100
- initialize(ctx: TestProject, options: BrowserProviderInitializationOptions): Awaitable<void>;
101
- }
102
- interface BrowserProviderModule {
103
- new (): BrowserProvider;
104
- }
105
- interface BrowserProviderOptions {}
106
- type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
107
- type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
108
- interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
77
+ readonly project: TestProject;
109
78
  /**
110
- * Name of the browser
79
+ * Unique identifier.
80
+ * This ID is deterministic and will be the same for the same test across multiple runs.
81
+ * The ID is based on the project name, module url and test order.
111
82
  */
112
- browser: string;
113
- name?: string;
114
- }
115
- interface BrowserConfigOptions {
83
+ readonly id: string;
116
84
  /**
117
- * if running tests in the browser should be the default
118
- *
119
- * @default false
85
+ * Location in the module where the test or suite is defined.
120
86
  */
121
- enabled?: boolean;
87
+ readonly location: {
88
+ line: number;
89
+ column: number;
90
+ } | undefined;
122
91
  /**
123
- * Name of the browser
124
- * @deprecated use `instances` instead. if both are defined, this will filter `instances` by name.
92
+ * Checks if the test did not fail the suite.
93
+ * If the test is not finished yet or was skipped, it will return `true`.
125
94
  */
126
- name?: string;
95
+ ok(): boolean;
127
96
  /**
128
- * Configurations for different browser setups
97
+ * Custom metadata that was attached to the test during its execution.
129
98
  */
130
- instances?: BrowserInstanceOption[];
99
+ meta(): TaskMeta;
100
+ }
101
+ declare class TestCase extends ReportedTaskImplementation {
102
+ #private;
103
+ readonly type = "test";
131
104
  /**
132
- * Browser provider
133
- *
134
- * @default 'preview'
105
+ * Direct reference to the test module where the test or suite is defined.
135
106
  */
136
- provider?: BrowserBuiltinProvider | (string & {});
107
+ readonly module: TestModule;
137
108
  /**
138
- * Options that are passed down to a browser provider.
139
- * To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
140
- *
141
- * - for webdriverio: `@vitest/browser/providers/webdriverio`
142
- * - for playwright: `@vitest/browser/providers/playwright`
143
- *
144
- * @example
145
- * { playwright: { launch: { devtools: true } }
146
- * @deprecated use `instances` instead
109
+ * Name of the test.
147
110
  */
148
- providerOptions?: BrowserProviderOptions;
111
+ readonly name: string;
149
112
  /**
150
- * enable headless mode
151
- *
152
- * @default process.env.CI
113
+ * Options that the test was initiated with.
153
114
  */
154
- headless?: boolean;
115
+ readonly options: TaskOptions;
155
116
  /**
156
- * Serve API options.
157
- *
158
- * The default port is 63315.
117
+ * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
159
118
  */
160
- api?: ApiConfig | number;
119
+ readonly parent: TestSuite | TestModule;
161
120
  /**
162
- * Isolate test environment after each test
163
- *
164
- * @default true
121
+ * Full name of the test including all parent suites separated with `>`.
165
122
  */
166
- isolate?: boolean;
123
+ get fullName(): string;
167
124
  /**
168
- * Run test files in parallel if provider supports this option
169
- * This option only has effect in headless mode (enabled in CI by default)
170
- *
171
- * @default // Same as "test.fileParallelism"
125
+ * Test results.
126
+ * - **pending**: Test was collected, but didn't finish running yet.
127
+ * - **passed**: Test passed successfully
128
+ * - **failed**: Test failed to execute
129
+ * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
172
130
  */
173
- fileParallelism?: boolean;
131
+ result(): TestResult;
174
132
  /**
175
- * Show Vitest UI
176
- *
177
- * @default !process.env.CI
133
+ * Test annotations added via the `task.annotate` API during the test execution.
178
134
  */
179
- ui?: boolean;
135
+ annotations(): ReadonlyArray<TestAnnotation>;
180
136
  /**
181
- * Default viewport size
137
+ * Useful information about the test like duration, memory usage, etc.
138
+ * Diagnostic is only available after the test has finished.
182
139
  */
183
- viewport?: {
184
- /**
185
- * Width of the viewport
186
- * @default 414
187
- */
188
- width: number;
189
- /**
190
- * Height of the viewport
191
- * @default 896
192
- */
193
- height: number;
194
- };
140
+ diagnostic(): TestDiagnostic | undefined;
141
+ }
142
+ declare class TestCollection {
143
+ #private;
144
+ constructor(task: Suite | File, project: TestProject);
195
145
  /**
196
- * Locator options
146
+ * Returns the test or suite at a specific index.
197
147
  */
198
- locators?: {
199
- /**
200
- * Attribute used to locate elements by test id
201
- * @default 'data-testid'
202
- */
203
- testIdAttribute?: string;
204
- };
148
+ at(index: number): TestCase | TestSuite | undefined;
205
149
  /**
206
- * Directory where screenshots will be saved when page.screenshot() is called
207
- * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
208
- * If this is set, it will be resolved relative to the project root.
209
- * @default __screenshots__
150
+ * The number of tests and suites in the collection.
210
151
  */
211
- screenshotDirectory?: string;
152
+ get size(): number;
212
153
  /**
213
- * Should Vitest take screenshots if the test fails
214
- * @default !browser.ui
154
+ * Returns the collection in array form for easier manipulation.
215
155
  */
216
- screenshotFailures?: boolean;
156
+ array(): (TestCase | TestSuite)[];
217
157
  /**
218
- * Path to the index.html file that will be used to run tests.
158
+ * Filters all tests that are part of this collection and its children.
219
159
  */
220
- testerHtmlPath?: string;
160
+ allTests(state?: TestState): Generator<TestCase, undefined, void>;
221
161
  /**
222
- * Scripts injected into the main window.
162
+ * Filters only the tests that are part of this collection.
223
163
  */
224
- orchestratorScripts?: BrowserScript[];
164
+ tests(state?: TestState): Generator<TestCase, undefined, void>;
225
165
  /**
226
- * Commands that will be executed on the server
227
- * via the browser `import("@vitest/browser/context").commands` API.
228
- * @see {@link https://vitest.dev/guide/browser/commands}
166
+ * Filters only the suites that are part of this collection.
229
167
  */
230
- commands?: Record<string, BrowserCommand<any>>;
168
+ suites(): Generator<TestSuite, undefined, void>;
231
169
  /**
232
- * Timeout for connecting to the browser
233
- * @default 30000
170
+ * Filters all suites that are part of this collection and its children.
234
171
  */
235
- connectTimeout?: number;
236
- expect?: {
237
- toMatchScreenshot?: { [ComparatorName in keyof ToMatchScreenshotComparators] : {
238
- /**
239
- * The name of the comparator to use for visual diffing.
240
- *
241
- * @defaultValue `'pixelmatch'`
242
- */
243
- comparatorName?: ComparatorName;
244
- comparatorOptions?: ToMatchScreenshotComparators[ComparatorName];
245
- } }[keyof ToMatchScreenshotComparators] & ToMatchScreenshotOptions;
246
- };
172
+ allSuites(): Generator<TestSuite, undefined, void>;
173
+ [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
174
+ }
175
+
176
+ type ReportedHookContext = {
177
+ readonly name: "beforeAll" | "afterAll";
178
+ readonly entity: TestSuite | TestModule;
179
+ } | {
180
+ readonly name: "beforeEach" | "afterEach";
181
+ readonly entity: TestCase;
182
+ };
183
+ declare abstract class SuiteImplementation extends ReportedTaskImplementation {
247
184
  /**
248
- * Enables tracking uncaught errors and exceptions so they can be reported by Vitest.
249
- *
250
- * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/#onunhandlederror) option instead.
251
- *
252
- * Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on.
253
- * @default true
185
+ * Collection of suites and tests that are part of this suite.
254
186
  */
255
- trackUnhandledErrors?: boolean;
256
- }
257
- interface BrowserCommandContext {
258
- testPath: string | undefined;
259
- provider: BrowserProvider;
260
- project: TestProject;
261
- sessionId: string;
262
- }
263
- interface BrowserServerStateSession {
264
- project: TestProject;
265
- connected: () => void;
266
- fail: (v: Error) => void;
267
- }
268
- interface BrowserOrchestrator {
269
- cleanupTesters: () => Promise<void>;
270
- createTesters: (options: BrowserTesterOptions) => Promise<void>;
271
- onCancel: (reason: CancelReason) => Promise<void>;
272
- $close: () => void;
273
- }
274
- interface BrowserServerState {
275
- orchestrators: Map<string, BrowserOrchestrator>;
276
- }
277
- interface ParentProjectBrowser {
278
- spawn: (project: TestProject) => ProjectBrowser;
279
- }
280
- interface ProjectBrowser {
281
- vite: ViteDevServer;
282
- state: BrowserServerState;
283
- provider: BrowserProvider;
284
- close: () => Promise<void>;
285
- initBrowserProvider: (project: TestProject) => Promise<void>;
286
- parseStacktrace: (stack: string) => ParsedStack[];
287
- parseErrorStacktrace: (error: TestError, options?: StackTraceParserOptions) => ParsedStack[];
288
- }
289
- interface BrowserCommand<Payload extends unknown[]> {
290
- (context: BrowserCommandContext, ...payload: Payload): Awaitable<any>;
291
- }
292
- interface BrowserScript {
187
+ readonly children: TestCollection;
293
188
  /**
294
- * If "content" is provided and type is "module", this will be its identifier.
295
- *
296
- * If you are using TypeScript, you can add `.ts` extension here for example.
297
- * @default `injected-${index}.js`
189
+ * Errors that happened outside of the test run during collection, like syntax errors.
298
190
  */
299
- id?: string;
191
+ errors(): SerializedError[];
192
+ }
193
+ declare class TestSuite extends SuiteImplementation {
194
+ #private;
195
+ readonly type = "suite";
300
196
  /**
301
- * JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
302
- *
303
- * You can use `id` to give Vite a hint about the file extension.
197
+ * Name of the test or the suite.
304
198
  */
305
- content?: string;
199
+ readonly name: string;
306
200
  /**
307
- * Path to the script. This value is resolved by Vite so it can be a node module or a file path.
201
+ * Direct reference to the test module where the test or suite is defined.
308
202
  */
309
- src?: string;
203
+ readonly module: TestModule;
310
204
  /**
311
- * If the script should be loaded asynchronously.
205
+ * Parent suite. If suite was called directly inside the module, the parent will be the module itself.
312
206
  */
313
- async?: boolean;
207
+ readonly parent: TestSuite | TestModule;
314
208
  /**
315
- * Script type.
316
- * @default 'module'
209
+ * Options that suite was initiated with.
317
210
  */
318
- type?: string;
319
- }
320
- interface ResolvedBrowserOptions extends BrowserConfigOptions {
321
- name: string;
322
- providerOptions?: BrowserProviderOptions;
323
- enabled: boolean;
324
- headless: boolean;
325
- isolate: boolean;
326
- fileParallelism: boolean;
327
- api: ApiConfig;
328
- ui: boolean;
329
- viewport: {
330
- width: number;
331
- height: number;
332
- };
333
- screenshotFailures: boolean;
334
- locators: {
335
- testIdAttribute: string;
336
- };
337
- }
338
- type ToMatchScreenshotResolvePath = (data: {
211
+ readonly options: TaskOptions;
339
212
  /**
340
- * Path **without** extension, sanitized and relative to the test file.
341
- *
342
- * This comes from the arguments passed to `toMatchScreenshot`; if called
343
- * without arguments this will be the auto-generated name.
344
- *
345
- * @example
346
- * test('calls `onClick`', () => {
347
- * expect(locator).toMatchScreenshot()
348
- * // arg = "calls-onclick-1"
349
- * })
350
- *
351
- * @example
352
- * expect(locator).toMatchScreenshot('foo/bar/baz.png')
353
- * // arg = "foo/bar/baz"
354
- *
355
- * @example
356
- * expect(locator).toMatchScreenshot('../foo/bar/baz.png')
357
- * // arg = "foo/bar/baz"
213
+ * Checks if the suite has any failed tests.
214
+ * This will also return `false` if suite failed during collection.
358
215
  */
359
- arg: string;
216
+ ok: () => boolean;
360
217
  /**
361
- * Screenshot extension, with leading dot.
362
- *
363
- * This can be set through the arguments passed to `toMatchScreenshot`, but
364
- * the value will fall back to `'.png'` if an unsupported extension is used.
218
+ * The meta information attached to the suite during its collection or execution.
365
219
  */
366
- ext: string;
220
+ meta: () => TaskMeta;
367
221
  /**
368
- * The instance's browser name.
222
+ * Checks the running state of the suite.
369
223
  */
370
- browserName: string;
224
+ state(): TestSuiteState;
371
225
  /**
372
- * The value of {@linkcode process.platform}.
226
+ * Full name of the suite including all parent suites separated with `>`.
373
227
  */
374
- platform: NodeJS.Platform;
228
+ get fullName(): string;
229
+ }
230
+ declare class TestModule extends SuiteImplementation {
231
+ readonly location: undefined;
232
+ readonly type = "module";
375
233
  /**
376
- * The value provided to
377
- * {@linkcode https://vitest.dev/guide/browser/config#browser-screenshotdirectory|browser.screenshotDirectory},
378
- * if none is provided, its default value.
234
+ * This is usually an absolute UNIX file path.
235
+ * It can be a virtual ID if the file is not on the disk.
236
+ * This value corresponds to the ID in the Vite's module graph.
379
237
  */
380
- screenshotDirectory: string;
238
+ readonly moduleId: string;
381
239
  /**
382
- * Absolute path to the project's
383
- * {@linkcode https://vitest.dev/config/#root|root}.
240
+ * Module id relative to the project. This is the same as `task.name`.
384
241
  */
385
- root: string;
242
+ readonly relativeModuleId: string;
386
243
  /**
387
- * Path to the test file, relative to the project's
388
- * {@linkcode https://vitest.dev/config/#root|root}.
244
+ * Checks the running state of the test file.
389
245
  */
390
- testFileDirectory: string;
246
+ state(): TestModuleState;
391
247
  /**
392
- * The test's filename.
248
+ * Checks if the module has any failed tests.
249
+ * This will also return `false` if module failed during collection.
393
250
  */
394
- testFileName: string;
251
+ ok: () => boolean;
395
252
  /**
396
- * The {@linkcode https://vitest.dev/api/#test|test}'s name, including
397
- * parent {@linkcode https://vitest.dev/api/#describe|describe}, sanitized.
253
+ * The meta information attached to the module during its collection or execution.
398
254
  */
399
- testName: string;
255
+ meta: () => TaskMeta;
400
256
  /**
401
- * The value provided to
402
- * {@linkcode https://vitest.dev/config/#attachmentsdir|attachmentsDir},
403
- * if none is provided, its default value.
257
+ * Useful information about the module like duration, memory usage, etc.
258
+ * If the module was not executed yet, all diagnostic values will return `0`.
404
259
  */
405
- attachmentsDir: string;
406
- }) => string;
407
- interface ToMatchScreenshotOptions {
260
+ diagnostic(): ModuleDiagnostic;
261
+ }
262
+ interface TaskOptions {
263
+ readonly each: boolean | undefined;
264
+ readonly fails: boolean | undefined;
265
+ readonly concurrent: boolean | undefined;
266
+ readonly shuffle: boolean | undefined;
267
+ readonly retry: number | undefined;
268
+ readonly repeats: number | undefined;
269
+ readonly mode: "run" | "only" | "skip" | "todo";
270
+ }
271
+ type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
272
+ type TestModuleState = TestSuiteState | "queued";
273
+ type TestState = TestResult["state"];
274
+ type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
275
+ interface TestResultPending {
408
276
  /**
409
- * Overrides default reference screenshot path.
410
- *
411
- * @default `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
277
+ * The test was collected, but didn't finish running yet.
412
278
  */
413
- resolveScreenshotPath?: ToMatchScreenshotResolvePath;
279
+ readonly state: "pending";
414
280
  /**
415
- * Overrides default screenshot path used for diffs.
416
- *
417
- * @default `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
281
+ * Pending tests have no errors.
418
282
  */
419
- resolveDiffPath?: ToMatchScreenshotResolvePath;
283
+ readonly errors: undefined;
420
284
  }
421
- interface ToMatchScreenshotComparators {}
422
-
423
- type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
424
- type Pool = BuiltinPool | (string & {});
425
- interface PoolOptions extends Record<string, unknown> {
285
+ interface TestResultPassed {
426
286
  /**
427
- * Run tests in `node:worker_threads`.
428
- *
429
- * Test isolation (when enabled) is done by spawning a new thread for each test file.
430
- *
431
- * This pool is used by default.
287
+ * The test passed successfully.
432
288
  */
433
- threads?: ThreadsOptions & WorkerContextOptions;
289
+ readonly state: "passed";
434
290
  /**
435
- * Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
291
+ * Errors that were thrown during the test execution.
436
292
  *
437
- * Test isolation (when enabled) is done by spawning a new child process for each test file.
293
+ * **Note**: If test was retried successfully, errors will still be reported.
438
294
  */
439
- forks?: ForksOptions & WorkerContextOptions;
295
+ readonly errors: ReadonlyArray<TestError> | undefined;
296
+ }
297
+ interface TestResultFailed {
440
298
  /**
441
- * Run tests in isolated `node:vm`.
442
- * Test files are run parallel using `node:worker_threads`.
443
- *
444
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
299
+ * The test failed to execute.
445
300
  */
446
- vmThreads?: ThreadsOptions & VmOptions;
301
+ readonly state: "failed";
447
302
  /**
448
- * Run tests in isolated `node:vm`.
449
- *
450
- * Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
451
- *
452
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
303
+ * Errors that were thrown during the test execution.
453
304
  */
454
- vmForks?: ForksOptions & VmOptions;
455
- }
456
- interface ResolvedPoolOptions extends PoolOptions {
457
- threads?: ResolvedThreadsOptions & WorkerContextOptions;
458
- forks?: ResolvedForksOptions & WorkerContextOptions;
459
- vmThreads?: ResolvedThreadsOptions & VmOptions;
460
- vmForks?: ResolvedForksOptions & VmOptions;
305
+ readonly errors: ReadonlyArray<TestError>;
461
306
  }
462
- interface ThreadsOptions {
463
- /** Minimum amount of threads to use */
464
- minThreads?: number | string;
465
- /** Maximum amount of threads to use */
466
- maxThreads?: number | string;
307
+ interface TestResultSkipped {
467
308
  /**
468
- * Run tests inside a single thread.
469
- *
470
- * @default false
309
+ * The test was skipped with `only` (on another test), `skip` or `todo` flag.
310
+ * You can see which one was used in the `options.mode` option.
471
311
  */
472
- singleThread?: boolean;
312
+ readonly state: "skipped";
473
313
  /**
474
- * Use Atomics to synchronize threads
475
- *
476
- * This can improve performance in some cases, but might cause segfault in older Node versions.
477
- *
478
- * @default false
314
+ * Skipped tests have no errors.
479
315
  */
480
- useAtomics?: boolean;
481
- }
482
- interface ResolvedThreadsOptions extends ThreadsOptions {
483
- minThreads?: number;
484
- maxThreads?: number;
485
- }
486
- interface ForksOptions {
487
- /** Minimum amount of child processes to use */
488
- minForks?: number | string;
489
- /** Maximum amount of child processes to use */
490
- maxForks?: number | string;
316
+ readonly errors: undefined;
491
317
  /**
492
- * Run tests inside a single fork.
493
- *
494
- * @default false
318
+ * A custom note passed down to `ctx.skip(note)`.
495
319
  */
496
- singleFork?: boolean;
497
- }
498
- interface ResolvedForksOptions extends ForksOptions {
499
- minForks?: number;
500
- maxForks?: number;
320
+ readonly note: string | undefined;
501
321
  }
502
- interface WorkerContextOptions {
322
+ interface TestDiagnostic {
503
323
  /**
504
- * Isolate test environment by recycling `worker_threads` or `child_process` after each test
505
- *
506
- * @default true
324
+ * If the duration of the test is above `slowTestThreshold`.
507
325
  */
508
- isolate?: boolean;
326
+ readonly slow: boolean;
509
327
  /**
510
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
511
- *
512
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
513
- *
514
- * Set to `process.execArgv` to pass all arguments of the current process.
515
- *
516
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
517
- *
518
- * @default [] // no execution arguments are passed
328
+ * The amount of memory used by the test in bytes.
329
+ * This value is only available if the test was executed with `logHeapUsage` flag.
519
330
  */
520
- execArgv?: string[];
331
+ readonly heap: number | undefined;
332
+ /**
333
+ * The time it takes to execute the test in ms.
334
+ */
335
+ readonly duration: number;
336
+ /**
337
+ * The time in ms when the test started.
338
+ */
339
+ readonly startTime: number;
340
+ /**
341
+ * The amount of times the test was retried.
342
+ */
343
+ readonly retryCount: number;
344
+ /**
345
+ * The amount of times the test was repeated as configured by `repeats` option.
346
+ * This value can be lower if the test failed during the repeat and no `retry` is configured.
347
+ */
348
+ readonly repeatCount: number;
349
+ /**
350
+ * If test passed on a second retry.
351
+ */
352
+ readonly flaky: boolean;
521
353
  }
522
- interface VmOptions {
354
+ interface ModuleDiagnostic {
523
355
  /**
524
- * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
525
- * If you see memory leaks, try to tinker this value.
356
+ * The time it takes to import and initiate an environment.
526
357
  */
527
- memoryLimit?: string | number;
528
- /** Isolation is always enabled */
529
- isolate?: true;
358
+ readonly environmentSetupDuration: number;
530
359
  /**
531
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
532
- *
533
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
534
- *
535
- * Set to `process.execArgv` to pass all arguments of the current process.
536
- *
537
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
538
- *
539
- * @default [] // no execution arguments are passed
360
+ * The time it takes Vitest to setup test harness (runner, mocks, etc.).
540
361
  */
541
- execArgv?: string[];
362
+ readonly prepareDuration: number;
363
+ /**
364
+ * The time it takes to import the test module.
365
+ * This includes importing everything in the module and executing suite callbacks.
366
+ */
367
+ readonly collectDuration: number;
368
+ /**
369
+ * The time it takes to import the setup module.
370
+ */
371
+ readonly setupDuration: number;
372
+ /**
373
+ * Accumulated duration of all tests and hooks in the module.
374
+ */
375
+ readonly duration: number;
376
+ /**
377
+ * The amount of memory used by the test module in bytes.
378
+ * This value is only available if the test was executed with `logHeapUsage` flag.
379
+ */
380
+ readonly heap: number | undefined;
381
+ /**
382
+ * The time spent importing every non-externalized dependency that Vitest has processed.
383
+ */
384
+ readonly importDurations: Record<string, ImportDuration>;
542
385
  }
386
+ declare function experimental_getRunnerTask(entity: TestCase): Test;
387
+ declare function experimental_getRunnerTask(entity: TestSuite): Suite;
388
+ declare function experimental_getRunnerTask(entity: TestModule): File;
389
+ declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
543
390
 
544
391
  declare class TestSpecification {
545
392
  /**
@@ -571,440 +418,6 @@ declare class TestSpecification {
571
418
  toJSON(): SerializedTestSpecification;
572
419
  }
573
420
 
574
- declare class TestProject {
575
- options?: Vitest;
576
- /**
577
- * The global Vitest instance.
578
- * @experimental The public Vitest API is experimental and does not follow semver.
579
- */
580
- readonly vitest: Vitest;
581
- /**
582
- * Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
583
- */
584
- readonly globalConfig: ResolvedConfig;
585
- /**
586
- * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
587
- */
588
- browser?: ProjectBrowser;
589
- /**
590
- * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
591
- */
592
- readonly tmpDir: string;
593
- /** @inetrnal */ testFilesList: string[] | null;
594
- private runner;
595
- private closingPromise;
596
- private typecheckFilesList;
597
- private _globalSetups?;
598
- private _provided;
599
- constructor(vitest: Vitest, options?: InitializeProjectOptions | undefined);
600
- /**
601
- * The unique hash of this project. This value is consistent between the reruns.
602
- *
603
- * It is based on the root of the project (not consistent between OS) and its name.
604
- */
605
- get hash(): string;
606
- // "provide" is a property, not a method to keep the context when destructed in the global setup,
607
- // making it a method would be a breaking change, and can be done in Vitest 3 at minimum
608
- /**
609
- * Provide a value to the test context. This value will be available to all tests with `inject`.
610
- */
611
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
612
- /**
613
- * Get the provided context. The project context is merged with the global context.
614
- */
615
- getProvidedContext(): ProvidedContext;
616
- /**
617
- * Creates a new test specification. Specifications describe how to run tests.
618
- * @param moduleId The file path
619
- */
620
- createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
621
- toJSON(): SerializedTestProject;
622
- /**
623
- * Vite's dev server instance. Every workspace project has its own server.
624
- */
625
- get vite(): ViteDevServer;
626
- /**
627
- * Resolved project configuration.
628
- */
629
- get config(): ResolvedConfig;
630
- /**
631
- * The name of the project or an empty string if not set.
632
- */
633
- get name(): string;
634
- /**
635
- * The color used when reporting tasks of this project.
636
- */
637
- get color(): ProjectName["color"];
638
- /**
639
- * Serialized project configuration. This is the config that tests receive.
640
- */
641
- get serializedConfig(): SerializedConfig;
642
- /**
643
- * Check if this is the root project. The root project is the one that has the root config.
644
- */
645
- isRootProject(): boolean;
646
- onTestsRerun(cb: OnTestsRerunHandler): void;
647
- /**
648
- * Get all files in the project that match the globs in the config and the filters.
649
- * @param filters String filters to match the test files.
650
- */
651
- globTestFiles(filters?: string[]): Promise<{
652
- /**
653
- * Test files that match the filters.
654
- */
655
- testFiles: string[];
656
- /**
657
- * Typecheck test files that match the filters. This will be empty unless `typecheck.enabled` is `true`.
658
- */
659
- typecheckTestFiles: string[];
660
- }>;
661
- private globAllTestFiles;
662
- isBrowserEnabled(): boolean;
663
- private markTestFile;
664
- /**
665
- * Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
666
- */
667
- matchesTestGlob(moduleId: string, source?: () => string): boolean;
668
- private isInSourceTestCode;
669
- private filterFiles;
670
- private _parentBrowser?;
671
- /**
672
- * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
673
- * If the resources are needed again, create a new project.
674
- */
675
- close(): Promise<void>;
676
- /**
677
- * Import a file using Vite module runner.
678
- * @param moduleId The ID of the module in Vite module graph
679
- */
680
- import<T>(moduleId: string): Promise<T>;
681
- private _setHash;
682
- private _serializeOverriddenConfig;
683
- private clearTmpDir;
684
- }
685
- interface SerializedTestProject {
686
- name: string;
687
- serializedConfig: SerializedConfig;
688
- context: ProvidedContext;
689
- }
690
- interface InitializeProjectOptions extends TestProjectInlineConfiguration {
691
- configFile: string | false;
692
- }
693
-
694
- declare class ReportedTaskImplementation {
695
- /**
696
- * The project associated with the test or suite.
697
- */
698
- readonly project: TestProject;
699
- /**
700
- * Unique identifier.
701
- * This ID is deterministic and will be the same for the same test across multiple runs.
702
- * The ID is based on the project name, module url and test order.
703
- */
704
- readonly id: string;
705
- /**
706
- * Location in the module where the test or suite is defined.
707
- */
708
- readonly location: {
709
- line: number;
710
- column: number;
711
- } | undefined;
712
- /**
713
- * Checks if the test did not fail the suite.
714
- * If the test is not finished yet or was skipped, it will return `true`.
715
- */
716
- ok(): boolean;
717
- /**
718
- * Custom metadata that was attached to the test during its execution.
719
- */
720
- meta(): TaskMeta;
721
- }
722
- declare class TestCase extends ReportedTaskImplementation {
723
- #private;
724
- readonly type = "test";
725
- /**
726
- * Direct reference to the test module where the test or suite is defined.
727
- */
728
- readonly module: TestModule;
729
- /**
730
- * Name of the test.
731
- */
732
- readonly name: string;
733
- /**
734
- * Options that the test was initiated with.
735
- */
736
- readonly options: TaskOptions;
737
- /**
738
- * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
739
- */
740
- readonly parent: TestSuite | TestModule;
741
- /**
742
- * Full name of the test including all parent suites separated with `>`.
743
- */
744
- get fullName(): string;
745
- /**
746
- * Test results.
747
- * - **pending**: Test was collected, but didn't finish running yet.
748
- * - **passed**: Test passed successfully
749
- * - **failed**: Test failed to execute
750
- * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
751
- */
752
- result(): TestResult;
753
- /**
754
- * Test annotations added via the `task.annotate` API during the test execution.
755
- */
756
- annotations(): ReadonlyArray<TestAnnotation>;
757
- /**
758
- * Useful information about the test like duration, memory usage, etc.
759
- * Diagnostic is only available after the test has finished.
760
- */
761
- diagnostic(): TestDiagnostic | undefined;
762
- }
763
- declare class TestCollection {
764
- #private;
765
- constructor(task: Suite | File, project: TestProject);
766
- /**
767
- * Returns the test or suite at a specific index.
768
- */
769
- at(index: number): TestCase | TestSuite | undefined;
770
- /**
771
- * The number of tests and suites in the collection.
772
- */
773
- get size(): number;
774
- /**
775
- * Returns the collection in array form for easier manipulation.
776
- */
777
- array(): (TestCase | TestSuite)[];
778
- /**
779
- * Filters all tests that are part of this collection and its children.
780
- */
781
- allTests(state?: TestState): Generator<TestCase, undefined, void>;
782
- /**
783
- * Filters only the tests that are part of this collection.
784
- */
785
- tests(state?: TestState): Generator<TestCase, undefined, void>;
786
- /**
787
- * Filters only the suites that are part of this collection.
788
- */
789
- suites(): Generator<TestSuite, undefined, void>;
790
- /**
791
- * Filters all suites that are part of this collection and its children.
792
- */
793
- allSuites(): Generator<TestSuite, undefined, void>;
794
- [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
795
- }
796
-
797
- type ReportedHookContext = {
798
- readonly name: "beforeAll" | "afterAll";
799
- readonly entity: TestSuite | TestModule;
800
- } | {
801
- readonly name: "beforeEach" | "afterEach";
802
- readonly entity: TestCase;
803
- };
804
- declare abstract class SuiteImplementation extends ReportedTaskImplementation {
805
- /**
806
- * Collection of suites and tests that are part of this suite.
807
- */
808
- readonly children: TestCollection;
809
- /**
810
- * Errors that happened outside of the test run during collection, like syntax errors.
811
- */
812
- errors(): SerializedError[];
813
- }
814
- declare class TestSuite extends SuiteImplementation {
815
- #private;
816
- readonly type = "suite";
817
- /**
818
- * Name of the test or the suite.
819
- */
820
- readonly name: string;
821
- /**
822
- * Direct reference to the test module where the test or suite is defined.
823
- */
824
- readonly module: TestModule;
825
- /**
826
- * Parent suite. If suite was called directly inside the module, the parent will be the module itself.
827
- */
828
- readonly parent: TestSuite | TestModule;
829
- /**
830
- * Options that suite was initiated with.
831
- */
832
- readonly options: TaskOptions;
833
- /**
834
- * Checks if the suite has any failed tests.
835
- * This will also return `false` if suite failed during collection.
836
- */
837
- ok: () => boolean;
838
- /**
839
- * The meta information attached to the suite during its collection or execution.
840
- */
841
- meta: () => TaskMeta;
842
- /**
843
- * Checks the running state of the suite.
844
- */
845
- state(): TestSuiteState;
846
- /**
847
- * Full name of the suite including all parent suites separated with `>`.
848
- */
849
- get fullName(): string;
850
- }
851
- declare class TestModule extends SuiteImplementation {
852
- readonly location: undefined;
853
- readonly type = "module";
854
- /**
855
- * This is usually an absolute UNIX file path.
856
- * It can be a virtual ID if the file is not on the disk.
857
- * This value corresponds to the ID in the Vite's module graph.
858
- */
859
- readonly moduleId: string;
860
- /**
861
- * Checks the running state of the test file.
862
- */
863
- state(): TestModuleState;
864
- /**
865
- * Checks if the module has any failed tests.
866
- * This will also return `false` if module failed during collection.
867
- */
868
- ok: () => boolean;
869
- /**
870
- * The meta information attached to the module during its collection or execution.
871
- */
872
- meta: () => TaskMeta;
873
- /**
874
- * Useful information about the module like duration, memory usage, etc.
875
- * If the module was not executed yet, all diagnostic values will return `0`.
876
- */
877
- diagnostic(): ModuleDiagnostic;
878
- }
879
- interface TaskOptions {
880
- readonly each: boolean | undefined;
881
- readonly fails: boolean | undefined;
882
- readonly concurrent: boolean | undefined;
883
- readonly shuffle: boolean | undefined;
884
- readonly retry: number | undefined;
885
- readonly repeats: number | undefined;
886
- readonly mode: "run" | "only" | "skip" | "todo";
887
- }
888
- type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
889
- type TestModuleState = TestSuiteState | "queued";
890
- type TestState = TestResult["state"];
891
- type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
892
- interface TestResultPending {
893
- /**
894
- * The test was collected, but didn't finish running yet.
895
- */
896
- readonly state: "pending";
897
- /**
898
- * Pending tests have no errors.
899
- */
900
- readonly errors: undefined;
901
- }
902
- interface TestResultPassed {
903
- /**
904
- * The test passed successfully.
905
- */
906
- readonly state: "passed";
907
- /**
908
- * Errors that were thrown during the test execution.
909
- *
910
- * **Note**: If test was retried successfully, errors will still be reported.
911
- */
912
- readonly errors: ReadonlyArray<TestError> | undefined;
913
- }
914
- interface TestResultFailed {
915
- /**
916
- * The test failed to execute.
917
- */
918
- readonly state: "failed";
919
- /**
920
- * Errors that were thrown during the test execution.
921
- */
922
- readonly errors: ReadonlyArray<TestError>;
923
- }
924
- interface TestResultSkipped {
925
- /**
926
- * The test was skipped with `only` (on another test), `skip` or `todo` flag.
927
- * You can see which one was used in the `options.mode` option.
928
- */
929
- readonly state: "skipped";
930
- /**
931
- * Skipped tests have no errors.
932
- */
933
- readonly errors: undefined;
934
- /**
935
- * A custom note passed down to `ctx.skip(note)`.
936
- */
937
- readonly note: string | undefined;
938
- }
939
- interface TestDiagnostic {
940
- /**
941
- * If the duration of the test is above `slowTestThreshold`.
942
- */
943
- readonly slow: boolean;
944
- /**
945
- * The amount of memory used by the test in bytes.
946
- * This value is only available if the test was executed with `logHeapUsage` flag.
947
- */
948
- readonly heap: number | undefined;
949
- /**
950
- * The time it takes to execute the test in ms.
951
- */
952
- readonly duration: number;
953
- /**
954
- * The time in ms when the test started.
955
- */
956
- readonly startTime: number;
957
- /**
958
- * The amount of times the test was retried.
959
- */
960
- readonly retryCount: number;
961
- /**
962
- * The amount of times the test was repeated as configured by `repeats` option.
963
- * This value can be lower if the test failed during the repeat and no `retry` is configured.
964
- */
965
- readonly repeatCount: number;
966
- /**
967
- * If test passed on a second retry.
968
- */
969
- readonly flaky: boolean;
970
- }
971
- interface ModuleDiagnostic {
972
- /**
973
- * The time it takes to import and initiate an environment.
974
- */
975
- readonly environmentSetupDuration: number;
976
- /**
977
- * The time it takes Vitest to setup test harness (runner, mocks, etc.).
978
- */
979
- readonly prepareDuration: number;
980
- /**
981
- * The time it takes to import the test module.
982
- * This includes importing everything in the module and executing suite callbacks.
983
- */
984
- readonly collectDuration: number;
985
- /**
986
- * The time it takes to import the setup module.
987
- */
988
- readonly setupDuration: number;
989
- /**
990
- * Accumulated duration of all tests and hooks in the module.
991
- */
992
- readonly duration: number;
993
- /**
994
- * The amount of memory used by the test module in bytes.
995
- * This value is only available if the test was executed with `logHeapUsage` flag.
996
- */
997
- readonly heap: number | undefined;
998
- /**
999
- * The time spent importing every non-externalized dependency that Vitest has processed.
1000
- */
1001
- readonly importDurations: Record<string, ImportDuration>;
1002
- }
1003
- declare function experimental_getRunnerTask(entity: TestCase): Test;
1004
- declare function experimental_getRunnerTask(entity: TestSuite): Suite;
1005
- declare function experimental_getRunnerTask(entity: TestModule): File;
1006
- declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
1007
-
1008
421
  interface CoverageSummaryData {
1009
422
  lines: Totals;
1010
423
  statements: Totals;
@@ -1376,10 +789,11 @@ interface Thresholds {
1376
789
  perFile?: boolean;
1377
790
  /**
1378
791
  * Update threshold values automatically when current coverage is higher than earlier thresholds
792
+ * Also can accept a function to format the new threshold values
1379
793
  *
1380
794
  * @default false
1381
795
  */
1382
- autoUpdate?: boolean;
796
+ autoUpdate?: boolean | ((newThreshold: number) => number);
1383
797
  /** Thresholds for statements */
1384
798
  statements?: number;
1385
799
  /** Thresholds for functions */
@@ -1489,6 +903,80 @@ declare class VitestPackageInstaller {
1489
903
  ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1490
904
  }
1491
905
 
906
+ type TestRunEndReason = "passed" | "interrupted" | "failed";
907
+ interface Reporter {
908
+ onInit?: (vitest: Vitest) => void;
909
+ /**
910
+ * Called when the project initiated the browser instance.
911
+ * project.browser will always be defined.
912
+ * @experimental
913
+ */
914
+ onBrowserInit?: (project: TestProject) => Awaitable<void>;
915
+ onTestRemoved?: (trigger?: string) => Awaitable<void>;
916
+ onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
917
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
918
+ onServerRestart?: (reason?: string) => Awaitable<void>;
919
+ onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
920
+ onProcessTimeout?: () => Awaitable<void>;
921
+ /**
922
+ * Called when the new test run starts.
923
+ */
924
+ onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable<void>;
925
+ /**
926
+ * Called when the test run is finished.
927
+ */
928
+ onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable<void>;
929
+ /**
930
+ * Called when the module is enqueued for testing. The file itself is not loaded yet.
931
+ */
932
+ onTestModuleQueued?: (testModule: TestModule) => Awaitable<void>;
933
+ /**
934
+ * Called when the test file is loaded and the module is ready to run tests.
935
+ */
936
+ onTestModuleCollected?: (testModule: TestModule) => Awaitable<void>;
937
+ /**
938
+ * Called when starting to run tests of the test file
939
+ */
940
+ onTestModuleStart?: (testModule: TestModule) => Awaitable<void>;
941
+ /**
942
+ * Called when all tests of the test file have finished running.
943
+ */
944
+ onTestModuleEnd?: (testModule: TestModule) => Awaitable<void>;
945
+ /**
946
+ * Called when test case is ready to run.
947
+ * Called before the `beforeEach` hooks for the test are run.
948
+ */
949
+ onTestCaseReady?: (testCase: TestCase) => Awaitable<void>;
950
+ /**
951
+ * Called after the test and its hooks are finished running.
952
+ * The `result()` cannot be `pending`.
953
+ */
954
+ onTestCaseResult?: (testCase: TestCase) => Awaitable<void>;
955
+ /**
956
+ * Called when annotation is added via the `task.annotate` API.
957
+ */
958
+ onTestCaseAnnotate?: (testCase: TestCase, annotation: TestAnnotation) => Awaitable<void>;
959
+ /**
960
+ * Called when test suite is ready to run.
961
+ * Called before the `beforeAll` hooks for the test are run.
962
+ */
963
+ onTestSuiteReady?: (testSuite: TestSuite) => Awaitable<void>;
964
+ /**
965
+ * Called after the test suite and its hooks are finished running.
966
+ * The `state` cannot be `pending`.
967
+ */
968
+ onTestSuiteResult?: (testSuite: TestSuite) => Awaitable<void>;
969
+ /**
970
+ * Called before the hook starts to run.
971
+ */
972
+ onHookStart?: (hook: ReportedHookContext) => Awaitable<void>;
973
+ /**
974
+ * Called after the hook finished running.
975
+ */
976
+ onHookEnd?: (hook: ReportedHookContext) => Awaitable<void>;
977
+ onCoverage?: (coverage: unknown) => Awaitable<void>;
978
+ }
979
+
1492
980
  interface BlobOptions {
1493
981
  outputFile?: string;
1494
982
  }
@@ -1515,10 +1003,19 @@ declare class StateManager {
1515
1003
  idMap: Map<string, Task>;
1516
1004
  taskFileMap: WeakMap<Task, File>;
1517
1005
  errorsSet: Set<unknown>;
1518
- processTimeoutCauses: Set<string>;
1519
1006
  reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1520
1007
  blobs?: MergedBlobs;
1521
1008
  transformTime: number;
1009
+ metadata: Record<string, {
1010
+ externalized: Record<string, string>;
1011
+ duration: Record<string, number[]>;
1012
+ tmps: Record<string, string>;
1013
+ dumpDir?: string;
1014
+ outline?: {
1015
+ externalized: number;
1016
+ inlined: number;
1017
+ };
1018
+ }>;
1522
1019
  onUnhandledError?: OnUnhandledErrorCallback;
1523
1020
  constructor(options: {
1524
1021
  onUnhandledError?: OnUnhandledErrorCallback;
@@ -1526,8 +1023,6 @@ declare class StateManager {
1526
1023
  catchError(error: unknown, type: string): void;
1527
1024
  clearErrors(): void;
1528
1025
  getUnhandledErrors(): unknown[];
1529
- addProcessTimeoutCause(cause: string): void;
1530
- getProcessTimeoutCauses(): string[];
1531
1026
  getPaths(): string[];
1532
1027
  /**
1533
1028
  * Return files that were running or collected.
@@ -1541,10 +1036,11 @@ declare class StateManager {
1541
1036
  clearFiles(project: TestProject, paths?: string[]): void;
1542
1037
  updateId(task: Task, project: TestProject): void;
1543
1038
  getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1039
+ getReportedEntityById(taskId: string): TestModule | TestCase | TestSuite | undefined;
1544
1040
  updateTasks(packs: TaskResultPack[]): void;
1545
1041
  updateUserLog(log: UserConsoleLog): void;
1546
1042
  getCountOfFailedTests(): number;
1547
- cancelFiles(files: string[], project: TestProject): void;
1043
+ cancelFiles(files: FileSpecification[], project: TestProject): void;
1548
1044
  }
1549
1045
 
1550
1046
  declare class VitestWatcher {
@@ -1665,260 +1161,773 @@ declare class Vitest {
1665
1161
  disableCoverage(): void;
1666
1162
  private _coverageOverrideCache;
1667
1163
  /**
1668
- * Inject new test projects into the workspace.
1669
- * @param config Glob, config path or a custom config options.
1670
- * @returns An array of new test projects. Can be empty if the name was filtered out.
1164
+ * Inject new test projects into the workspace.
1165
+ * @param config Glob, config path or a custom config options.
1166
+ * @returns An array of new test projects. Can be empty if the name was filtered out.
1167
+ */
1168
+ private injectTestProject;
1169
+ /**
1170
+ * Provide a value to the test context. This value will be available to all tests with `inject`.
1171
+ */
1172
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1173
+ /**
1174
+ * Get global provided context.
1175
+ */
1176
+ getProvidedContext(): ProvidedContext;
1177
+ /**
1178
+ * Return project that has the root (or "global") config.
1179
+ */
1180
+ getRootProject(): TestProject;
1181
+ getProjectByName(name: string): TestProject;
1182
+ /**
1183
+ * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
1184
+ * @param moduleId The ID of the module in Vite module graph
1185
+ */
1186
+ import<T>(moduleId: string): Promise<T>;
1187
+ /**
1188
+ * Creates a coverage provider if `coverage` is enabled in the config.
1189
+ */
1190
+ createCoverageProvider(): Promise<CoverageProvider | null>;
1191
+ private resolveProjects;
1192
+ /**
1193
+ * Glob test files in every project and create a TestSpecification for each file and pool.
1194
+ * @param filters String filters to match the test files.
1195
+ */
1196
+ globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1197
+ private initCoverageProvider;
1198
+ /**
1199
+ * Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
1200
+ */
1201
+ mergeReports(directory?: string): Promise<TestRunResult>;
1202
+ /**
1203
+ * Returns the seed, if tests are running in a random order.
1204
+ */
1205
+ getSeed(): number | null;
1206
+ collect(filters?: string[]): Promise<TestRunResult>;
1207
+ /**
1208
+ * Returns the list of test files that match the config and filters.
1209
+ * @param filters String filters to match the test files
1210
+ */
1211
+ getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1212
+ /**
1213
+ * Initialize reporters, the coverage provider, and run tests.
1214
+ * This method can throw an error:
1215
+ * - `FilesNotFoundError` if no tests are found
1216
+ * - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
1217
+ * - `Error` from the user reporters
1218
+ * @param filters String filters to match the test files
1219
+ */
1220
+ start(filters?: string[]): Promise<TestRunResult>;
1221
+ /**
1222
+ * Initialize reporters and the coverage provider. This method doesn't run any tests.
1223
+ * If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
1224
+ */
1225
+ init(): Promise<void>;
1226
+ /**
1227
+ * If there is a test run happening, returns a promise that will
1228
+ * resolve when the test run is finished.
1229
+ */
1230
+ waitForTestRunEnd(): Promise<void>;
1231
+ /**
1232
+ * Get test specifications associated with the given module. If module is not a test file, an empty array is returned.
1233
+ *
1234
+ * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
1235
+ * @param moduleId The module ID to get test specifications for.
1236
+ */
1237
+ getModuleSpecifications(moduleId: string): TestSpecification[];
1238
+ /**
1239
+ * Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache altogether.
1240
+ */
1241
+ clearSpecificationsCache(moduleId?: string): void;
1242
+ /**
1243
+ * Run tests for the given test specifications. This does not trigger `onWatcher*` events.
1244
+ * @param specifications A list of specifications to run.
1245
+ * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
1246
+ */
1247
+ runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1248
+ /**
1249
+ * Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
1250
+ * @param specifications A list of specifications to run.
1251
+ * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
1252
+ */
1253
+ rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1254
+ private runFiles;
1255
+ experimental_parseSpecifications(specifications: TestSpecification[], options?: {
1256
+ /** @default os.availableParallelism() */
1257
+ concurrency?: number;
1258
+ }): Promise<TestModule[]>;
1259
+ experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
1260
+ /**
1261
+ * Collect tests in specified modules. Vitest will run the files to collect tests.
1262
+ * @param specifications A list of specifications to run.
1263
+ */
1264
+ collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
1265
+ /**
1266
+ * Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
1267
+ */
1268
+ cancelCurrentRun(reason: CancelReason): Promise<void>;
1269
+ private initializeGlobalSetup;
1270
+ /**
1271
+ * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
1272
+ * @param files The list of files on the file system
1273
+ */
1274
+ updateSnapshot(files?: string[]): Promise<TestRunResult>;
1275
+ /**
1276
+ * Enable the mode that allows updating snapshots when running tests.
1277
+ * This method doesn't run any tests.
1278
+ *
1279
+ * Every test that runs after this method is called will update snapshots.
1280
+ * To disable the mode, call `resetSnapshotUpdate`.
1281
+ */
1282
+ enableSnapshotUpdate(): void;
1283
+ /**
1284
+ * Disable the mode that allows updating snapshots when running tests.
1285
+ */
1286
+ resetSnapshotUpdate(): void;
1287
+ /**
1288
+ * Set the global test name pattern to a regexp.
1289
+ * This method doesn't run any tests.
1290
+ */
1291
+ setGlobalTestNamePattern(pattern: string | RegExp): void;
1292
+ /**
1293
+ * Returns the regexp used for the global test name pattern.
1294
+ */
1295
+ getGlobalTestNamePattern(): RegExp | undefined;
1296
+ /**
1297
+ * Resets the global test name pattern. This method doesn't run any tests.
1298
+ */
1299
+ resetGlobalTestNamePattern(): void;
1300
+ private _rerunTimer;
1301
+ private scheduleRerun;
1302
+ /**
1303
+ * Invalidate a file in all projects.
1304
+ */
1305
+ invalidateFile(filepath: string): void;
1306
+ private reportCoverage;
1307
+ /**
1308
+ * Closes all projects and their associated resources.
1309
+ * This can only be called once; the closing promise is cached until the server restarts.
1310
+ */
1311
+ close(): Promise<void>;
1312
+ /**
1313
+ * Closes all projects and exit the process
1314
+ * @param force If true, the process will exit immediately after closing the projects.
1315
+ */
1316
+ exit(force?: boolean): Promise<void>;
1317
+ /**
1318
+ * Should the server be kept running after the tests are done.
1319
+ */
1320
+ shouldKeepServer(): boolean;
1321
+ /**
1322
+ * Register a handler that will be called when the server is restarted due to a config change.
1323
+ */
1324
+ onServerRestart(fn: OnServerRestartHandler): void;
1325
+ /**
1326
+ * Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
1327
+ */
1328
+ onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1329
+ /**
1330
+ * Register a handler that will be called when the server is closed.
1331
+ */
1332
+ onClose(fn: () => Awaitable<void>): void;
1333
+ /**
1334
+ * Register a handler that will be called when the tests are rerunning.
1335
+ */
1336
+ onTestsRerun(fn: OnTestsRerunHandler): void;
1337
+ /**
1338
+ * Register a handler that will be called when a file is changed.
1339
+ * This callback should return `true` of `false` indicating whether the test file needs to be rerun.
1340
+ * @example
1341
+ * const testsToRun = [resolve('./test.spec.ts')]
1342
+ * vitest.onFilterWatchedSpecification(specification => testsToRun.includes(specification.moduleId))
1343
+ */
1344
+ onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
1345
+ /**
1346
+ * Check if the project with a given name should be included.
1347
+ */
1348
+ matchesProjectFilter(name: string): boolean;
1349
+ }
1350
+ type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1351
+ type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
1352
+
1353
+ interface CDPSession {
1354
+ send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
1355
+ on: (event: string, listener: (...args: unknown[]) => void) => void;
1356
+ once: (event: string, listener: (...args: unknown[]) => void) => void;
1357
+ off: (event: string, listener: (...args: unknown[]) => void) => void;
1358
+ }
1359
+ interface BrowserModuleMocker {
1360
+ register: (sessionId: string, module: MockedModule) => Promise<void>;
1361
+ delete: (sessionId: string, url: string) => Promise<void>;
1362
+ clear: (sessionId: string) => Promise<void>;
1363
+ }
1364
+ interface BrowserProviderOption<Options extends object = object> {
1365
+ name: string;
1366
+ supportedBrowser?: ReadonlyArray<string>;
1367
+ options: Options;
1368
+ providerFactory: (project: TestProject) => BrowserProvider;
1369
+ serverFactory: BrowserServerFactory;
1370
+ }
1371
+ interface BrowserServerOptions {
1372
+ project: TestProject;
1373
+ coveragePlugin: () => Plugin;
1374
+ mocksPlugins: (options: {
1375
+ filter: (id: string) => boolean;
1376
+ }) => Plugin[];
1377
+ metaEnvReplacer: () => Plugin;
1378
+ }
1379
+ interface BrowserServerFactory {
1380
+ (otpions: BrowserServerOptions): Promise<ParentProjectBrowser>;
1381
+ }
1382
+ interface BrowserProvider {
1383
+ name: string;
1384
+ mocker?: BrowserModuleMocker;
1385
+ readonly initScripts?: string[];
1386
+ /**
1387
+ * @experimental opt-in into file parallelisation
1388
+ */
1389
+ supportsParallelism: boolean;
1390
+ getCommandsContext: (sessionId: string) => Record<string, unknown>;
1391
+ openPage: (sessionId: string, url: string) => Promise<void>;
1392
+ getCDPSession?: (sessionId: string) => Promise<CDPSession>;
1393
+ close: () => Awaitable<void>;
1394
+ }
1395
+ type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
1396
+ interface _BrowserNames {}
1397
+ type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
1398
+ interface BrowserInstanceOption extends Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
1399
+ /**
1400
+ * Name of the browser
1401
+ */
1402
+ browser: keyof _BrowserNames extends never ? string : _BrowserNames[keyof _BrowserNames];
1403
+ name?: string;
1404
+ provider?: BrowserProviderOption;
1405
+ }
1406
+ interface BrowserConfigOptions {
1407
+ /**
1408
+ * if running tests in the browser should be the default
1409
+ *
1410
+ * @default false
1411
+ */
1412
+ enabled?: boolean;
1413
+ /**
1414
+ * Configurations for different browser setups
1415
+ */
1416
+ instances?: BrowserInstanceOption[];
1417
+ /**
1418
+ * Browser provider
1419
+ * @example
1420
+ * ```ts
1421
+ * import { playwright } from '@vitest/browser-playwright'
1422
+ * export default defineConfig({
1423
+ * test: {
1424
+ * browser: {
1425
+ * provider: playwright(),
1426
+ * },
1427
+ * },
1428
+ * })
1429
+ * ```
1430
+ */
1431
+ provider?: BrowserProviderOption;
1432
+ /**
1433
+ * enable headless mode
1434
+ *
1435
+ * @default process.env.CI
1436
+ */
1437
+ headless?: boolean;
1438
+ /**
1439
+ * Serve API options.
1440
+ *
1441
+ * The default port is 63315.
1442
+ */
1443
+ api?: ApiConfig | number;
1444
+ /**
1445
+ * Isolate test environment after each test
1446
+ *
1447
+ * @default true
1671
1448
  */
1672
- private injectTestProject;
1449
+ isolate?: boolean;
1673
1450
  /**
1674
- * Provide a value to the test context. This value will be available to all tests with `inject`.
1451
+ * Run test files in parallel if provider supports this option
1452
+ * This option only has effect in headless mode (enabled in CI by default)
1453
+ *
1454
+ * @default // Same as "test.fileParallelism"
1675
1455
  */
1676
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1456
+ fileParallelism?: boolean;
1677
1457
  /**
1678
- * Get global provided context.
1458
+ * Show Vitest UI
1459
+ *
1460
+ * @default !process.env.CI
1679
1461
  */
1680
- getProvidedContext(): ProvidedContext;
1462
+ ui?: boolean;
1681
1463
  /**
1682
- * Return project that has the root (or "global") config.
1464
+ * Default viewport size
1683
1465
  */
1684
- getRootProject(): TestProject;
1685
- getProjectByName(name: string): TestProject;
1466
+ viewport?: {
1467
+ /**
1468
+ * Width of the viewport
1469
+ * @default 414
1470
+ */
1471
+ width: number;
1472
+ /**
1473
+ * Height of the viewport
1474
+ * @default 896
1475
+ */
1476
+ height: number;
1477
+ };
1686
1478
  /**
1687
- * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
1688
- * @param moduleId The ID of the module in Vite module graph
1479
+ * Locator options
1689
1480
  */
1690
- import<T>(moduleId: string): Promise<T>;
1481
+ locators?: {
1482
+ /**
1483
+ * Attribute used to locate elements by test id
1484
+ * @default 'data-testid'
1485
+ */
1486
+ testIdAttribute?: string;
1487
+ };
1691
1488
  /**
1692
- * Creates a coverage provider if `coverage` is enabled in the config.
1489
+ * Generate traces that can be viewed on https://trace.playwright.dev/
1490
+ *
1491
+ * This option is supported only by **playwright** provider.
1693
1492
  */
1694
- createCoverageProvider(): Promise<CoverageProvider | null>;
1695
- private resolveProjects;
1493
+ trace?: BrowserTraceViewMode | {
1494
+ mode: BrowserTraceViewMode;
1495
+ /**
1496
+ * The directory where all traces will be stored. By default, Vitest
1497
+ * stores all traces in `__traces__` folder close to the test file.
1498
+ */
1499
+ tracesDir?: string;
1500
+ /**
1501
+ * Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.
1502
+ * @default true
1503
+ */
1504
+ screenshots?: boolean;
1505
+ /**
1506
+ * If this option is true tracing will
1507
+ * - capture DOM snapshot on every action
1508
+ * - record network activity
1509
+ * @default true
1510
+ */
1511
+ snapshots?: boolean;
1512
+ };
1696
1513
  /**
1697
- * Glob test files in every project and create a TestSpecification for each file and pool.
1698
- * @param filters String filters to match the test files.
1514
+ * Directory where screenshots will be saved when page.screenshot() is called
1515
+ * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
1516
+ * If this is set, it will be resolved relative to the project root.
1517
+ * @default __screenshots__
1699
1518
  */
1700
- globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1701
- private initCoverageProvider;
1519
+ screenshotDirectory?: string;
1702
1520
  /**
1703
- * Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
1521
+ * Should Vitest take screenshots if the test fails
1522
+ * @default !browser.ui
1704
1523
  */
1705
- mergeReports(directory?: string): Promise<TestRunResult>;
1706
- collect(filters?: string[]): Promise<TestRunResult>;
1524
+ screenshotFailures?: boolean;
1707
1525
  /**
1708
- * Returns the list of test files that match the config and filters.
1709
- * @param filters String filters to match the test files
1526
+ * Path to the index.html file that will be used to run tests.
1710
1527
  */
1711
- getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1528
+ testerHtmlPath?: string;
1712
1529
  /**
1713
- * Initialize reporters, the coverage provider, and run tests.
1714
- * This method can throw an error:
1715
- * - `FilesNotFoundError` if no tests are found
1716
- * - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
1717
- * - `Error` from the user reporters
1718
- * @param filters String filters to match the test files
1530
+ * Scripts injected into the main window.
1719
1531
  */
1720
- start(filters?: string[]): Promise<TestRunResult>;
1532
+ orchestratorScripts?: BrowserScript[];
1721
1533
  /**
1722
- * Initialize reporters and the coverage provider. This method doesn't run any tests.
1723
- * If the `--watch` flag is provided, Vitest will still run changed tests even if this method was not called.
1534
+ * Commands that will be executed on the server
1535
+ * via the browser `import("vitest/browser").commands` API.
1536
+ * @see {@link https://vitest.dev/guide/browser/commands}
1724
1537
  */
1725
- init(): Promise<void>;
1538
+ commands?: Record<string, BrowserCommand<any>>;
1726
1539
  /**
1727
- * If there is a test run happening, returns a promise that will
1728
- * resolve when the test run is finished.
1540
+ * Timeout for connecting to the browser
1541
+ * @default 30000
1729
1542
  */
1730
- waitForTestRunEnd(): Promise<void>;
1543
+ connectTimeout?: number;
1544
+ expect?: {
1545
+ toMatchScreenshot?: { [ComparatorName in keyof ToMatchScreenshotComparators] : {
1546
+ /**
1547
+ * The name of the comparator to use for visual diffing.
1548
+ *
1549
+ * @defaultValue `'pixelmatch'`
1550
+ */
1551
+ comparatorName?: ComparatorName;
1552
+ comparatorOptions?: ToMatchScreenshotComparators[ComparatorName];
1553
+ } }[keyof ToMatchScreenshotComparators] & ToMatchScreenshotOptions;
1554
+ };
1731
1555
  /**
1732
- * Get test specifications associated with the given module. If module is not a test file, an empty array is returned.
1556
+ * Enables tracking uncaught errors and exceptions so they can be reported by Vitest.
1733
1557
  *
1734
- * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
1735
- * @param moduleId The module ID to get test specifications for.
1558
+ * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/#onunhandlederror) option instead.
1559
+ *
1560
+ * Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on.
1561
+ * @default true
1736
1562
  */
1737
- getModuleSpecifications(moduleId: string): TestSpecification[];
1563
+ trackUnhandledErrors?: boolean;
1564
+ }
1565
+ interface BrowserCommandContext {
1566
+ testPath: string | undefined;
1567
+ provider: BrowserProvider;
1568
+ project: TestProject;
1569
+ sessionId: string;
1570
+ triggerCommand: <K extends keyof BrowserCommands>(name: K, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
1571
+ }
1572
+ interface BrowserServerStateSession {
1573
+ project: TestProject;
1574
+ connected: () => void;
1575
+ fail: (v: Error) => void;
1576
+ }
1577
+ interface BrowserOrchestrator {
1578
+ cleanupTesters: () => Promise<void>;
1579
+ createTesters: (options: BrowserTesterOptions) => Promise<void>;
1580
+ onCancel: (reason: CancelReason) => Promise<void>;
1581
+ $close: () => void;
1582
+ }
1583
+ interface BrowserServerState {
1584
+ orchestrators: Map<string, BrowserOrchestrator>;
1585
+ }
1586
+ interface ParentProjectBrowser {
1587
+ spawn: (project: TestProject) => ProjectBrowser;
1588
+ vite: ViteDevServer;
1589
+ }
1590
+ interface ProjectBrowser {
1591
+ vite: ViteDevServer;
1592
+ state: BrowserServerState;
1593
+ provider: BrowserProvider;
1594
+ close: () => Promise<void>;
1595
+ initBrowserProvider: (project: TestProject) => Promise<void>;
1596
+ parseStacktrace: (stack: string) => ParsedStack[];
1597
+ parseErrorStacktrace: (error: TestError, options?: StackTraceParserOptions) => ParsedStack[];
1598
+ registerCommand: <K extends keyof BrowserCommands>(name: K, cb: BrowserCommand<Parameters<BrowserCommands[K]>, ReturnType<BrowserCommands[K]>>) => void;
1599
+ triggerCommand: <K extends keyof BrowserCommands>(name: K, context: BrowserCommandContext, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
1600
+ }
1601
+ interface BrowserCommand<
1602
+ Payload extends unknown[] = [],
1603
+ ReturnValue = any
1604
+ > {
1605
+ (context: BrowserCommandContext, ...payload: Payload): Awaitable<ReturnValue>;
1606
+ }
1607
+ interface BrowserScript {
1738
1608
  /**
1739
- * Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache altogether.
1609
+ * If "content" is provided and type is "module", this will be its identifier.
1610
+ *
1611
+ * If you are using TypeScript, you can add `.ts` extension here for example.
1612
+ * @default `injected-${index}.js`
1740
1613
  */
1741
- clearSpecificationsCache(moduleId?: string): void;
1614
+ id?: string;
1742
1615
  /**
1743
- * Run tests for the given test specifications. This does not trigger `onWatcher*` events.
1744
- * @param specifications A list of specifications to run.
1745
- * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
1616
+ * JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
1617
+ *
1618
+ * You can use `id` to give Vite a hint about the file extension.
1746
1619
  */
1747
- runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1620
+ content?: string;
1748
1621
  /**
1749
- * Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
1750
- * @param specifications A list of specifications to run.
1751
- * @param allTestsRun Indicates whether all tests were run. This only matters for coverage.
1622
+ * Path to the script. This value is resolved by Vite so it can be a node module or a file path.
1752
1623
  */
1753
- rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1754
- private runFiles;
1755
- experimental_parseSpecifications(specifications: TestSpecification[], options?: {
1756
- /** @default os.availableParallelism() */
1757
- concurrency?: number;
1758
- }): Promise<TestModule[]>;
1759
- experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
1624
+ src?: string;
1760
1625
  /**
1761
- * Collect tests in specified modules. Vitest will run the files to collect tests.
1762
- * @param specifications A list of specifications to run.
1626
+ * If the script should be loaded asynchronously.
1763
1627
  */
1764
- collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
1628
+ async?: boolean;
1765
1629
  /**
1766
- * Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
1630
+ * Script type.
1631
+ * @default 'module'
1767
1632
  */
1768
- cancelCurrentRun(reason: CancelReason): Promise<void>;
1769
- private initializeGlobalSetup;
1633
+ type?: string;
1634
+ }
1635
+ interface ResolvedBrowserOptions extends BrowserConfigOptions {
1636
+ name: string;
1637
+ enabled: boolean;
1638
+ headless: boolean;
1639
+ isolate: boolean;
1640
+ fileParallelism: boolean;
1641
+ api: ApiConfig;
1642
+ ui: boolean;
1643
+ viewport: {
1644
+ width: number;
1645
+ height: number;
1646
+ };
1647
+ screenshotFailures: boolean;
1648
+ locators: {
1649
+ testIdAttribute: string;
1650
+ };
1651
+ trace: {
1652
+ mode: BrowserTraceViewMode;
1653
+ tracesDir?: string;
1654
+ screenshots?: boolean;
1655
+ snapshots?: boolean;
1656
+ };
1657
+ }
1658
+ type ToMatchScreenshotResolvePath = (data: {
1770
1659
  /**
1771
- * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
1772
- * @param files The list of files on the file system
1660
+ * Path **without** extension, sanitized and relative to the test file.
1661
+ *
1662
+ * This comes from the arguments passed to `toMatchScreenshot`; if called
1663
+ * without arguments this will be the auto-generated name.
1664
+ *
1665
+ * @example
1666
+ * test('calls `onClick`', () => {
1667
+ * expect(locator).toMatchScreenshot()
1668
+ * // arg = "calls-onclick-1"
1669
+ * })
1670
+ *
1671
+ * @example
1672
+ * expect(locator).toMatchScreenshot('foo/bar/baz.png')
1673
+ * // arg = "foo/bar/baz"
1674
+ *
1675
+ * @example
1676
+ * expect(locator).toMatchScreenshot('../foo/bar/baz.png')
1677
+ * // arg = "foo/bar/baz"
1773
1678
  */
1774
- updateSnapshot(files?: string[]): Promise<TestRunResult>;
1679
+ arg: string;
1775
1680
  /**
1776
- * Enable the mode that allows updating snapshots when running tests.
1777
- * This method doesn't run any tests.
1681
+ * Screenshot extension, with leading dot.
1778
1682
  *
1779
- * Every test that runs after this method is called will update snapshots.
1780
- * To disable the mode, call `resetSnapshotUpdate`.
1683
+ * This can be set through the arguments passed to `toMatchScreenshot`, but
1684
+ * the value will fall back to `'.png'` if an unsupported extension is used.
1781
1685
  */
1782
- enableSnapshotUpdate(): void;
1686
+ ext: string;
1783
1687
  /**
1784
- * Disable the mode that allows updating snapshots when running tests.
1688
+ * The instance's browser name.
1689
+ */
1690
+ browserName: string;
1691
+ /**
1692
+ * The value of {@linkcode process.platform}.
1785
1693
  */
1786
- resetSnapshotUpdate(): void;
1694
+ platform: NodeJS.Platform;
1787
1695
  /**
1788
- * Set the global test name pattern to a regexp.
1789
- * This method doesn't run any tests.
1696
+ * The value provided to
1697
+ * {@linkcode https://vitest.dev/guide/browser/config#browser-screenshotdirectory|browser.screenshotDirectory},
1698
+ * if none is provided, its default value.
1790
1699
  */
1791
- setGlobalTestNamePattern(pattern: string | RegExp): void;
1700
+ screenshotDirectory: string;
1792
1701
  /**
1793
- * Resets the global test name pattern. This method doesn't run any tests.
1702
+ * Absolute path to the project's
1703
+ * {@linkcode https://vitest.dev/config/#root|root}.
1794
1704
  */
1795
- resetGlobalTestNamePattern(): void;
1796
- private _rerunTimer;
1797
- private scheduleRerun;
1705
+ root: string;
1798
1706
  /**
1799
- * Invalidate a file in all projects.
1707
+ * Path to the test file, relative to the project's
1708
+ * {@linkcode https://vitest.dev/config/#root|root}.
1800
1709
  */
1801
- invalidateFile(filepath: string): void;
1802
- private reportCoverage;
1710
+ testFileDirectory: string;
1803
1711
  /**
1804
- * Closes all projects and their associated resources.
1805
- * This can only be called once; the closing promise is cached until the server restarts.
1712
+ * The test's filename.
1806
1713
  */
1807
- close(): Promise<void>;
1714
+ testFileName: string;
1808
1715
  /**
1809
- * Closes all projects and exit the process
1810
- * @param force If true, the process will exit immediately after closing the projects.
1716
+ * The {@linkcode https://vitest.dev/api/#test|test}'s name, including
1717
+ * parent {@linkcode https://vitest.dev/api/#describe|describe}, sanitized.
1811
1718
  */
1812
- exit(force?: boolean): Promise<void>;
1719
+ testName: string;
1813
1720
  /**
1814
- * Should the server be kept running after the tests are done.
1721
+ * The value provided to
1722
+ * {@linkcode https://vitest.dev/config/#attachmentsdir|attachmentsDir},
1723
+ * if none is provided, its default value.
1815
1724
  */
1816
- shouldKeepServer(): boolean;
1725
+ attachmentsDir: string;
1726
+ }) => string;
1727
+ interface ToMatchScreenshotOptions {
1817
1728
  /**
1818
- * Register a handler that will be called when the server is restarted due to a config change.
1729
+ * Overrides default reference screenshot path.
1730
+ *
1731
+ * @default `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
1819
1732
  */
1820
- onServerRestart(fn: OnServerRestartHandler): void;
1733
+ resolveScreenshotPath?: ToMatchScreenshotResolvePath;
1821
1734
  /**
1822
- * Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
1735
+ * Overrides default screenshot path used for diffs.
1736
+ *
1737
+ * @default `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
1823
1738
  */
1824
- onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1739
+ resolveDiffPath?: ToMatchScreenshotResolvePath;
1740
+ }
1741
+ interface ToMatchScreenshotComparators {}
1742
+
1743
+ declare class TestProject {
1744
+ options?: InitializeProjectOptions | undefined;
1825
1745
  /**
1826
- * Register a handler that will be called when the server is closed.
1746
+ * The global Vitest instance.
1827
1747
  */
1828
- onClose(fn: () => Awaitable<void>): void;
1748
+ readonly vitest: Vitest;
1829
1749
  /**
1830
- * Register a handler that will be called when the tests are rerunning.
1750
+ * Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
1831
1751
  */
1832
- onTestsRerun(fn: OnTestsRerunHandler): void;
1752
+ readonly globalConfig: ResolvedConfig;
1833
1753
  /**
1834
- * Register a handler that will be called when a file is changed.
1835
- * This callback should return `true` of `false` indicating whether the test file needs to be rerun.
1836
- * @example
1837
- * const testsToRun = [resolve('./test.spec.ts')]
1838
- * vitest.onFilterWatchedSpecification(specification => testsToRun.includes(specification.moduleId))
1754
+ * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
1839
1755
  */
1840
- onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
1756
+ browser?: ProjectBrowser;
1841
1757
  /**
1842
- * Check if the project with a given name should be included.
1758
+ * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
1843
1759
  */
1844
- matchesProjectFilter(name: string): boolean;
1845
- }
1846
- type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1847
- type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
1848
-
1849
- type TestRunEndReason = "passed" | "interrupted" | "failed";
1850
- interface Reporter {
1851
- onInit?: (vitest: Vitest) => void;
1760
+ readonly tmpDir: string;
1761
+ /** @inetrnal */ testFilesList: string[] | null;
1762
+ private runner;
1763
+ private closingPromise;
1764
+ private typecheckFilesList;
1765
+ private _globalSetups?;
1766
+ private _provided;
1767
+ constructor(vitest: Vitest, options?: InitializeProjectOptions | undefined, tmpDir?: string);
1852
1768
  /**
1853
- * Called when the project initiated the browser instance.
1854
- * project.browser will always be defined.
1855
- * @experimental
1769
+ * The unique hash of this project. This value is consistent between the reruns.
1770
+ *
1771
+ * It is based on the root of the project (not consistent between OS) and its name.
1856
1772
  */
1857
- onBrowserInit?: (project: TestProject) => Awaitable$1<void>;
1858
- onTestRemoved?: (trigger?: string) => Awaitable$1<void>;
1859
- onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable$1<void>;
1860
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable$1<void>;
1861
- onServerRestart?: (reason?: string) => Awaitable$1<void>;
1862
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable$1<void>;
1863
- onProcessTimeout?: () => Awaitable$1<void>;
1773
+ get hash(): string;
1864
1774
  /**
1865
- * Called when the new test run starts.
1775
+ * Provide a value to the test context. This value will be available to all tests with `inject`.
1866
1776
  */
1867
- onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable$1<void>;
1777
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1868
1778
  /**
1869
- * Called when the test run is finished.
1779
+ * Get the provided context. The project context is merged with the global context.
1870
1780
  */
1871
- onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable$1<void>;
1781
+ getProvidedContext(): ProvidedContext;
1872
1782
  /**
1873
- * Called when the module is enqueued for testing. The file itself is not loaded yet.
1783
+ * Creates a new test specification. Specifications describe how to run tests.
1784
+ * @param moduleId The file path
1874
1785
  */
1875
- onTestModuleQueued?: (testModule: TestModule) => Awaitable$1<void>;
1786
+ createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
1787
+ toJSON(): SerializedTestProject;
1876
1788
  /**
1877
- * Called when the test file is loaded and the module is ready to run tests.
1789
+ * Vite's dev server instance. Every workspace project has its own server.
1878
1790
  */
1879
- onTestModuleCollected?: (testModule: TestModule) => Awaitable$1<void>;
1791
+ get vite(): ViteDevServer;
1880
1792
  /**
1881
- * Called when starting to run tests of the test file
1793
+ * Resolved project configuration.
1882
1794
  */
1883
- onTestModuleStart?: (testModule: TestModule) => Awaitable$1<void>;
1795
+ get config(): ResolvedConfig;
1884
1796
  /**
1885
- * Called when all tests of the test file have finished running.
1797
+ * The name of the project or an empty string if not set.
1886
1798
  */
1887
- onTestModuleEnd?: (testModule: TestModule) => Awaitable$1<void>;
1799
+ get name(): string;
1888
1800
  /**
1889
- * Called when test case is ready to run.
1890
- * Called before the `beforeEach` hooks for the test are run.
1801
+ * The color used when reporting tasks of this project.
1891
1802
  */
1892
- onTestCaseReady?: (testCase: TestCase) => Awaitable$1<void>;
1803
+ get color(): ProjectName["color"];
1893
1804
  /**
1894
- * Called after the test and its hooks are finished running.
1895
- * The `result()` cannot be `pending`.
1805
+ * Serialized project configuration. This is the config that tests receive.
1896
1806
  */
1897
- onTestCaseResult?: (testCase: TestCase) => Awaitable$1<void>;
1807
+ get serializedConfig(): SerializedConfig;
1898
1808
  /**
1899
- * Called when annotation is added via the `task.annotate` API.
1809
+ * Check if this is the root project. The root project is the one that has the root config.
1900
1810
  */
1901
- onTestCaseAnnotate?: (testCase: TestCase, annotation: TestAnnotation) => Awaitable$1<void>;
1811
+ isRootProject(): boolean;
1812
+ onTestsRerun(cb: OnTestsRerunHandler): void;
1902
1813
  /**
1903
- * Called when test suite is ready to run.
1904
- * Called before the `beforeAll` hooks for the test are run.
1814
+ * Get all files in the project that match the globs in the config and the filters.
1815
+ * @param filters String filters to match the test files.
1905
1816
  */
1906
- onTestSuiteReady?: (testSuite: TestSuite) => Awaitable$1<void>;
1817
+ globTestFiles(filters?: string[]): Promise<{
1818
+ /**
1819
+ * Test files that match the filters.
1820
+ */
1821
+ testFiles: string[];
1822
+ /**
1823
+ * Typecheck test files that match the filters. This will be empty unless `typecheck.enabled` is `true`.
1824
+ */
1825
+ typecheckTestFiles: string[];
1826
+ }>;
1827
+ private globAllTestFiles;
1828
+ isBrowserEnabled(): boolean;
1829
+ private markTestFile;
1907
1830
  /**
1908
- * Called after the test suite and its hooks are finished running.
1909
- * The `state` cannot be `pending`.
1831
+ * Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
1910
1832
  */
1911
- onTestSuiteResult?: (testSuite: TestSuite) => Awaitable$1<void>;
1833
+ matchesTestGlob(moduleId: string, source?: () => string): boolean;
1834
+ private isInSourceTestCode;
1835
+ private filterFiles;
1836
+ private _parentBrowser?;
1912
1837
  /**
1913
- * Called before the hook starts to run.
1838
+ * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
1839
+ * If the resources are needed again, create a new project.
1914
1840
  */
1915
- onHookStart?: (hook: ReportedHookContext) => Awaitable$1<void>;
1841
+ close(): Promise<void>;
1916
1842
  /**
1917
- * Called after the hook finished running.
1843
+ * Import a file using Vite module runner.
1844
+ * @param moduleId The ID of the module in Vite module graph
1918
1845
  */
1919
- onHookEnd?: (hook: ReportedHookContext) => Awaitable$1<void>;
1920
- onCoverage?: (coverage: unknown) => Awaitable$1<void>;
1846
+ import<T>(moduleId: string): Promise<T>;
1847
+ private _setHash;
1848
+ private _serializeOverriddenConfig;
1849
+ private clearTmpDir;
1850
+ }
1851
+ interface SerializedTestProject {
1852
+ name: string;
1853
+ serializedConfig: SerializedConfig;
1854
+ context: ProvidedContext;
1855
+ }
1856
+ interface InitializeProjectOptions extends TestProjectInlineConfiguration {
1857
+ configFile: string | false;
1858
+ }
1859
+
1860
+ interface PoolRunnerInitializer {
1861
+ readonly name: string;
1862
+ createPoolWorker: (options: PoolOptions) => PoolWorker;
1921
1863
  }
1864
+ interface PoolOptions {
1865
+ distPath: string;
1866
+ project: TestProject;
1867
+ method: "run" | "collect";
1868
+ cacheFs?: boolean;
1869
+ environment: string;
1870
+ execArgv: string[];
1871
+ env: Partial<NodeJS.ProcessEnv>;
1872
+ }
1873
+ interface PoolWorker {
1874
+ readonly name: string;
1875
+ readonly reportMemory?: boolean;
1876
+ readonly cacheFs?: boolean;
1877
+ on: (event: string, callback: (arg: any) => void) => void;
1878
+ off: (event: string, callback: (arg: any) => void) => void;
1879
+ send: (message: WorkerRequest) => void;
1880
+ deserialize: (data: unknown) => unknown;
1881
+ start: () => Promise<void>;
1882
+ stop: () => Promise<void>;
1883
+ /**
1884
+ * This is called on workers that already satisfy certain constraints:
1885
+ * - The task has the same project
1886
+ * - The task has the same environment
1887
+ */
1888
+ canReuse?: (task: PoolTask) => boolean;
1889
+ }
1890
+ interface PoolTask {
1891
+ worker: "forks" | "threads" | "vmForks" | "vmThreads" | (string & {});
1892
+ project: TestProject;
1893
+ isolate: boolean;
1894
+ env: Partial<NodeJS.ProcessEnv>;
1895
+ execArgv: string[];
1896
+ context: ContextRPC;
1897
+ memoryLimit: number | null;
1898
+ }
1899
+ type WorkerRequest = {
1900
+ __vitest_worker_request__: true;
1901
+ } & ({
1902
+ type: "start";
1903
+ options: {
1904
+ reportMemory: boolean;
1905
+ };
1906
+ } | {
1907
+ type: "stop";
1908
+ } | {
1909
+ type: "run";
1910
+ context: ContextRPC;
1911
+ poolId: number;
1912
+ } | {
1913
+ type: "collect";
1914
+ context: ContextRPC;
1915
+ poolId: number;
1916
+ } | {
1917
+ type: "cancel";
1918
+ });
1919
+ type WorkerResponse = {
1920
+ __vitest_worker_response__: true;
1921
+ } & ({
1922
+ type: "started";
1923
+ } | {
1924
+ type: "stopped";
1925
+ error?: unknown;
1926
+ } | {
1927
+ type: "testfileFinished";
1928
+ usedMemory?: number;
1929
+ error?: unknown;
1930
+ });
1922
1931
 
1923
1932
  interface BaseOptions {
1924
1933
  isTTY?: boolean;
@@ -1947,13 +1956,15 @@ declare abstract class BaseReporter implements Reporter {
1947
1956
  protected printTestModule(testModule: TestModule): void;
1948
1957
  protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
1949
1958
  private getModuleLog;
1950
- protected printTestSuite(_suite: TestSuite): void;
1951
- protected getTestName(test: Task, separator?: string): string;
1959
+ protected printTestSuite(testSuite: TestSuite): void;
1960
+ protected getTestName(test: Task, _separator?: string): string;
1952
1961
  protected getFullName(test: Task, separator?: string): string;
1953
- protected formatShortError(error: TestError): string;
1954
- protected getTestIndentation(_test: Task): string;
1962
+ protected getTestIndentation(test: Task): string;
1955
1963
  protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
1956
- protected getDurationPrefix(task: Task): string;
1964
+ protected getEntityPrefix(entity: TestCase | TestModule | TestSuite): string;
1965
+ protected getTestCaseSuffix(testCase: TestCase): string;
1966
+ protected getStateSymbol(test: TestCase | TestModule | TestSuite): string;
1967
+ private getDurationPrefix;
1957
1968
  onWatcherStart(files?: File[], errors?: unknown[]): void;
1958
1969
  onWatcherRerun(files: string[], trigger?: string): void;
1959
1970
  onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
@@ -1986,13 +1997,26 @@ declare class DefaultReporter extends BaseReporter {
1986
1997
  onInit(ctx: Vitest): void;
1987
1998
  }
1988
1999
 
2000
+ interface GithubActionsReporterOptions {
2001
+ onWritePath?: (path: string) => string;
2002
+ /**
2003
+ * @default true
2004
+ */
2005
+ displayAnnotations?: boolean;
2006
+ }
2007
+ declare class GithubActionsReporter implements Reporter {
2008
+ ctx: Vitest;
2009
+ options: GithubActionsReporterOptions;
2010
+ constructor(options?: GithubActionsReporterOptions);
2011
+ onInit(ctx: Vitest): void;
2012
+ onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void;
2013
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): void;
2014
+ }
2015
+
1989
2016
  interface HTMLOptions {
1990
2017
  outputFile?: string;
1991
2018
  }
1992
2019
 
1993
- // for compatibility reasons, the reporter produces a JSON similar to the one produced by the Jest JSON reporter
1994
- // the following types are extracted from the Jest repository (and simplified)
1995
- // the commented-out fields are the missing ones
1996
2020
  type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled";
1997
2021
  type Milliseconds = number;
1998
2022
  interface Callsite {
@@ -2096,7 +2120,6 @@ declare class DotReporter extends BaseReporter {
2096
2120
  private tests;
2097
2121
  private finishedTests;
2098
2122
  onInit(ctx: Vitest): void;
2099
- // Ignore default logging of base reporter
2100
2123
  printTestModule(): void;
2101
2124
  onWatcherRerun(files: string[], trigger?: string): void;
2102
2125
  onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
@@ -2107,18 +2130,6 @@ declare class DotReporter extends BaseReporter {
2107
2130
  private createSummary;
2108
2131
  }
2109
2132
 
2110
- interface GithubActionsReporterOptions {
2111
- onWritePath?: (path: string) => string;
2112
- }
2113
- declare class GithubActionsReporter implements Reporter {
2114
- ctx: Vitest;
2115
- options: GithubActionsReporterOptions;
2116
- constructor(options?: GithubActionsReporterOptions);
2117
- onInit(ctx: Vitest): void;
2118
- onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void;
2119
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): void;
2120
- }
2121
-
2122
2133
  declare class HangingProcessReporter implements Reporter {
2123
2134
  whyRunning: (() => void) | undefined;
2124
2135
  onInit(): void;
@@ -2140,15 +2151,16 @@ declare class TapFlatReporter extends TapReporter {
2140
2151
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
2141
2152
  }
2142
2153
 
2154
+ declare class TreeReporter extends DefaultReporter {
2155
+ protected verbose: boolean;
2156
+ renderSucceed: boolean;
2157
+ }
2158
+
2143
2159
  declare class VerboseReporter extends DefaultReporter {
2144
2160
  protected verbose: boolean;
2145
2161
  renderSucceed: boolean;
2146
- printTestModule(module: TestModule): void;
2162
+ printTestModule(_module: TestModule): void;
2147
2163
  onTestCaseResult(test: TestCase): void;
2148
- protected printTestSuite(testSuite: TestSuite): void;
2149
- protected getTestName(test: Task): string;
2150
- protected getTestIndentation(test: Task): string;
2151
- protected formatShortError(): string;
2152
2164
  }
2153
2165
 
2154
2166
  type FormattedBenchmarkResult = BenchmarkResult & {
@@ -2194,6 +2206,7 @@ declare const ReportersMap: {
2194
2206
  tap: typeof TapReporter;
2195
2207
  "tap-flat": typeof TapFlatReporter;
2196
2208
  junit: typeof JUnitReporter;
2209
+ tree: typeof TreeReporter;
2197
2210
  "hanging-process": typeof HangingProcessReporter;
2198
2211
  "github-actions": typeof GithubActionsReporter;
2199
2212
  };
@@ -2202,6 +2215,7 @@ interface BuiltinReporterOptions {
2202
2215
  "default": DefaultReporterOptions;
2203
2216
  "verbose": DefaultReporterOptions;
2204
2217
  "dot": BaseOptions;
2218
+ "tree": BaseOptions;
2205
2219
  "json": JsonOptions;
2206
2220
  "blob": BlobOptions;
2207
2221
  "tap": never;
@@ -2209,6 +2223,7 @@ interface BuiltinReporterOptions {
2209
2223
  "junit": JUnitOptions;
2210
2224
  "hanging-process": never;
2211
2225
  "html": HTMLOptions;
2226
+ "github-actions": GithubActionsReporterOptions;
2212
2227
  }
2213
2228
 
2214
2229
  interface TestSequencer {
@@ -2216,8 +2231,8 @@ interface TestSequencer {
2216
2231
  * Slicing tests into shards. Will be run before `sort`.
2217
2232
  * Only run, if `shard` is defined.
2218
2233
  */
2219
- shard: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2220
- sort: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2234
+ shard: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
2235
+ sort: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
2221
2236
  }
2222
2237
  interface TestSequencerConstructor {
2223
2238
  new (ctx: Vitest): TestSequencer;
@@ -2247,7 +2262,7 @@ interface BenchmarkUserOptions {
2247
2262
  *
2248
2263
  * @default ['default']
2249
2264
  */
2250
- reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
2265
+ reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
2251
2266
  /**
2252
2267
  * @deprecated Use `benchmark.outputJson` instead
2253
2268
  */
@@ -2269,9 +2284,7 @@ interface BenchmarkUserOptions {
2269
2284
  }
2270
2285
 
2271
2286
  type BuiltinEnvironment = "node" | "jsdom" | "happy-dom" | "edge-runtime";
2272
- // Record is used, so user can get intellisense for builtin environments, but still allow custom environments
2273
2287
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
2274
-
2275
2288
  type CSSModuleScopeStrategy = "stable" | "scoped" | "non-scoped";
2276
2289
  type ApiConfig = Pick<ServerOptions, "port" | "strictPort" | "host" | "middlewareMode">;
2277
2290
  interface EnvironmentOptions {
@@ -2408,6 +2421,8 @@ interface ResolveSnapshotPathHandlerContext {
2408
2421
  config: SerializedConfig;
2409
2422
  }
2410
2423
  type ResolveSnapshotPathHandler = (testPath: string, snapExtension: string, context: ResolveSnapshotPathHandlerContext) => string;
2424
+ type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
2425
+ type Pool = BuiltinPool | (string & {});
2411
2426
  interface InlineConfig {
2412
2427
  /**
2413
2428
  * Name of the project. Will be used to display in the reporter.
@@ -2443,6 +2458,23 @@ interface InlineConfig {
2443
2458
  deps?: DepsOptions;
2444
2459
  server?: {
2445
2460
  deps?: ServerDepsOptions;
2461
+ debug?: {
2462
+ /**
2463
+ * The folder where Vitest stores the contents of transformed
2464
+ * test files that can be inspected manually.
2465
+ *
2466
+ * If `true`, Vitest dumps the files in `.vitest-dump` folder relative to the root of the project.
2467
+ *
2468
+ * You can also use `VITEST_DEBUG_DUMP` env variable to enable this.
2469
+ */
2470
+ dump?: string | true;
2471
+ /**
2472
+ * If dump is enabled, should Vitest load the files from there instead of transforming them.
2473
+ *
2474
+ * You can also use `VITEST_DEBUG_LOAD_DUMP` env variable to enable this.
2475
+ */
2476
+ load?: boolean;
2477
+ };
2446
2478
  };
2447
2479
  /**
2448
2480
  * Base directory to scan for the test files
@@ -2473,34 +2505,43 @@ interface InlineConfig {
2473
2505
  /**
2474
2506
  * Run tests in an isolated environment. This option has no effect on vmThreads pool.
2475
2507
  *
2476
- * Disabling this option might improve performance if your code doesn't rely on side effects.
2508
+ * Disabling this option improves performance if your code doesn't rely on side effects.
2477
2509
  *
2478
2510
  * @default true
2479
2511
  */
2480
2512
  isolate?: boolean;
2481
2513
  /**
2482
- * Pool used to run tests in.
2514
+ * Pass additional arguments to `node` process when spawning the worker.
2483
2515
  *
2484
- * Supports 'threads', 'forks', 'vmThreads'
2516
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
2485
2517
  *
2486
- * @default 'forks'
2518
+ * Set to `process.execArgv` to pass all arguments of the current process.
2519
+ *
2520
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
2521
+ *
2522
+ * @default [] // no execution arguments are passed
2487
2523
  */
2488
- pool?: Exclude<Pool, "browser">;
2524
+ execArgv?: string[];
2489
2525
  /**
2490
- * Pool options
2526
+ * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
2527
+ * If you see memory leaks, try to tinker this value.
2491
2528
  */
2492
- poolOptions?: PoolOptions;
2529
+ vmMemoryLimit?: string | number;
2493
2530
  /**
2494
- * Maximum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.maxThreads`/`poolOptions.forks.maxForks` has higher priority.
2531
+ * Pool used to run tests in.
2532
+ *
2533
+ * Supports 'threads', 'forks', 'vmThreads', 'vmForks'
2534
+ *
2535
+ * @default 'forks'
2495
2536
  */
2496
- maxWorkers?: number | string;
2537
+ pool?: Exclude<Pool, "browser"> | PoolRunnerInitializer;
2497
2538
  /**
2498
- * Minimum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.minThreads`/`poolOptions.forks.minForks` has higher priority.
2539
+ * Maximum number or percentage of workers to run tests in.
2499
2540
  */
2500
- minWorkers?: number | string;
2541
+ maxWorkers?: number | string;
2501
2542
  /**
2502
2543
  * Should all test files run in parallel. Doesn't affect tests running in the same file.
2503
- * Setting this to `false` will override `maxWorkers` and `minWorkers` options to `1`.
2544
+ * Setting this to `false` will override `maxWorkers` option to `1`.
2504
2545
  *
2505
2546
  * @default true
2506
2547
  */
@@ -2641,7 +2682,6 @@ interface InlineConfig {
2641
2682
  ui?: boolean;
2642
2683
  /**
2643
2684
  * options for test in a browser environment
2644
- * @experimental
2645
2685
  *
2646
2686
  * @default false
2647
2687
  */
@@ -2782,14 +2822,14 @@ interface InlineConfig {
2782
2822
  * Debug tests by opening `node:inspector` in worker / child process.
2783
2823
  * Provides similar experience as `--inspect` Node CLI argument.
2784
2824
  *
2785
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2825
+ * Requires `fileParallelism: false`.
2786
2826
  */
2787
2827
  inspect?: boolean | string;
2788
2828
  /**
2789
2829
  * Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
2790
2830
  * Provides similar experience as `--inspect-brk` Node CLI argument.
2791
2831
  *
2792
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2832
+ * Requires `fileParallelism: false`.
2793
2833
  */
2794
2834
  inspectBrk?: boolean | string;
2795
2835
  /**
@@ -3023,7 +3063,7 @@ interface UserConfig extends InlineConfig {
3023
3063
  type OnUnhandledErrorCallback = (error: (TestError | Error) & {
3024
3064
  type: string;
3025
3065
  }) => boolean | void;
3026
- interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "poolOptions" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name"> {
3066
+ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit"> {
3027
3067
  mode: VitestRunMode;
3028
3068
  name: ProjectName["label"];
3029
3069
  color?: ProjectName["color"];
@@ -3040,7 +3080,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3040
3080
  snapshotOptions: SnapshotStateOptions;
3041
3081
  browser: ResolvedBrowserOptions;
3042
3082
  pool: Pool;
3043
- poolOptions?: ResolvedPoolOptions;
3083
+ poolRunner?: PoolRunnerInitializer;
3044
3084
  reporters: (InlineReporter | ReporterWithOptions)[];
3045
3085
  defines: Record<string, any>;
3046
3086
  api: ApiConfig & {
@@ -3073,9 +3113,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3073
3113
  };
3074
3114
  runner?: string;
3075
3115
  maxWorkers: number;
3076
- minWorkers: number;
3116
+ vmMemoryLimit?: UserConfig["vmMemoryLimit"];
3117
+ dumpDir?: string;
3077
3118
  }
3078
- 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";
3119
+ 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" | "watchTriggerPatterns";
3079
3120
  interface ServerDepsOptions {
3080
3121
  /**
3081
3122
  * Externalize means that Vite will bpass the package to native Node.
@@ -3100,21 +3141,16 @@ interface ServerDepsOptions {
3100
3141
  */
3101
3142
  fallbackCJS?: boolean;
3102
3143
  }
3103
- type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
3144
+ type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps"> & {
3104
3145
  mode?: string;
3105
3146
  sequencer?: Omit<SequenceOptions, "sequencer" | "seed">;
3106
3147
  deps?: Omit<DepsOptions, "moduleDirectories">;
3107
- poolOptions?: {
3108
- threads?: Pick<NonNullable<PoolOptions["threads"]>, "singleThread" | "isolate">;
3109
- vmThreads?: Pick<NonNullable<PoolOptions["vmThreads"]>, "singleThread">;
3110
- forks?: Pick<NonNullable<PoolOptions["forks"]>, "singleFork" | "isolate">;
3111
- };
3148
+ fileParallelism?: boolean;
3112
3149
  };
3113
3150
  type ResolvedProjectConfig = Omit<ResolvedConfig, Exclude<NonProjectOptions, "coverage" | "watch">>;
3114
3151
  interface UserWorkspaceConfig extends UserConfig$1 {
3115
3152
  test?: ProjectConfig;
3116
3153
  }
3117
- // TODO: remove types when "workspace" support is removed
3118
3154
  type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
3119
3155
  type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3120
3156
  type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
@@ -3127,5 +3163,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3127
3163
  });
3128
3164
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3129
3165
 
3130
- export { TestSuite as B, CoverageMap as C, experimental_getRunnerTask as E, Logger as L, TestProject as T, Vitest as V, DefaultReporter as aA, DotReporter as aB, GithubActionsReporter as aC, HangingProcessReporter as aD, JsonReporter as aE, JUnitReporter as aF, ReportersMap as aG, TapFlatReporter as aH, TapReporter as aI, VerboseBenchmarkReporter as aJ, VerboseReporter as aK, BaseReporter as aL, BenchmarkReporter as ay, BenchmarkReportsMap as az, TestSpecification as k, VitestPackageInstaller as n, TestCase as q, TestCollection as r, TestModule as t };
3131
- export type { BrowserProvider as $, ApiConfig as A, TestSuiteState as D, TestSequencerConstructor as F, BenchmarkUserOptions as G, HTMLOptions as H, InlineConfig as I, JsonOptions as J, BrowserBuiltinProvider as K, ModuleDiagnostic as M, BrowserCommand as N, OnServerRestartHandler as O, Pool as P, BrowserCommandContext as Q, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, BrowserConfigOptions as X, BrowserInstanceOption as Y, BrowserModuleMocker as Z, BrowserOrchestrator as _, TestProjectConfiguration as a, BrowserProviderInitializationOptions as a0, BrowserProviderModule as a1, BrowserProviderOptions as a2, BrowserScript as a3, BrowserServerState as a4, BrowserServerStateSession as a5, CDPSession as a6, ParentProjectBrowser as a7, ProjectBrowser as a8, ResolvedBrowserOptions as a9, BenchmarkBuiltinReporters as aM, BuiltinReporterOptions as aN, BuiltinReporters as aO, JsonAssertionResult as aP, JsonTestResult as aQ, JsonTestResults as aR, ToMatchScreenshotComparators as aa, ToMatchScreenshotOptions as ab, BuiltinEnvironment as ac, CSSModuleScopeStrategy as ad, DepsOptimizationOptions as ae, EnvironmentOptions as af, PoolOptions as ag, ProjectConfig as ah, ResolvedProjectConfig as ai, ResolveSnapshotPathHandler as aj, ResolveSnapshotPathHandlerContext as ak, TypecheckConfig as al, VitestEnvironment as am, BaseCoverageOptions as an, CoverageIstanbulOptions as ao, CoverageOptions as ap, CoverageProvider as aq, CoverageProviderModule as ar, CoverageReporter as as, CustomProviderOptions as at, TestRunResult as au, ReportedHookContext as av, Reporter as aw, TestRunEndReason as ax, 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 l, OnTestsRerunHandler as m, JUnitOptions as o, TaskOptions as p, TestDiagnostic as s, TestModuleState as u, TestResult as v, TestResultFailed as w, TestResultPassed as x, TestResultSkipped as y, TestState as z };
3166
+ export { CoverageMap as C, TestSuite as K, Logger as L, experimental_getRunnerTask as Q, TestProject as T, Vitest as V, BenchmarkReporter as aE, BenchmarkReportsMap as aF, DefaultReporter as aG, DotReporter as aH, GithubActionsReporter as aI, HangingProcessReporter as aJ, JsonReporter as aK, JUnitReporter as aL, ReportersMap as aM, TapFlatReporter as aN, TapReporter as aO, VerboseBenchmarkReporter as aP, VerboseReporter as aQ, BaseReporter as aR, TestSpecification as k, VitestPackageInstaller as p, TestCase as v, TestCollection as w, TestModule as y };
3167
+ export type { BrowserCommand as $, ApiConfig as A, TestResult as B, TestResultFailed as D, TestResultPassed as E, TestResultSkipped as F, TestState as G, HTMLOptions as H, InlineConfig as I, JsonOptions as J, ModuleDiagnostic as M, TestSuiteState as N, OnServerRestartHandler as O, PoolWorker as P, ResolvedCoverageOptions as R, SerializedTestProject as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, TestSequencerConstructor as X, BenchmarkUserOptions as Y, BrowserBuiltinProvider as Z, _BrowserNames as _, TestProjectConfiguration as a, BrowserCommandContext as a0, BrowserConfigOptions as a1, BrowserInstanceOption as a2, BrowserModuleMocker as a3, BrowserOrchestrator as a4, BrowserProvider as a5, BrowserProviderOption as a6, BrowserScript as a7, BrowserServerFactory as a8, BrowserServerOptions as a9, TestRunResult as aA, ReportedHookContext as aB, Reporter as aC, TestRunEndReason as aD, BenchmarkBuiltinReporters as aS, BuiltinReporterOptions as aT, BuiltinReporters as aU, JsonAssertionResult as aV, JsonTestResult as aW, JsonTestResults as aX, BrowserServerState as aa, BrowserServerStateSession as ab, CDPSession as ac, ParentProjectBrowser as ad, ProjectBrowser as ae, ResolvedBrowserOptions as af, ToMatchScreenshotComparators as ag, ToMatchScreenshotOptions as ah, BuiltinEnvironment as ai, CSSModuleScopeStrategy as aj, DepsOptimizationOptions as ak, EnvironmentOptions as al, Pool as am, ProjectConfig as an, ResolvedProjectConfig as ao, ResolveSnapshotPathHandler as ap, ResolveSnapshotPathHandlerContext as aq, TypecheckConfig as ar, VitestEnvironment as as, BaseCoverageOptions as at, CoverageIstanbulOptions as au, CoverageOptions as av, CoverageProvider as aw, CoverageProviderModule as ax, CoverageReporter as ay, CustomProviderOptions 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, PoolOptions as l, WorkerRequest as m, TestSequencer as n, OnTestsRerunHandler as o, PoolRunnerInitializer as q, PoolTask as r, WorkerResponse as s, JUnitOptions as t, TaskOptions as u, TestDiagnostic as x, TestModuleState as z };