vitest 4.0.0-beta.9 → 4.0.1

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 (83) 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 +24 -7
  5. package/dist/browser.js +15 -5
  6. package/dist/chunks/{base.CA5N8Af0.js → base.BYPMk0VN.js} +36 -36
  7. package/dist/chunks/{benchmark.CJUa-Hsa.js → benchmark.DHKMYAts.js} +2 -2
  8. package/dist/chunks/{browser.d.DtfyY9yS.d.ts → browser.d.B9iJzZyn.d.ts} +3 -3
  9. package/dist/chunks/{cac.Dt7e1TIu.js → cac.DrF4Gm0S.js} +47 -73
  10. package/dist/chunks/{cli-api.eAzsLIxz.js → cli-api.W2Q-JQoO.js} +1524 -296
  11. package/dist/chunks/{config.d.DacWrqWe.d.ts → config.d.u2CUDWwS.d.ts} +5 -19
  12. package/dist/chunks/{console.7h5kHUIf.js → console.CTJL2nuH.js} +4 -6
  13. package/dist/chunks/{coverage.CDRAMTt7.js → coverage.FU3w4IrQ.js} +125 -1108
  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.CJrTTbxC.js → globals.BGT_RUsD.js} +11 -7
  20. package/dist/chunks/{index.BjKEiSn0.js → index.BdSLhLDZ.js} +3 -3
  21. package/dist/chunks/{index.DfviD7lX.js → index.CbWINfS7.js} +49 -21
  22. package/dist/chunks/{index.BIP7prJq.js → index.CcRZ6fUh.js} +1493 -114
  23. package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
  24. package/dist/chunks/{index.C832ioot.js → index.RwjEGCQ0.js} +4 -4
  25. package/dist/chunks/init-forks.WglB-sfY.js +54 -0
  26. package/dist/chunks/init-threads.Czek6eA5.js +17 -0
  27. package/dist/chunks/init.94FWN9pW.js +213 -0
  28. package/dist/chunks/{inspector.CvQD-Nie.js → inspector.DLZxSeU3.js} +2 -6
  29. package/dist/chunks/{moduleRunner.d.DxTLreRD.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +9 -14
  30. package/dist/chunks/{node.CyipiPvJ.js → node.BwAWWjHZ.js} +3 -4
  31. package/dist/chunks/{plugin.d.CIk0YiKb.d.ts → plugin.d.DQU1R5px.d.ts} +1 -1
  32. package/dist/chunks/{reporters.d.DmP-iHLr.d.ts → reporters.d.BMKt7f6I.d.ts} +1064 -1021
  33. package/dist/chunks/{resolveSnapshotEnvironment.Bvv2zr69.js → resolveSnapshotEnvironment.DJJKMKxb.js} +7 -8
  34. package/dist/chunks/{rpc.BKr6mtxz.js → rpc.cD77ENhU.js} +13 -14
  35. package/dist/chunks/{setup-common.B7I37Tji.js → setup-common.DR1sucx6.js} +6 -6
  36. package/dist/chunks/{startModuleRunner.BDRvKSdz.js → startModuleRunner.iF1E9Bt4.js} +126 -110
  37. package/dist/chunks/{test.BAlBebnP.js → test.C3RPt8JR.js} +7 -7
  38. package/dist/chunks/{utils.D2R2NiOH.js → utils.CG9h5ccR.js} +2 -5
  39. package/dist/chunks/{vi.BB37KeLx.js → vi.BZvkKVkM.js} +61 -164
  40. package/dist/chunks/{vm.CjLTDaST.js → vm.CuMWYx_F.js} +20 -29
  41. package/dist/chunks/{worker.d.B2r4Ln6p.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 +11 -13
  45. package/dist/config.js +1 -1
  46. package/dist/coverage.d.ts +7 -6
  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 +20 -25
  51. package/dist/index.js +11 -7
  52. package/dist/module-evaluator.d.ts +5 -4
  53. package/dist/module-evaluator.js +11 -13
  54. package/dist/module-runner.js +5 -5
  55. package/dist/node.d.ts +82 -25
  56. package/dist/node.js +23 -20
  57. package/dist/reporters.d.ts +10 -9
  58. package/dist/reporters.js +12 -11
  59. package/dist/runners.d.ts +1 -1
  60. package/dist/runners.js +9 -7
  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 -165
  65. package/dist/workers/forks.js +26 -43
  66. package/dist/workers/runVmTests.js +16 -12
  67. package/dist/workers/threads.js +26 -31
  68. package/dist/workers/vmForks.js +26 -39
  69. package/dist/workers/vmThreads.js +26 -29
  70. package/package.json +48 -32
  71. package/worker.d.ts +1 -0
  72. package/browser.d.ts +0 -1
  73. package/dist/chunks/environment.d.2fYMoz3o.d.ts +0 -66
  74. package/dist/chunks/moduleTransport.I-bgQy0S.js +0 -19
  75. package/dist/chunks/resolver.Bx6lE0iq.js +0 -119
  76. package/dist/chunks/typechecker.DB-fIMaH.js +0 -805
  77. package/dist/chunks/utils.C2YI6McM.js +0 -52
  78. package/dist/chunks/worker.d.DJ6qxO2w.d.ts +0 -8
  79. package/dist/workers.d.ts +0 -38
  80. package/dist/workers.js +0 -49
  81. package/execute.d.ts +0 -1
  82. package/utils.d.ts +0 -1
  83. package/workers.d.ts +0 -1
@@ -1,12 +1,13 @@
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.DtfyY9yS.js';
9
- import { a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.DacWrqWe.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';
@@ -69,471 +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
- /** Maximum amount of threads to use */
464
- maxThreads?: number | string;
307
+ interface TestResultSkipped {
465
308
  /**
466
- * Run tests inside a single thread.
467
- *
468
- * @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.
469
311
  */
470
- singleThread?: boolean;
312
+ readonly state: "skipped";
471
313
  /**
472
- * Use Atomics to synchronize threads
473
- *
474
- * This can improve performance in some cases, but might cause segfault in older Node versions.
475
- *
476
- * @default false
314
+ * Skipped tests have no errors.
477
315
  */
478
- useAtomics?: boolean;
479
- }
480
- interface ResolvedThreadsOptions extends ThreadsOptions {
481
- maxThreads?: number;
482
- }
483
- interface ForksOptions {
484
- /** Maximum amount of child processes to use */
485
- maxForks?: number | string;
316
+ readonly errors: undefined;
486
317
  /**
487
- * Run tests inside a single fork.
488
- *
489
- * @default false
318
+ * A custom note passed down to `ctx.skip(note)`.
490
319
  */
491
- singleFork?: boolean;
492
- }
493
- interface ResolvedForksOptions extends ForksOptions {
494
- maxForks?: number;
320
+ readonly note: string | undefined;
495
321
  }
496
- interface WorkerContextOptions {
322
+ interface TestDiagnostic {
497
323
  /**
498
- * Isolate test environment by recycling `worker_threads` or `child_process` after each test
499
- *
500
- * @default true
324
+ * If the duration of the test is above `slowTestThreshold`.
501
325
  */
502
- isolate?: boolean;
326
+ readonly slow: boolean;
503
327
  /**
504
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
505
- *
506
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
507
- *
508
- * Set to `process.execArgv` to pass all arguments of the current process.
509
- *
510
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
511
- *
512
- * @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.
513
330
  */
514
- 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;
515
353
  }
516
- interface VmOptions {
354
+ interface ModuleDiagnostic {
517
355
  /**
518
- * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
519
- * If you see memory leaks, try to tinker this value.
356
+ * The time it takes to import and initiate an environment.
520
357
  */
521
- memoryLimit?: string | number;
522
- /** Isolation is always enabled */
523
- isolate?: true;
358
+ readonly environmentSetupDuration: number;
524
359
  /**
525
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
526
- *
527
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
528
- *
529
- * Set to `process.execArgv` to pass all arguments of the current process.
530
- *
531
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
532
- *
533
- * @default [] // no execution arguments are passed
360
+ * The time it takes Vitest to setup test harness (runner, mocks, etc.).
534
361
  */
535
- 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>;
536
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;
537
390
 
538
391
  declare class TestSpecification {
539
392
  /**
@@ -565,440 +418,6 @@ declare class TestSpecification {
565
418
  toJSON(): SerializedTestSpecification;
566
419
  }
567
420
 
568
- declare class TestProject {
569
- options?: Vitest;
570
- /**
571
- * The global Vitest instance.
572
- * @experimental The public Vitest API is experimental and does not follow semver.
573
- */
574
- readonly vitest: Vitest;
575
- /**
576
- * Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
577
- */
578
- readonly globalConfig: ResolvedConfig;
579
- /**
580
- * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
581
- */
582
- browser?: ProjectBrowser;
583
- /**
584
- * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
585
- */
586
- readonly tmpDir: string;
587
- /** @inetrnal */ testFilesList: string[] | null;
588
- private runner;
589
- private closingPromise;
590
- private typecheckFilesList;
591
- private _globalSetups?;
592
- private _provided;
593
- constructor(vitest: Vitest, options?: InitializeProjectOptions | undefined);
594
- /**
595
- * The unique hash of this project. This value is consistent between the reruns.
596
- *
597
- * It is based on the root of the project (not consistent between OS) and its name.
598
- */
599
- get hash(): string;
600
- // "provide" is a property, not a method to keep the context when destructed in the global setup,
601
- // making it a method would be a breaking change, and can be done in Vitest 3 at minimum
602
- /**
603
- * Provide a value to the test context. This value will be available to all tests with `inject`.
604
- */
605
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
606
- /**
607
- * Get the provided context. The project context is merged with the global context.
608
- */
609
- getProvidedContext(): ProvidedContext;
610
- /**
611
- * Creates a new test specification. Specifications describe how to run tests.
612
- * @param moduleId The file path
613
- */
614
- createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
615
- toJSON(): SerializedTestProject;
616
- /**
617
- * Vite's dev server instance. Every workspace project has its own server.
618
- */
619
- get vite(): ViteDevServer;
620
- /**
621
- * Resolved project configuration.
622
- */
623
- get config(): ResolvedConfig;
624
- /**
625
- * The name of the project or an empty string if not set.
626
- */
627
- get name(): string;
628
- /**
629
- * The color used when reporting tasks of this project.
630
- */
631
- get color(): ProjectName["color"];
632
- /**
633
- * Serialized project configuration. This is the config that tests receive.
634
- */
635
- get serializedConfig(): SerializedConfig;
636
- /**
637
- * Check if this is the root project. The root project is the one that has the root config.
638
- */
639
- isRootProject(): boolean;
640
- onTestsRerun(cb: OnTestsRerunHandler): void;
641
- /**
642
- * Get all files in the project that match the globs in the config and the filters.
643
- * @param filters String filters to match the test files.
644
- */
645
- globTestFiles(filters?: string[]): Promise<{
646
- /**
647
- * Test files that match the filters.
648
- */
649
- testFiles: string[];
650
- /**
651
- * Typecheck test files that match the filters. This will be empty unless `typecheck.enabled` is `true`.
652
- */
653
- typecheckTestFiles: string[];
654
- }>;
655
- private globAllTestFiles;
656
- isBrowserEnabled(): boolean;
657
- private markTestFile;
658
- /**
659
- * Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
660
- */
661
- matchesTestGlob(moduleId: string, source?: () => string): boolean;
662
- private isInSourceTestCode;
663
- private filterFiles;
664
- private _parentBrowser?;
665
- /**
666
- * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
667
- * If the resources are needed again, create a new project.
668
- */
669
- close(): Promise<void>;
670
- /**
671
- * Import a file using Vite module runner.
672
- * @param moduleId The ID of the module in Vite module graph
673
- */
674
- import<T>(moduleId: string): Promise<T>;
675
- private _setHash;
676
- private _serializeOverriddenConfig;
677
- private clearTmpDir;
678
- }
679
- interface SerializedTestProject {
680
- name: string;
681
- serializedConfig: SerializedConfig;
682
- context: ProvidedContext;
683
- }
684
- interface InitializeProjectOptions extends TestProjectInlineConfiguration {
685
- configFile: string | false;
686
- }
687
-
688
- declare class ReportedTaskImplementation {
689
- /**
690
- * The project associated with the test or suite.
691
- */
692
- readonly project: TestProject;
693
- /**
694
- * Unique identifier.
695
- * This ID is deterministic and will be the same for the same test across multiple runs.
696
- * The ID is based on the project name, module url and test order.
697
- */
698
- readonly id: string;
699
- /**
700
- * Location in the module where the test or suite is defined.
701
- */
702
- readonly location: {
703
- line: number;
704
- column: number;
705
- } | undefined;
706
- /**
707
- * Checks if the test did not fail the suite.
708
- * If the test is not finished yet or was skipped, it will return `true`.
709
- */
710
- ok(): boolean;
711
- /**
712
- * Custom metadata that was attached to the test during its execution.
713
- */
714
- meta(): TaskMeta;
715
- }
716
- declare class TestCase extends ReportedTaskImplementation {
717
- #private;
718
- readonly type = "test";
719
- /**
720
- * Direct reference to the test module where the test or suite is defined.
721
- */
722
- readonly module: TestModule;
723
- /**
724
- * Name of the test.
725
- */
726
- readonly name: string;
727
- /**
728
- * Options that the test was initiated with.
729
- */
730
- readonly options: TaskOptions;
731
- /**
732
- * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
733
- */
734
- readonly parent: TestSuite | TestModule;
735
- /**
736
- * Full name of the test including all parent suites separated with `>`.
737
- */
738
- get fullName(): string;
739
- /**
740
- * Test results.
741
- * - **pending**: Test was collected, but didn't finish running yet.
742
- * - **passed**: Test passed successfully
743
- * - **failed**: Test failed to execute
744
- * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
745
- */
746
- result(): TestResult;
747
- /**
748
- * Test annotations added via the `task.annotate` API during the test execution.
749
- */
750
- annotations(): ReadonlyArray<TestAnnotation>;
751
- /**
752
- * Useful information about the test like duration, memory usage, etc.
753
- * Diagnostic is only available after the test has finished.
754
- */
755
- diagnostic(): TestDiagnostic | undefined;
756
- }
757
- declare class TestCollection {
758
- #private;
759
- constructor(task: Suite | File, project: TestProject);
760
- /**
761
- * Returns the test or suite at a specific index.
762
- */
763
- at(index: number): TestCase | TestSuite | undefined;
764
- /**
765
- * The number of tests and suites in the collection.
766
- */
767
- get size(): number;
768
- /**
769
- * Returns the collection in array form for easier manipulation.
770
- */
771
- array(): (TestCase | TestSuite)[];
772
- /**
773
- * Filters all tests that are part of this collection and its children.
774
- */
775
- allTests(state?: TestState): Generator<TestCase, undefined, void>;
776
- /**
777
- * Filters only the tests that are part of this collection.
778
- */
779
- tests(state?: TestState): Generator<TestCase, undefined, void>;
780
- /**
781
- * Filters only the suites that are part of this collection.
782
- */
783
- suites(): Generator<TestSuite, undefined, void>;
784
- /**
785
- * Filters all suites that are part of this collection and its children.
786
- */
787
- allSuites(): Generator<TestSuite, undefined, void>;
788
- [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
789
- }
790
-
791
- type ReportedHookContext = {
792
- readonly name: "beforeAll" | "afterAll";
793
- readonly entity: TestSuite | TestModule;
794
- } | {
795
- readonly name: "beforeEach" | "afterEach";
796
- readonly entity: TestCase;
797
- };
798
- declare abstract class SuiteImplementation extends ReportedTaskImplementation {
799
- /**
800
- * Collection of suites and tests that are part of this suite.
801
- */
802
- readonly children: TestCollection;
803
- /**
804
- * Errors that happened outside of the test run during collection, like syntax errors.
805
- */
806
- errors(): SerializedError[];
807
- }
808
- declare class TestSuite extends SuiteImplementation {
809
- #private;
810
- readonly type = "suite";
811
- /**
812
- * Name of the test or the suite.
813
- */
814
- readonly name: string;
815
- /**
816
- * Direct reference to the test module where the test or suite is defined.
817
- */
818
- readonly module: TestModule;
819
- /**
820
- * Parent suite. If suite was called directly inside the module, the parent will be the module itself.
821
- */
822
- readonly parent: TestSuite | TestModule;
823
- /**
824
- * Options that suite was initiated with.
825
- */
826
- readonly options: TaskOptions;
827
- /**
828
- * Checks if the suite has any failed tests.
829
- * This will also return `false` if suite failed during collection.
830
- */
831
- ok: () => boolean;
832
- /**
833
- * The meta information attached to the suite during its collection or execution.
834
- */
835
- meta: () => TaskMeta;
836
- /**
837
- * Checks the running state of the suite.
838
- */
839
- state(): TestSuiteState;
840
- /**
841
- * Full name of the suite including all parent suites separated with `>`.
842
- */
843
- get fullName(): string;
844
- }
845
- declare class TestModule extends SuiteImplementation {
846
- readonly location: undefined;
847
- readonly type = "module";
848
- /**
849
- * This is usually an absolute UNIX file path.
850
- * It can be a virtual ID if the file is not on the disk.
851
- * This value corresponds to the ID in the Vite's module graph.
852
- */
853
- readonly moduleId: string;
854
- /**
855
- * Checks the running state of the test file.
856
- */
857
- state(): TestModuleState;
858
- /**
859
- * Checks if the module has any failed tests.
860
- * This will also return `false` if module failed during collection.
861
- */
862
- ok: () => boolean;
863
- /**
864
- * The meta information attached to the module during its collection or execution.
865
- */
866
- meta: () => TaskMeta;
867
- /**
868
- * Useful information about the module like duration, memory usage, etc.
869
- * If the module was not executed yet, all diagnostic values will return `0`.
870
- */
871
- diagnostic(): ModuleDiagnostic;
872
- }
873
- interface TaskOptions {
874
- readonly each: boolean | undefined;
875
- readonly fails: boolean | undefined;
876
- readonly concurrent: boolean | undefined;
877
- readonly shuffle: boolean | undefined;
878
- readonly retry: number | undefined;
879
- readonly repeats: number | undefined;
880
- readonly mode: "run" | "only" | "skip" | "todo";
881
- }
882
- type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
883
- type TestModuleState = TestSuiteState | "queued";
884
- type TestState = TestResult["state"];
885
- type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
886
- interface TestResultPending {
887
- /**
888
- * The test was collected, but didn't finish running yet.
889
- */
890
- readonly state: "pending";
891
- /**
892
- * Pending tests have no errors.
893
- */
894
- readonly errors: undefined;
895
- }
896
- interface TestResultPassed {
897
- /**
898
- * The test passed successfully.
899
- */
900
- readonly state: "passed";
901
- /**
902
- * Errors that were thrown during the test execution.
903
- *
904
- * **Note**: If test was retried successfully, errors will still be reported.
905
- */
906
- readonly errors: ReadonlyArray<TestError> | undefined;
907
- }
908
- interface TestResultFailed {
909
- /**
910
- * The test failed to execute.
911
- */
912
- readonly state: "failed";
913
- /**
914
- * Errors that were thrown during the test execution.
915
- */
916
- readonly errors: ReadonlyArray<TestError>;
917
- }
918
- interface TestResultSkipped {
919
- /**
920
- * The test was skipped with `only` (on another test), `skip` or `todo` flag.
921
- * You can see which one was used in the `options.mode` option.
922
- */
923
- readonly state: "skipped";
924
- /**
925
- * Skipped tests have no errors.
926
- */
927
- readonly errors: undefined;
928
- /**
929
- * A custom note passed down to `ctx.skip(note)`.
930
- */
931
- readonly note: string | undefined;
932
- }
933
- interface TestDiagnostic {
934
- /**
935
- * If the duration of the test is above `slowTestThreshold`.
936
- */
937
- readonly slow: boolean;
938
- /**
939
- * The amount of memory used by the test in bytes.
940
- * This value is only available if the test was executed with `logHeapUsage` flag.
941
- */
942
- readonly heap: number | undefined;
943
- /**
944
- * The time it takes to execute the test in ms.
945
- */
946
- readonly duration: number;
947
- /**
948
- * The time in ms when the test started.
949
- */
950
- readonly startTime: number;
951
- /**
952
- * The amount of times the test was retried.
953
- */
954
- readonly retryCount: number;
955
- /**
956
- * The amount of times the test was repeated as configured by `repeats` option.
957
- * This value can be lower if the test failed during the repeat and no `retry` is configured.
958
- */
959
- readonly repeatCount: number;
960
- /**
961
- * If test passed on a second retry.
962
- */
963
- readonly flaky: boolean;
964
- }
965
- interface ModuleDiagnostic {
966
- /**
967
- * The time it takes to import and initiate an environment.
968
- */
969
- readonly environmentSetupDuration: number;
970
- /**
971
- * The time it takes Vitest to setup test harness (runner, mocks, etc.).
972
- */
973
- readonly prepareDuration: number;
974
- /**
975
- * The time it takes to import the test module.
976
- * This includes importing everything in the module and executing suite callbacks.
977
- */
978
- readonly collectDuration: number;
979
- /**
980
- * The time it takes to import the setup module.
981
- */
982
- readonly setupDuration: number;
983
- /**
984
- * Accumulated duration of all tests and hooks in the module.
985
- */
986
- readonly duration: number;
987
- /**
988
- * The amount of memory used by the test module in bytes.
989
- * This value is only available if the test was executed with `logHeapUsage` flag.
990
- */
991
- readonly heap: number | undefined;
992
- /**
993
- * The time spent importing every non-externalized dependency that Vitest has processed.
994
- */
995
- readonly importDurations: Record<string, ImportDuration>;
996
- }
997
- declare function experimental_getRunnerTask(entity: TestCase): Test;
998
- declare function experimental_getRunnerTask(entity: TestSuite): Suite;
999
- declare function experimental_getRunnerTask(entity: TestModule): File;
1000
- declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
1001
-
1002
421
  interface CoverageSummaryData {
1003
422
  lines: Totals;
1004
423
  statements: Totals;
@@ -1370,10 +789,11 @@ interface Thresholds {
1370
789
  perFile?: boolean;
1371
790
  /**
1372
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
1373
793
  *
1374
794
  * @default false
1375
795
  */
1376
- autoUpdate?: boolean;
796
+ autoUpdate?: boolean | ((newThreshold: number) => number);
1377
797
  /** Thresholds for statements */
1378
798
  statements?: number;
1379
799
  /** Thresholds for functions */
@@ -1483,6 +903,80 @@ declare class VitestPackageInstaller {
1483
903
  ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1484
904
  }
1485
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
+
1486
980
  interface BlobOptions {
1487
981
  outputFile?: string;
1488
982
  }
@@ -1509,10 +1003,19 @@ declare class StateManager {
1509
1003
  idMap: Map<string, Task>;
1510
1004
  taskFileMap: WeakMap<Task, File>;
1511
1005
  errorsSet: Set<unknown>;
1512
- processTimeoutCauses: Set<string>;
1513
1006
  reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1514
1007
  blobs?: MergedBlobs;
1515
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
+ }>;
1516
1019
  onUnhandledError?: OnUnhandledErrorCallback;
1517
1020
  constructor(options: {
1518
1021
  onUnhandledError?: OnUnhandledErrorCallback;
@@ -1520,8 +1023,6 @@ declare class StateManager {
1520
1023
  catchError(error: unknown, type: string): void;
1521
1024
  clearErrors(): void;
1522
1025
  getUnhandledErrors(): unknown[];
1523
- addProcessTimeoutCause(cause: string): void;
1524
- getProcessTimeoutCauses(): string[];
1525
1026
  getPaths(): string[];
1526
1027
  /**
1527
1028
  * Return files that were running or collected.
@@ -1535,10 +1036,11 @@ declare class StateManager {
1535
1036
  clearFiles(project: TestProject, paths?: string[]): void;
1536
1037
  updateId(task: Task, project: TestProject): void;
1537
1038
  getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1039
+ getReportedEntityById(taskId: string): TestModule | TestCase | TestSuite | undefined;
1538
1040
  updateTasks(packs: TaskResultPack[]): void;
1539
1041
  updateUserLog(log: UserConsoleLog): void;
1540
1042
  getCountOfFailedTests(): number;
1541
- cancelFiles(files: string[], project: TestProject): void;
1043
+ cancelFiles(files: FileSpecification[], project: TestProject): void;
1542
1044
  }
1543
1045
 
1544
1046
  declare class VitestWatcher {
@@ -1659,264 +1161,773 @@ declare class Vitest {
1659
1161
  disableCoverage(): void;
1660
1162
  private _coverageOverrideCache;
1661
1163
  /**
1662
- * Inject new test projects into the workspace.
1663
- * @param config Glob, config path or a custom config options.
1664
- * @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
1665
1448
  */
1666
- private injectTestProject;
1449
+ isolate?: boolean;
1667
1450
  /**
1668
- * 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"
1669
1455
  */
1670
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1456
+ fileParallelism?: boolean;
1671
1457
  /**
1672
- * Get global provided context.
1458
+ * Show Vitest UI
1459
+ *
1460
+ * @default !process.env.CI
1673
1461
  */
1674
- getProvidedContext(): ProvidedContext;
1462
+ ui?: boolean;
1675
1463
  /**
1676
- * Return project that has the root (or "global") config.
1464
+ * Default viewport size
1677
1465
  */
1678
- getRootProject(): TestProject;
1679
- 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
+ };
1680
1478
  /**
1681
- * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
1682
- * @param moduleId The ID of the module in Vite module graph
1479
+ * Locator options
1683
1480
  */
1684
- 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
+ };
1685
1488
  /**
1686
- * 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.
1687
1492
  */
1688
- createCoverageProvider(): Promise<CoverageProvider | null>;
1689
- 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
+ };
1690
1513
  /**
1691
- * Glob test files in every project and create a TestSpecification for each file and pool.
1692
- * @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__
1693
1518
  */
1694
- globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1695
- private initCoverageProvider;
1519
+ screenshotDirectory?: string;
1696
1520
  /**
1697
- * 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
1698
1523
  */
1699
- mergeReports(directory?: string): Promise<TestRunResult>;
1700
- collect(filters?: string[]): Promise<TestRunResult>;
1524
+ screenshotFailures?: boolean;
1701
1525
  /**
1702
- * Returns the list of test files that match the config and filters.
1703
- * @param filters String filters to match the test files
1526
+ * Path to the index.html file that will be used to run tests.
1704
1527
  */
1705
- getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1528
+ testerHtmlPath?: string;
1706
1529
  /**
1707
- * Initialize reporters, the coverage provider, and run tests.
1708
- * This method can throw an error:
1709
- * - `FilesNotFoundError` if no tests are found
1710
- * - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
1711
- * - `Error` from the user reporters
1712
- * @param filters String filters to match the test files
1530
+ * Scripts injected into the main window.
1713
1531
  */
1714
- start(filters?: string[]): Promise<TestRunResult>;
1532
+ orchestratorScripts?: BrowserScript[];
1715
1533
  /**
1716
- * Initialize reporters and the coverage provider. This method doesn't run any tests.
1717
- * 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}
1718
1537
  */
1719
- init(): Promise<void>;
1538
+ commands?: Record<string, BrowserCommand<any>>;
1720
1539
  /**
1721
- * If there is a test run happening, returns a promise that will
1722
- * resolve when the test run is finished.
1540
+ * Timeout for connecting to the browser
1541
+ * @default 30000
1723
1542
  */
1724
- 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
+ };
1725
1555
  /**
1726
- * 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.
1727
1557
  *
1728
- * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
1729
- * @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
1730
1562
  */
1731
- 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 {
1732
1608
  /**
1733
- * 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`
1734
1613
  */
1735
- clearSpecificationsCache(moduleId?: string): void;
1614
+ id?: string;
1736
1615
  /**
1737
- * Run tests for the given test specifications. This does not trigger `onWatcher*` events.
1738
- * @param specifications A list of specifications to run.
1739
- * @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.
1740
1619
  */
1741
- runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1620
+ content?: string;
1742
1621
  /**
1743
- * Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
1744
- * @param specifications A list of specifications to run.
1745
- * @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.
1746
1623
  */
1747
- rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1748
- private runFiles;
1749
- experimental_parseSpecifications(specifications: TestSpecification[], options?: {
1750
- /** @default os.availableParallelism() */
1751
- concurrency?: number;
1752
- }): Promise<TestModule[]>;
1753
- experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
1624
+ src?: string;
1754
1625
  /**
1755
- * Collect tests in specified modules. Vitest will run the files to collect tests.
1756
- * @param specifications A list of specifications to run.
1626
+ * If the script should be loaded asynchronously.
1757
1627
  */
1758
- collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
1628
+ async?: boolean;
1759
1629
  /**
1760
- * Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
1630
+ * Script type.
1631
+ * @default 'module'
1761
1632
  */
1762
- cancelCurrentRun(reason: CancelReason): Promise<void>;
1763
- 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: {
1764
1659
  /**
1765
- * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
1766
- * @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"
1767
1678
  */
1768
- updateSnapshot(files?: string[]): Promise<TestRunResult>;
1679
+ arg: string;
1769
1680
  /**
1770
- * Enable the mode that allows updating snapshots when running tests.
1771
- * This method doesn't run any tests.
1681
+ * Screenshot extension, with leading dot.
1772
1682
  *
1773
- * Every test that runs after this method is called will update snapshots.
1774
- * 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.
1775
1685
  */
1776
- enableSnapshotUpdate(): void;
1686
+ ext: string;
1777
1687
  /**
1778
- * Disable the mode that allows updating snapshots when running tests.
1688
+ * The instance's browser name.
1779
1689
  */
1780
- resetSnapshotUpdate(): void;
1781
- /**
1782
- * Set the global test name pattern to a regexp.
1783
- * This method doesn't run any tests.
1690
+ browserName: string;
1691
+ /**
1692
+ * The value of {@linkcode process.platform}.
1784
1693
  */
1785
- setGlobalTestNamePattern(pattern: string | RegExp): void;
1694
+ platform: NodeJS.Platform;
1786
1695
  /**
1787
- * Returns the regexp used for the global test name pattern.
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.
1788
1699
  */
1789
- getGlobalTestNamePattern(): RegExp | undefined;
1700
+ screenshotDirectory: string;
1790
1701
  /**
1791
- * 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}.
1792
1704
  */
1793
- resetGlobalTestNamePattern(): void;
1794
- private _rerunTimer;
1795
- private scheduleRerun;
1705
+ root: string;
1796
1706
  /**
1797
- * 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}.
1798
1709
  */
1799
- invalidateFile(filepath: string): void;
1800
- private reportCoverage;
1710
+ testFileDirectory: string;
1801
1711
  /**
1802
- * Closes all projects and their associated resources.
1803
- * This can only be called once; the closing promise is cached until the server restarts.
1712
+ * The test's filename.
1804
1713
  */
1805
- close(): Promise<void>;
1714
+ testFileName: string;
1806
1715
  /**
1807
- * Closes all projects and exit the process
1808
- * @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.
1809
1718
  */
1810
- exit(force?: boolean): Promise<void>;
1719
+ testName: string;
1811
1720
  /**
1812
- * 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.
1813
1724
  */
1814
- shouldKeepServer(): boolean;
1725
+ attachmentsDir: string;
1726
+ }) => string;
1727
+ interface ToMatchScreenshotOptions {
1815
1728
  /**
1816
- * 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}`
1817
1732
  */
1818
- onServerRestart(fn: OnServerRestartHandler): void;
1733
+ resolveScreenshotPath?: ToMatchScreenshotResolvePath;
1819
1734
  /**
1820
- * 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}`
1821
1738
  */
1822
- onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1739
+ resolveDiffPath?: ToMatchScreenshotResolvePath;
1740
+ }
1741
+ interface ToMatchScreenshotComparators {}
1742
+
1743
+ declare class TestProject {
1744
+ options?: InitializeProjectOptions | undefined;
1823
1745
  /**
1824
- * Register a handler that will be called when the server is closed.
1746
+ * The global Vitest instance.
1825
1747
  */
1826
- onClose(fn: () => Awaitable<void>): void;
1748
+ readonly vitest: Vitest;
1827
1749
  /**
1828
- * 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`.
1829
1751
  */
1830
- onTestsRerun(fn: OnTestsRerunHandler): void;
1752
+ readonly globalConfig: ResolvedConfig;
1831
1753
  /**
1832
- * Register a handler that will be called when a file is changed.
1833
- * This callback should return `true` of `false` indicating whether the test file needs to be rerun.
1834
- * @example
1835
- * const testsToRun = [resolve('./test.spec.ts')]
1836
- * 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.
1837
1755
  */
1838
- onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
1756
+ browser?: ProjectBrowser;
1839
1757
  /**
1840
- * 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.
1841
1759
  */
1842
- matchesProjectFilter(name: string): boolean;
1843
- }
1844
- type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1845
- type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
1846
-
1847
- type TestRunEndReason = "passed" | "interrupted" | "failed";
1848
- interface Reporter {
1849
- 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);
1850
1768
  /**
1851
- * Called when the project initiated the browser instance.
1852
- * project.browser will always be defined.
1853
- * @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.
1854
1772
  */
1855
- onBrowserInit?: (project: TestProject) => Awaitable$1<void>;
1856
- onTestRemoved?: (trigger?: string) => Awaitable$1<void>;
1857
- onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable$1<void>;
1858
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable$1<void>;
1859
- onServerRestart?: (reason?: string) => Awaitable$1<void>;
1860
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable$1<void>;
1861
- onProcessTimeout?: () => Awaitable$1<void>;
1773
+ get hash(): string;
1862
1774
  /**
1863
- * 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`.
1864
1776
  */
1865
- onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable$1<void>;
1777
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1866
1778
  /**
1867
- * Called when the test run is finished.
1779
+ * Get the provided context. The project context is merged with the global context.
1868
1780
  */
1869
- onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable$1<void>;
1781
+ getProvidedContext(): ProvidedContext;
1870
1782
  /**
1871
- * 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
1872
1785
  */
1873
- onTestModuleQueued?: (testModule: TestModule) => Awaitable$1<void>;
1786
+ createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
1787
+ toJSON(): SerializedTestProject;
1874
1788
  /**
1875
- * 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.
1876
1790
  */
1877
- onTestModuleCollected?: (testModule: TestModule) => Awaitable$1<void>;
1791
+ get vite(): ViteDevServer;
1878
1792
  /**
1879
- * Called when starting to run tests of the test file
1793
+ * Resolved project configuration.
1880
1794
  */
1881
- onTestModuleStart?: (testModule: TestModule) => Awaitable$1<void>;
1795
+ get config(): ResolvedConfig;
1882
1796
  /**
1883
- * Called when all tests of the test file have finished running.
1797
+ * The name of the project or an empty string if not set.
1884
1798
  */
1885
- onTestModuleEnd?: (testModule: TestModule) => Awaitable$1<void>;
1799
+ get name(): string;
1886
1800
  /**
1887
- * Called when test case is ready to run.
1888
- * Called before the `beforeEach` hooks for the test are run.
1801
+ * The color used when reporting tasks of this project.
1889
1802
  */
1890
- onTestCaseReady?: (testCase: TestCase) => Awaitable$1<void>;
1803
+ get color(): ProjectName["color"];
1891
1804
  /**
1892
- * Called after the test and its hooks are finished running.
1893
- * The `result()` cannot be `pending`.
1805
+ * Serialized project configuration. This is the config that tests receive.
1894
1806
  */
1895
- onTestCaseResult?: (testCase: TestCase) => Awaitable$1<void>;
1807
+ get serializedConfig(): SerializedConfig;
1896
1808
  /**
1897
- * 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.
1898
1810
  */
1899
- onTestCaseAnnotate?: (testCase: TestCase, annotation: TestAnnotation) => Awaitable$1<void>;
1811
+ isRootProject(): boolean;
1812
+ onTestsRerun(cb: OnTestsRerunHandler): void;
1900
1813
  /**
1901
- * Called when test suite is ready to run.
1902
- * 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.
1903
1816
  */
1904
- 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;
1905
1830
  /**
1906
- * Called after the test suite and its hooks are finished running.
1907
- * 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`.
1908
1832
  */
1909
- onTestSuiteResult?: (testSuite: TestSuite) => Awaitable$1<void>;
1833
+ matchesTestGlob(moduleId: string, source?: () => string): boolean;
1834
+ private isInSourceTestCode;
1835
+ private filterFiles;
1836
+ private _parentBrowser?;
1910
1837
  /**
1911
- * 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.
1912
1840
  */
1913
- onHookStart?: (hook: ReportedHookContext) => Awaitable$1<void>;
1841
+ close(): Promise<void>;
1914
1842
  /**
1915
- * 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
1916
1845
  */
1917
- onHookEnd?: (hook: ReportedHookContext) => Awaitable$1<void>;
1918
- 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;
1919
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
+ });
1920
1931
 
1921
1932
  interface BaseOptions {
1922
1933
  isTTY?: boolean;
@@ -1945,13 +1956,15 @@ declare abstract class BaseReporter implements Reporter {
1945
1956
  protected printTestModule(testModule: TestModule): void;
1946
1957
  protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
1947
1958
  private getModuleLog;
1948
- protected printTestSuite(_suite: TestSuite): void;
1949
- protected getTestName(test: Task, separator?: string): string;
1959
+ protected printTestSuite(testSuite: TestSuite): void;
1960
+ protected getTestName(test: Task, _separator?: string): string;
1950
1961
  protected getFullName(test: Task, separator?: string): string;
1951
- protected formatShortError(error: TestError): string;
1952
- protected getTestIndentation(_test: Task): string;
1962
+ protected getTestIndentation(test: Task): string;
1953
1963
  protected printAnnotations(test: TestCase, console: "log" | "error", padding?: number): void;
1954
- 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;
1955
1968
  onWatcherStart(files?: File[], errors?: unknown[]): void;
1956
1969
  onWatcherRerun(files: string[], trigger?: string): void;
1957
1970
  onUserConsoleLog(log: UserConsoleLog, taskState?: TestResult["state"]): void;
@@ -1984,13 +1997,26 @@ declare class DefaultReporter extends BaseReporter {
1984
1997
  onInit(ctx: Vitest): void;
1985
1998
  }
1986
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
+
1987
2016
  interface HTMLOptions {
1988
2017
  outputFile?: string;
1989
2018
  }
1990
2019
 
1991
- // for compatibility reasons, the reporter produces a JSON similar to the one produced by the Jest JSON reporter
1992
- // the following types are extracted from the Jest repository (and simplified)
1993
- // the commented-out fields are the missing ones
1994
2020
  type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled";
1995
2021
  type Milliseconds = number;
1996
2022
  interface Callsite {
@@ -2094,7 +2120,6 @@ declare class DotReporter extends BaseReporter {
2094
2120
  private tests;
2095
2121
  private finishedTests;
2096
2122
  onInit(ctx: Vitest): void;
2097
- // Ignore default logging of base reporter
2098
2123
  printTestModule(): void;
2099
2124
  onWatcherRerun(files: string[], trigger?: string): void;
2100
2125
  onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): void;
@@ -2105,18 +2130,6 @@ declare class DotReporter extends BaseReporter {
2105
2130
  private createSummary;
2106
2131
  }
2107
2132
 
2108
- interface GithubActionsReporterOptions {
2109
- onWritePath?: (path: string) => string;
2110
- }
2111
- declare class GithubActionsReporter implements Reporter {
2112
- ctx: Vitest;
2113
- options: GithubActionsReporterOptions;
2114
- constructor(options?: GithubActionsReporterOptions);
2115
- onInit(ctx: Vitest): void;
2116
- onTestCaseAnnotate(testCase: TestCase, annotation: TestAnnotation): void;
2117
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>): void;
2118
- }
2119
-
2120
2133
  declare class HangingProcessReporter implements Reporter {
2121
2134
  whyRunning: (() => void) | undefined;
2122
2135
  onInit(): void;
@@ -2138,15 +2151,16 @@ declare class TapFlatReporter extends TapReporter {
2138
2151
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): void;
2139
2152
  }
2140
2153
 
2154
+ declare class TreeReporter extends DefaultReporter {
2155
+ protected verbose: boolean;
2156
+ renderSucceed: boolean;
2157
+ }
2158
+
2141
2159
  declare class VerboseReporter extends DefaultReporter {
2142
2160
  protected verbose: boolean;
2143
2161
  renderSucceed: boolean;
2144
- printTestModule(module: TestModule): void;
2162
+ printTestModule(_module: TestModule): void;
2145
2163
  onTestCaseResult(test: TestCase): void;
2146
- protected printTestSuite(testSuite: TestSuite): void;
2147
- protected getTestName(test: Task): string;
2148
- protected getTestIndentation(test: Task): string;
2149
- protected formatShortError(): string;
2150
2164
  }
2151
2165
 
2152
2166
  type FormattedBenchmarkResult = BenchmarkResult & {
@@ -2192,6 +2206,7 @@ declare const ReportersMap: {
2192
2206
  tap: typeof TapReporter;
2193
2207
  "tap-flat": typeof TapFlatReporter;
2194
2208
  junit: typeof JUnitReporter;
2209
+ tree: typeof TreeReporter;
2195
2210
  "hanging-process": typeof HangingProcessReporter;
2196
2211
  "github-actions": typeof GithubActionsReporter;
2197
2212
  };
@@ -2200,6 +2215,7 @@ interface BuiltinReporterOptions {
2200
2215
  "default": DefaultReporterOptions;
2201
2216
  "verbose": DefaultReporterOptions;
2202
2217
  "dot": BaseOptions;
2218
+ "tree": BaseOptions;
2203
2219
  "json": JsonOptions;
2204
2220
  "blob": BlobOptions;
2205
2221
  "tap": never;
@@ -2207,6 +2223,7 @@ interface BuiltinReporterOptions {
2207
2223
  "junit": JUnitOptions;
2208
2224
  "hanging-process": never;
2209
2225
  "html": HTMLOptions;
2226
+ "github-actions": GithubActionsReporterOptions;
2210
2227
  }
2211
2228
 
2212
2229
  interface TestSequencer {
@@ -2214,8 +2231,8 @@ interface TestSequencer {
2214
2231
  * Slicing tests into shards. Will be run before `sort`.
2215
2232
  * Only run, if `shard` is defined.
2216
2233
  */
2217
- shard: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2218
- sort: (files: TestSpecification[]) => Awaitable$1<TestSpecification[]>;
2234
+ shard: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
2235
+ sort: (files: TestSpecification[]) => Awaitable<TestSpecification[]>;
2219
2236
  }
2220
2237
  interface TestSequencerConstructor {
2221
2238
  new (ctx: Vitest): TestSequencer;
@@ -2245,7 +2262,7 @@ interface BenchmarkUserOptions {
2245
2262
  *
2246
2263
  * @default ['default']
2247
2264
  */
2248
- reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
2265
+ reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>;
2249
2266
  /**
2250
2267
  * @deprecated Use `benchmark.outputJson` instead
2251
2268
  */
@@ -2267,9 +2284,7 @@ interface BenchmarkUserOptions {
2267
2284
  }
2268
2285
 
2269
2286
  type BuiltinEnvironment = "node" | "jsdom" | "happy-dom" | "edge-runtime";
2270
- // Record is used, so user can get intellisense for builtin environments, but still allow custom environments
2271
2287
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
2272
-
2273
2288
  type CSSModuleScopeStrategy = "stable" | "scoped" | "non-scoped";
2274
2289
  type ApiConfig = Pick<ServerOptions, "port" | "strictPort" | "host" | "middlewareMode">;
2275
2290
  interface EnvironmentOptions {
@@ -2406,6 +2421,8 @@ interface ResolveSnapshotPathHandlerContext {
2406
2421
  config: SerializedConfig;
2407
2422
  }
2408
2423
  type ResolveSnapshotPathHandler = (testPath: string, snapExtension: string, context: ResolveSnapshotPathHandlerContext) => string;
2424
+ type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
2425
+ type Pool = BuiltinPool | (string & {});
2409
2426
  interface InlineConfig {
2410
2427
  /**
2411
2428
  * Name of the project. Will be used to display in the reporter.
@@ -2441,6 +2458,23 @@ interface InlineConfig {
2441
2458
  deps?: DepsOptions;
2442
2459
  server?: {
2443
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
+ };
2444
2478
  };
2445
2479
  /**
2446
2480
  * Base directory to scan for the test files
@@ -2471,25 +2505,38 @@ interface InlineConfig {
2471
2505
  /**
2472
2506
  * Run tests in an isolated environment. This option has no effect on vmThreads pool.
2473
2507
  *
2474
- * 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.
2475
2509
  *
2476
2510
  * @default true
2477
2511
  */
2478
2512
  isolate?: boolean;
2479
2513
  /**
2480
- * Pool used to run tests in.
2514
+ * Pass additional arguments to `node` process when spawning the worker.
2481
2515
  *
2482
- * Supports 'threads', 'forks', 'vmThreads'
2516
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
2483
2517
  *
2484
- * @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
2523
+ */
2524
+ execArgv?: string[];
2525
+ /**
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.
2485
2528
  */
2486
- pool?: Exclude<Pool, "browser">;
2529
+ vmMemoryLimit?: string | number;
2487
2530
  /**
2488
- * Pool options
2531
+ * Pool used to run tests in.
2532
+ *
2533
+ * Supports 'threads', 'forks', 'vmThreads', 'vmForks'
2534
+ *
2535
+ * @default 'forks'
2489
2536
  */
2490
- poolOptions?: PoolOptions;
2537
+ pool?: Exclude<Pool, "browser"> | PoolRunnerInitializer;
2491
2538
  /**
2492
- * Maximum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.maxThreads`/`poolOptions.forks.maxForks` has higher priority.
2539
+ * Maximum number or percentage of workers to run tests in.
2493
2540
  */
2494
2541
  maxWorkers?: number | string;
2495
2542
  /**
@@ -2635,7 +2682,6 @@ interface InlineConfig {
2635
2682
  ui?: boolean;
2636
2683
  /**
2637
2684
  * options for test in a browser environment
2638
- * @experimental
2639
2685
  *
2640
2686
  * @default false
2641
2687
  */
@@ -2776,14 +2822,14 @@ interface InlineConfig {
2776
2822
  * Debug tests by opening `node:inspector` in worker / child process.
2777
2823
  * Provides similar experience as `--inspect` Node CLI argument.
2778
2824
  *
2779
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2825
+ * Requires `fileParallelism: false`.
2780
2826
  */
2781
2827
  inspect?: boolean | string;
2782
2828
  /**
2783
2829
  * Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
2784
2830
  * Provides similar experience as `--inspect-brk` Node CLI argument.
2785
2831
  *
2786
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2832
+ * Requires `fileParallelism: false`.
2787
2833
  */
2788
2834
  inspectBrk?: boolean | string;
2789
2835
  /**
@@ -3017,7 +3063,7 @@ interface UserConfig extends InlineConfig {
3017
3063
  type OnUnhandledErrorCallback = (error: (TestError | Error) & {
3018
3064
  type: string;
3019
3065
  }) => boolean | void;
3020
- 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"> {
3021
3067
  mode: VitestRunMode;
3022
3068
  name: ProjectName["label"];
3023
3069
  color?: ProjectName["color"];
@@ -3034,7 +3080,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3034
3080
  snapshotOptions: SnapshotStateOptions;
3035
3081
  browser: ResolvedBrowserOptions;
3036
3082
  pool: Pool;
3037
- poolOptions?: ResolvedPoolOptions;
3083
+ poolRunner?: PoolRunnerInitializer;
3038
3084
  reporters: (InlineReporter | ReporterWithOptions)[];
3039
3085
  defines: Record<string, any>;
3040
3086
  api: ApiConfig & {
@@ -3067,8 +3113,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3067
3113
  };
3068
3114
  runner?: string;
3069
3115
  maxWorkers: number;
3116
+ vmMemoryLimit?: UserConfig["vmMemoryLimit"];
3117
+ dumpDir?: string;
3070
3118
  }
3071
- 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" | "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";
3072
3120
  interface ServerDepsOptions {
3073
3121
  /**
3074
3122
  * Externalize means that Vite will bpass the package to native Node.
@@ -3093,21 +3141,16 @@ interface ServerDepsOptions {
3093
3141
  */
3094
3142
  fallbackCJS?: boolean;
3095
3143
  }
3096
- type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
3144
+ type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps"> & {
3097
3145
  mode?: string;
3098
3146
  sequencer?: Omit<SequenceOptions, "sequencer" | "seed">;
3099
3147
  deps?: Omit<DepsOptions, "moduleDirectories">;
3100
- poolOptions?: {
3101
- threads?: Pick<NonNullable<PoolOptions["threads"]>, "singleThread" | "isolate">;
3102
- vmThreads?: Pick<NonNullable<PoolOptions["vmThreads"]>, "singleThread">;
3103
- forks?: Pick<NonNullable<PoolOptions["forks"]>, "singleFork" | "isolate">;
3104
- };
3148
+ fileParallelism?: boolean;
3105
3149
  };
3106
3150
  type ResolvedProjectConfig = Omit<ResolvedConfig, Exclude<NonProjectOptions, "coverage" | "watch">>;
3107
3151
  interface UserWorkspaceConfig extends UserConfig$1 {
3108
3152
  test?: ProjectConfig;
3109
3153
  }
3110
- // TODO: remove types when "workspace" support is removed
3111
3154
  type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
3112
3155
  type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3113
3156
  type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
@@ -3120,5 +3163,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3120
3163
  });
3121
3164
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3122
3165
 
3123
- 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 };
3124
- 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 };