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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +1 -1
  3. package/dist/{worker-base.js → chunks/base.CtHM3ryk.js} +18 -91
  4. package/dist/chunks/{browser.d.CCG7W26I.d.ts → browser.d.B9iJzZyn.d.ts} +3 -2
  5. package/dist/chunks/{cac.DYnuYoJK.js → cac.DCrQhweU.js} +14 -61
  6. package/dist/chunks/{cli-api.xhe4uqTX.js → cli-api.BjHteKX0.js} +1312 -53
  7. package/dist/chunks/{config.d.C4PpNy7v.d.ts → config.d.u2CUDWwS.d.ts} +2 -16
  8. package/dist/chunks/{coverage.Ds84cgzV.js → coverage.FU3w4IrQ.js} +25 -1241
  9. package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
  10. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  11. package/dist/chunks/{global.d.RTA0rbJI.d.ts → global.d.BgJSTpgQ.d.ts} +1 -1
  12. package/dist/chunks/{globals.CwYe1aG7.js → globals.BGT_RUsD.js} +4 -2
  13. package/dist/chunks/{index.eEkl9h8v.js → index.BdSLhLDZ.js} +1 -1
  14. package/dist/chunks/{index.D2gVI9Ck.js → index.CcRZ6fUh.js} +1506 -11
  15. package/dist/chunks/{index.Bcjk8TKX.js → index.RwjEGCQ0.js} +2 -2
  16. package/dist/chunks/init-forks.DSafeltJ.js +54 -0
  17. package/dist/chunks/init-threads.SUtZ-067.js +17 -0
  18. package/dist/chunks/{worker.CdzokOSx.js → init.B2EESLQM.js} +97 -80
  19. package/dist/chunks/{inspector.Br76Q2Mb.js → inspector.DLZxSeU3.js} +1 -2
  20. package/dist/chunks/{moduleRunner.d.aXWuQhZN.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +1 -1
  21. package/dist/chunks/{plugin.d.XtKKWlOO.d.ts → plugin.d.BB__S31E.d.ts} +1 -1
  22. package/dist/chunks/{reporters.d.BJ_OuJGZ.d.ts → reporters.d.C6nGyY9_.d.ts} +1113 -1152
  23. package/dist/chunks/{resolveSnapshotEnvironment.tw2a5ux8.js → resolveSnapshotEnvironment.DJJKMKxb.js} +1 -1
  24. package/dist/chunks/{setup-common.DgXU7Yho.js → setup-common.DR1sucx6.js} +1 -1
  25. package/dist/chunks/{startModuleRunner.DPBo3mme.js → startModuleRunner.C2tTvmF9.js} +3 -1
  26. package/dist/{worker-vm.js → chunks/vm.DBeOXrP9.js} +6 -66
  27. package/dist/chunks/{worker.d.DSgBAZPX.d.ts → worker.d.BFk-vvBU.d.ts} +79 -4
  28. package/dist/cli.js +8 -9
  29. package/dist/config.cjs +0 -1
  30. package/dist/config.d.ts +6 -7
  31. package/dist/config.js +1 -1
  32. package/dist/coverage.d.ts +4 -4
  33. package/dist/coverage.js +2 -13
  34. package/dist/index.d.ts +13 -9
  35. package/dist/index.js +4 -2
  36. package/dist/module-evaluator.d.ts +3 -3
  37. package/dist/module-runner.js +1 -1
  38. package/dist/node.d.ts +79 -15
  39. package/dist/node.js +25 -26
  40. package/dist/reporters.d.ts +4 -4
  41. package/dist/reporters.js +9 -10
  42. package/dist/runners.d.ts +1 -1
  43. package/dist/worker.d.ts +26 -0
  44. package/dist/worker.js +46 -0
  45. package/dist/workers/forks.js +50 -0
  46. package/dist/workers/runVmTests.js +6 -5
  47. package/dist/workers/threads.js +50 -0
  48. package/dist/workers/vmForks.js +35 -0
  49. package/dist/workers/vmThreads.js +35 -0
  50. package/package.json +16 -13
  51. package/worker.d.ts +1 -0
  52. package/dist/chunks/typechecker.DsKAhua5.js +0 -1522
@@ -1,13 +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 } from '@vitest/utils';
3
- import { P as ProvidedContext, A as AfterSuiteRunMeta, U as UserConsoleLog, L as LabelColor } from './worker.d.DSgBAZPX.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 { Plugin, ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, 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
8
  import { BrowserCommands } from 'vitest/browser';
9
- import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.C4PpNy7v.js';
10
- import { B as BrowserTesterOptions, S as SerializedTestSpecification } from './browser.d.CCG7W26I.js';
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';
11
11
  import { PrettyFormatOptions } from '@vitest/pretty-format';
12
12
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
13
13
  import { SerializedDiffOptions } from '@vitest/utils/diff';
@@ -70,997 +70,375 @@ interface ConstructorOptionsOverride {
70
70
  resources?: "usable";
71
71
  }
72
72
 
73
- interface CDPSession {
74
- send: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
75
- on: (event: string, listener: (...args: unknown[]) => void) => void;
76
- once: (event: string, listener: (...args: unknown[]) => void) => void;
77
- off: (event: string, listener: (...args: unknown[]) => void) => void;
78
- }
79
- interface BrowserModuleMocker {
80
- register: (sessionId: string, module: MockedModule) => Promise<void>;
81
- delete: (sessionId: string, url: string) => Promise<void>;
82
- clear: (sessionId: string) => Promise<void>;
83
- }
84
- interface BrowserProviderOption<Options extends object = object> {
85
- name: string;
86
- supportedBrowser?: ReadonlyArray<string>;
87
- options: Options;
88
- providerFactory: (project: TestProject) => BrowserProvider;
89
- serverFactory: BrowserServerFactory;
90
- }
91
- interface BrowserServerOptions {
92
- project: TestProject;
93
- coveragePlugin: () => Plugin;
94
- mocksPlugins: (options: {
95
- filter: (id: string) => boolean;
96
- }) => Plugin[];
97
- metaEnvReplacer: () => Plugin;
98
- }
99
- interface BrowserServerFactory {
100
- (otpions: BrowserServerOptions): Promise<ParentProjectBrowser>;
101
- }
102
- interface BrowserProvider {
103
- name: string;
104
- mocker?: BrowserModuleMocker;
105
- readonly initScripts?: string[];
73
+ declare class ReportedTaskImplementation {
106
74
  /**
107
- * @experimental opt-in into file parallelisation
75
+ * The project associated with the test or suite.
108
76
  */
109
- supportsParallelism: boolean;
110
- getCommandsContext: (sessionId: string) => Record<string, unknown>;
111
- openPage: (sessionId: string, url: string) => Promise<void>;
112
- getCDPSession?: (sessionId: string) => Promise<CDPSession>;
113
- close: () => Awaitable<void>;
114
- }
115
- type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
116
- interface _BrowserNames {}
117
- type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "poolOptions" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
118
- interface BrowserInstanceOption extends Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
77
+ readonly project: TestProject;
119
78
  /**
120
- * 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.
121
82
  */
122
- browser: keyof _BrowserNames extends never ? string : _BrowserNames[keyof _BrowserNames];
123
- name?: string;
124
- provider?: BrowserProviderOption;
125
- }
126
- interface BrowserConfigOptions {
83
+ readonly id: string;
127
84
  /**
128
- * if running tests in the browser should be the default
129
- *
130
- * @default false
85
+ * Location in the module where the test or suite is defined.
131
86
  */
132
- enabled?: boolean;
87
+ readonly location: {
88
+ line: number;
89
+ column: number;
90
+ } | undefined;
133
91
  /**
134
- * Configurations for different browser setups
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`.
135
94
  */
136
- instances?: BrowserInstanceOption[];
95
+ ok(): boolean;
137
96
  /**
138
- * Browser provider
139
- * @example
140
- * ```ts
141
- * import { playwright } from '@vitest/browser-playwright'
142
- * export default defineConfig({
143
- * test: {
144
- * browser: {
145
- * provider: playwright(),
146
- * },
147
- * },
148
- * })
149
- * ```
97
+ * Custom metadata that was attached to the test during its execution.
150
98
  */
151
- provider?: BrowserProviderOption;
99
+ meta(): TaskMeta;
100
+ }
101
+ declare class TestCase extends ReportedTaskImplementation {
102
+ #private;
103
+ readonly type = "test";
152
104
  /**
153
- * enable headless mode
154
- *
155
- * @default process.env.CI
105
+ * Direct reference to the test module where the test or suite is defined.
156
106
  */
157
- headless?: boolean;
107
+ readonly module: TestModule;
158
108
  /**
159
- * Serve API options.
160
- *
161
- * The default port is 63315.
109
+ * Name of the test.
162
110
  */
163
- api?: ApiConfig | number;
111
+ readonly name: string;
164
112
  /**
165
- * Isolate test environment after each test
166
- *
167
- * @default true
113
+ * Options that the test was initiated with.
168
114
  */
169
- isolate?: boolean;
115
+ readonly options: TaskOptions;
170
116
  /**
171
- * Run test files in parallel if provider supports this option
172
- * This option only has effect in headless mode (enabled in CI by default)
173
- *
174
- * @default // Same as "test.fileParallelism"
117
+ * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
175
118
  */
176
- fileParallelism?: boolean;
119
+ readonly parent: TestSuite | TestModule;
177
120
  /**
178
- * Show Vitest UI
179
- *
180
- * @default !process.env.CI
121
+ * Full name of the test including all parent suites separated with `>`.
181
122
  */
182
- ui?: boolean;
123
+ get fullName(): string;
183
124
  /**
184
- * Default viewport size
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()`.
185
130
  */
186
- viewport?: {
187
- /**
188
- * Width of the viewport
189
- * @default 414
190
- */
191
- width: number;
192
- /**
193
- * Height of the viewport
194
- * @default 896
195
- */
196
- height: number;
197
- };
131
+ result(): TestResult;
198
132
  /**
199
- * Locator options
133
+ * Test annotations added via the `task.annotate` API during the test execution.
200
134
  */
201
- locators?: {
202
- /**
203
- * Attribute used to locate elements by test id
204
- * @default 'data-testid'
205
- */
206
- testIdAttribute?: string;
207
- };
135
+ annotations(): ReadonlyArray<TestAnnotation>;
208
136
  /**
209
- * Generate traces that can be viewed on https://trace.playwright.dev/
210
- *
211
- * This option is supported only by **playwright** provider.
137
+ * Useful information about the test like duration, memory usage, etc.
138
+ * Diagnostic is only available after the test has finished.
212
139
  */
213
- trace?: BrowserTraceViewMode | {
214
- mode: BrowserTraceViewMode;
215
- /**
216
- * The directory where all traces will be stored. By default, Vitest
217
- * stores all traces in `__traces__` folder close to the test file.
218
- */
219
- tracesDir?: string;
220
- /**
221
- * Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.
222
- * @default true
223
- */
224
- screenshots?: boolean;
225
- /**
226
- * If this option is true tracing will
227
- * - capture DOM snapshot on every action
228
- * - record network activity
229
- * @default true
230
- */
231
- snapshots?: boolean;
232
- };
140
+ diagnostic(): TestDiagnostic | undefined;
141
+ }
142
+ declare class TestCollection {
143
+ #private;
144
+ constructor(task: Suite | File, project: TestProject);
233
145
  /**
234
- * Directory where screenshots will be saved when page.screenshot() is called
235
- * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
236
- * If this is set, it will be resolved relative to the project root.
237
- * @default __screenshots__
146
+ * Returns the test or suite at a specific index.
238
147
  */
239
- screenshotDirectory?: string;
148
+ at(index: number): TestCase | TestSuite | undefined;
240
149
  /**
241
- * Should Vitest take screenshots if the test fails
242
- * @default !browser.ui
150
+ * The number of tests and suites in the collection.
243
151
  */
244
- screenshotFailures?: boolean;
152
+ get size(): number;
245
153
  /**
246
- * Path to the index.html file that will be used to run tests.
154
+ * Returns the collection in array form for easier manipulation.
247
155
  */
248
- testerHtmlPath?: string;
156
+ array(): (TestCase | TestSuite)[];
249
157
  /**
250
- * Scripts injected into the main window.
158
+ * Filters all tests that are part of this collection and its children.
251
159
  */
252
- orchestratorScripts?: BrowserScript[];
160
+ allTests(state?: TestState): Generator<TestCase, undefined, void>;
253
161
  /**
254
- * Commands that will be executed on the server
255
- * via the browser `import("vitest/browser").commands` API.
256
- * @see {@link https://vitest.dev/guide/browser/commands}
162
+ * Filters only the tests that are part of this collection.
257
163
  */
258
- commands?: Record<string, BrowserCommand<any>>;
164
+ tests(state?: TestState): Generator<TestCase, undefined, void>;
259
165
  /**
260
- * Timeout for connecting to the browser
261
- * @default 30000
166
+ * Filters only the suites that are part of this collection.
262
167
  */
263
- connectTimeout?: number;
264
- expect?: {
265
- toMatchScreenshot?: { [ComparatorName in keyof ToMatchScreenshotComparators] : {
266
- /**
267
- * The name of the comparator to use for visual diffing.
268
- *
269
- * @defaultValue `'pixelmatch'`
270
- */
271
- comparatorName?: ComparatorName;
272
- comparatorOptions?: ToMatchScreenshotComparators[ComparatorName];
273
- } }[keyof ToMatchScreenshotComparators] & ToMatchScreenshotOptions;
274
- };
168
+ suites(): Generator<TestSuite, undefined, void>;
275
169
  /**
276
- * Enables tracking uncaught errors and exceptions so they can be reported by Vitest.
277
- *
278
- * If you need to hide certain errors, it is recommended to use [`onUnhandledError`](https://vitest.dev/config/#onunhandlederror) option instead.
279
- *
280
- * Disabling this will completely remove all Vitest error handlers, which can help debugging with the "Pause on exceptions" checkbox turned on.
281
- * @default true
170
+ * Filters all suites that are part of this collection and its children.
282
171
  */
283
- trackUnhandledErrors?: boolean;
172
+ allSuites(): Generator<TestSuite, undefined, void>;
173
+ [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
284
174
  }
285
- interface BrowserCommandContext {
286
- testPath: string | undefined;
287
- provider: BrowserProvider;
288
- project: TestProject;
289
- sessionId: string;
290
- triggerCommand: <K extends keyof BrowserCommands>(name: K, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
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 {
184
+ /**
185
+ * Collection of suites and tests that are part of this suite.
186
+ */
187
+ readonly children: TestCollection;
188
+ /**
189
+ * Errors that happened outside of the test run during collection, like syntax errors.
190
+ */
191
+ errors(): SerializedError[];
291
192
  }
292
- interface BrowserServerStateSession {
293
- project: TestProject;
294
- connected: () => void;
295
- fail: (v: Error) => void;
296
- }
297
- interface BrowserOrchestrator {
298
- cleanupTesters: () => Promise<void>;
299
- createTesters: (options: BrowserTesterOptions) => Promise<void>;
300
- onCancel: (reason: CancelReason) => Promise<void>;
301
- $close: () => void;
302
- }
303
- interface BrowserServerState {
304
- orchestrators: Map<string, BrowserOrchestrator>;
305
- }
306
- interface ParentProjectBrowser {
307
- spawn: (project: TestProject) => ProjectBrowser;
308
- vite: ViteDevServer;
309
- }
310
- interface ProjectBrowser {
311
- vite: ViteDevServer;
312
- state: BrowserServerState;
313
- provider: BrowserProvider;
314
- close: () => Promise<void>;
315
- initBrowserProvider: (project: TestProject) => Promise<void>;
316
- parseStacktrace: (stack: string) => ParsedStack[];
317
- parseErrorStacktrace: (error: TestError, options?: StackTraceParserOptions) => ParsedStack[];
318
- registerCommand: <K extends keyof BrowserCommands>(name: K, cb: BrowserCommand<Parameters<BrowserCommands[K]>, ReturnType<BrowserCommands[K]>>) => void;
319
- triggerCommand: <K extends keyof BrowserCommands>(name: K, context: BrowserCommandContext, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
320
- }
321
- interface BrowserCommand<
322
- Payload extends unknown[] = [],
323
- ReturnValue = any
324
- > {
325
- (context: BrowserCommandContext, ...payload: Payload): Awaitable<ReturnValue>;
326
- }
327
- interface BrowserScript {
328
- /**
329
- * If "content" is provided and type is "module", this will be its identifier.
330
- *
331
- * If you are using TypeScript, you can add `.ts` extension here for example.
332
- * @default `injected-${index}.js`
333
- */
334
- id?: string;
193
+ declare class TestSuite extends SuiteImplementation {
194
+ #private;
195
+ readonly type = "suite";
335
196
  /**
336
- * JavaScript content to be injected. This string is processed by Vite plugins if type is "module".
337
- *
338
- * You can use `id` to give Vite a hint about the file extension.
197
+ * Name of the test or the suite.
339
198
  */
340
- content?: string;
199
+ readonly name: string;
341
200
  /**
342
- * 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.
343
202
  */
344
- src?: string;
203
+ readonly module: TestModule;
345
204
  /**
346
- * 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.
347
206
  */
348
- async?: boolean;
207
+ readonly parent: TestSuite | TestModule;
349
208
  /**
350
- * Script type.
351
- * @default 'module'
209
+ * Options that suite was initiated with.
352
210
  */
353
- type?: string;
354
- }
355
- interface ResolvedBrowserOptions extends BrowserConfigOptions {
356
- name: string;
357
- enabled: boolean;
358
- headless: boolean;
359
- isolate: boolean;
360
- fileParallelism: boolean;
361
- api: ApiConfig;
362
- ui: boolean;
363
- viewport: {
364
- width: number;
365
- height: number;
366
- };
367
- screenshotFailures: boolean;
368
- locators: {
369
- testIdAttribute: string;
370
- };
371
- trace: {
372
- mode: BrowserTraceViewMode;
373
- tracesDir?: string;
374
- screenshots?: boolean;
375
- snapshots?: boolean;
376
- };
377
- }
378
- type ToMatchScreenshotResolvePath = (data: {
211
+ readonly options: TaskOptions;
379
212
  /**
380
- * Path **without** extension, sanitized and relative to the test file.
381
- *
382
- * This comes from the arguments passed to `toMatchScreenshot`; if called
383
- * without arguments this will be the auto-generated name.
384
- *
385
- * @example
386
- * test('calls `onClick`', () => {
387
- * expect(locator).toMatchScreenshot()
388
- * // arg = "calls-onclick-1"
389
- * })
390
- *
391
- * @example
392
- * expect(locator).toMatchScreenshot('foo/bar/baz.png')
393
- * // arg = "foo/bar/baz"
394
- *
395
- * @example
396
- * expect(locator).toMatchScreenshot('../foo/bar/baz.png')
397
- * // arg = "foo/bar/baz"
213
+ * Checks if the suite has any failed tests.
214
+ * This will also return `false` if suite failed during collection.
398
215
  */
399
- arg: string;
216
+ ok: () => boolean;
400
217
  /**
401
- * Screenshot extension, with leading dot.
402
- *
403
- * This can be set through the arguments passed to `toMatchScreenshot`, but
404
- * 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.
405
219
  */
406
- ext: string;
220
+ meta: () => TaskMeta;
407
221
  /**
408
- * The instance's browser name.
222
+ * Checks the running state of the suite.
409
223
  */
410
- browserName: string;
224
+ state(): TestSuiteState;
411
225
  /**
412
- * The value of {@linkcode process.platform}.
226
+ * Full name of the suite including all parent suites separated with `>`.
413
227
  */
414
- platform: NodeJS.Platform;
228
+ get fullName(): string;
229
+ }
230
+ declare class TestModule extends SuiteImplementation {
231
+ readonly location: undefined;
232
+ readonly type = "module";
415
233
  /**
416
- * The value provided to
417
- * {@linkcode https://vitest.dev/guide/browser/config#browser-screenshotdirectory|browser.screenshotDirectory},
418
- * 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.
419
237
  */
420
- screenshotDirectory: string;
238
+ readonly moduleId: string;
421
239
  /**
422
- * Absolute path to the project's
423
- * {@linkcode https://vitest.dev/config/#root|root}.
240
+ * Module id relative to the project. This is the same as `task.name`.
424
241
  */
425
- root: string;
242
+ readonly relativeModuleId: string;
426
243
  /**
427
- * Path to the test file, relative to the project's
428
- * {@linkcode https://vitest.dev/config/#root|root}.
244
+ * Checks the running state of the test file.
429
245
  */
430
- testFileDirectory: string;
246
+ state(): TestModuleState;
431
247
  /**
432
- * The test's filename.
248
+ * Checks if the module has any failed tests.
249
+ * This will also return `false` if module failed during collection.
433
250
  */
434
- testFileName: string;
251
+ ok: () => boolean;
435
252
  /**
436
- * The {@linkcode https://vitest.dev/api/#test|test}'s name, including
437
- * parent {@linkcode https://vitest.dev/api/#describe|describe}, sanitized.
253
+ * The meta information attached to the module during its collection or execution.
438
254
  */
439
- testName: string;
255
+ meta: () => TaskMeta;
440
256
  /**
441
- * The value provided to
442
- * {@linkcode https://vitest.dev/config/#attachmentsdir|attachmentsDir},
443
- * 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`.
444
259
  */
445
- attachmentsDir: string;
446
- }) => string;
447
- 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 {
448
276
  /**
449
- * Overrides default reference screenshot path.
450
- *
451
- * @default `${root}/${testFileDirectory}/${screenshotDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
277
+ * The test was collected, but didn't finish running yet.
452
278
  */
453
- resolveScreenshotPath?: ToMatchScreenshotResolvePath;
279
+ readonly state: "pending";
454
280
  /**
455
- * Overrides default screenshot path used for diffs.
456
- *
457
- * @default `${root}/${attachmentsDir}/${testFileDirectory}/${testFileName}/${arg}-${browserName}-${platform}${ext}`
281
+ * Pending tests have no errors.
458
282
  */
459
- resolveDiffPath?: ToMatchScreenshotResolvePath;
283
+ readonly errors: undefined;
460
284
  }
461
- interface ToMatchScreenshotComparators {}
462
-
463
- type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
464
- type Pool = BuiltinPool | (string & {});
465
- interface PoolOptions extends Record<string, unknown> {
285
+ interface TestResultPassed {
466
286
  /**
467
- * Run tests in `node:worker_threads`.
468
- *
469
- * Test isolation (when enabled) is done by spawning a new thread for each test file.
470
- *
471
- * This pool is used by default.
287
+ * The test passed successfully.
472
288
  */
473
- threads?: ThreadsOptions & WorkerContextOptions;
289
+ readonly state: "passed";
474
290
  /**
475
- * 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.
476
292
  *
477
- * 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.
478
294
  */
479
- forks?: ForksOptions & WorkerContextOptions;
295
+ readonly errors: ReadonlyArray<TestError> | undefined;
296
+ }
297
+ interface TestResultFailed {
480
298
  /**
481
- * Run tests in isolated `node:vm`.
482
- * Test files are run parallel using `node:worker_threads`.
483
- *
484
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
299
+ * The test failed to execute.
485
300
  */
486
- vmThreads?: ThreadsOptions & VmOptions;
301
+ readonly state: "failed";
487
302
  /**
488
- * Run tests in isolated `node:vm`.
489
- *
490
- * Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
491
- *
492
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
303
+ * Errors that were thrown during the test execution.
493
304
  */
494
- vmForks?: ForksOptions & VmOptions;
495
- }
496
- interface ResolvedPoolOptions extends PoolOptions {
497
- threads?: ResolvedThreadsOptions & WorkerContextOptions;
498
- forks?: ResolvedForksOptions & WorkerContextOptions;
499
- vmThreads?: ResolvedThreadsOptions & VmOptions;
500
- vmForks?: ResolvedForksOptions & VmOptions;
305
+ readonly errors: ReadonlyArray<TestError>;
501
306
  }
502
- interface ThreadsOptions {
503
- /** Maximum amount of threads to use */
504
- maxThreads?: number | string;
307
+ interface TestResultSkipped {
505
308
  /**
506
- * Run tests inside a single thread.
507
- *
508
- * @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.
509
311
  */
510
- singleThread?: boolean;
312
+ readonly state: "skipped";
511
313
  /**
512
- * Use Atomics to synchronize threads
513
- *
514
- * This can improve performance in some cases, but might cause segfault in older Node versions.
515
- *
516
- * @default false
314
+ * Skipped tests have no errors.
517
315
  */
518
- useAtomics?: boolean;
519
- }
520
- interface ResolvedThreadsOptions extends ThreadsOptions {
521
- maxThreads?: number;
522
- }
523
- interface ForksOptions {
524
- /** Maximum amount of child processes to use */
525
- maxForks?: number | string;
316
+ readonly errors: undefined;
526
317
  /**
527
- * Run tests inside a single fork.
528
- *
529
- * @default false
318
+ * A custom note passed down to `ctx.skip(note)`.
530
319
  */
531
- singleFork?: boolean;
532
- }
533
- interface ResolvedForksOptions extends ForksOptions {
534
- maxForks?: number;
320
+ readonly note: string | undefined;
535
321
  }
536
- interface WorkerContextOptions {
322
+ interface TestDiagnostic {
537
323
  /**
538
- * Isolate test environment by recycling `worker_threads` or `child_process` after each test
539
- *
540
- * @default true
324
+ * If the duration of the test is above `slowTestThreshold`.
541
325
  */
542
- isolate?: boolean;
326
+ readonly slow: boolean;
543
327
  /**
544
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
545
- *
546
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
547
- *
548
- * Set to `process.execArgv` to pass all arguments of the current process.
549
- *
550
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
551
- *
552
- * @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.
553
330
  */
554
- execArgv?: string[];
555
- }
556
- interface VmOptions {
331
+ readonly heap: number | undefined;
557
332
  /**
558
- * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
559
- * If you see memory leaks, try to tinker this value.
333
+ * The time it takes to execute the test in ms.
560
334
  */
561
- memoryLimit?: string | number;
562
- /** Isolation is always enabled */
563
- isolate?: true;
335
+ readonly duration: number;
564
336
  /**
565
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
566
- *
567
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
568
- *
569
- * Set to `process.execArgv` to pass all arguments of the current process.
570
- *
571
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
572
- *
573
- * @default [] // no execution arguments are passed
574
- */
575
- execArgv?: string[];
576
- }
577
-
578
- declare class TestSpecification {
579
- /**
580
- * The task ID associated with the test module.
581
- */
582
- readonly taskId: string;
583
- /**
584
- * The test project that the module belongs to.
585
- */
586
- readonly project: TestProject;
587
- /**
588
- * The ID of the module in the Vite module graph. It is usually an absolute file path.
337
+ * The time in ms when the test started.
589
338
  */
590
- readonly moduleId: string;
339
+ readonly startTime: number;
591
340
  /**
592
- * The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
593
- * @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
341
+ * The amount of times the test was retried.
594
342
  */
595
- readonly pool: Pool;
343
+ readonly retryCount: number;
596
344
  /**
597
- * Line numbers of the test locations to run.
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.
598
347
  */
599
- readonly testLines: number[] | undefined;
600
- constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
348
+ readonly repeatCount: number;
601
349
  /**
602
- * Test module associated with the specification.
350
+ * If test passed on a second retry.
603
351
  */
604
- get testModule(): TestModule | undefined;
605
- toJSON(): SerializedTestSpecification;
352
+ readonly flaky: boolean;
606
353
  }
607
-
608
- declare class TestProject {
609
- options?: InitializeProjectOptions | undefined;
610
- /**
611
- * The global Vitest instance.
612
- */
613
- readonly vitest: Vitest;
614
- /**
615
- * Resolved global configuration. If there are no workspace projects, this will be the same as `config`.
616
- */
617
- readonly globalConfig: ResolvedConfig;
618
- /**
619
- * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
620
- */
621
- browser?: ProjectBrowser;
622
- /**
623
- * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
624
- */
625
- readonly tmpDir: string;
626
- /** @inetrnal */ testFilesList: string[] | null;
627
- private runner;
628
- private closingPromise;
629
- private typecheckFilesList;
630
- private _globalSetups?;
631
- private _provided;
632
- constructor(vitest: Vitest, options?: InitializeProjectOptions | undefined);
633
- /**
634
- * The unique hash of this project. This value is consistent between the reruns.
635
- *
636
- * It is based on the root of the project (not consistent between OS) and its name.
637
- */
638
- get hash(): string;
354
+ interface ModuleDiagnostic {
639
355
  /**
640
- * Provide a value to the test context. This value will be available to all tests with `inject`.
356
+ * The time it takes to import and initiate an environment.
641
357
  */
642
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
358
+ readonly environmentSetupDuration: number;
643
359
  /**
644
- * Get the provided context. The project context is merged with the global context.
360
+ * The time it takes Vitest to setup test harness (runner, mocks, etc.).
645
361
  */
646
- getProvidedContext(): ProvidedContext;
362
+ readonly prepareDuration: number;
647
363
  /**
648
- * Creates a new test specification. Specifications describe how to run tests.
649
- * @param moduleId The file path
364
+ * The time it takes to import the test module.
365
+ * This includes importing everything in the module and executing suite callbacks.
650
366
  */
651
- createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
652
- toJSON(): SerializedTestProject;
367
+ readonly collectDuration: number;
653
368
  /**
654
- * Vite's dev server instance. Every workspace project has its own server.
369
+ * The time it takes to import the setup module.
655
370
  */
656
- get vite(): ViteDevServer;
371
+ readonly setupDuration: number;
657
372
  /**
658
- * Resolved project configuration.
373
+ * Accumulated duration of all tests and hooks in the module.
659
374
  */
660
- get config(): ResolvedConfig;
375
+ readonly duration: number;
661
376
  /**
662
- * The name of the project or an empty string if not set.
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.
663
379
  */
664
- get name(): string;
380
+ readonly heap: number | undefined;
665
381
  /**
666
- * The color used when reporting tasks of this project.
382
+ * The time spent importing every non-externalized dependency that Vitest has processed.
667
383
  */
668
- get color(): ProjectName["color"];
384
+ readonly importDurations: Record<string, ImportDuration>;
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;
390
+
391
+ declare class TestSpecification {
669
392
  /**
670
- * Serialized project configuration. This is the config that tests receive.
393
+ * The task ID associated with the test module.
671
394
  */
672
- get serializedConfig(): SerializedConfig;
395
+ readonly taskId: string;
673
396
  /**
674
- * Check if this is the root project. The root project is the one that has the root config.
397
+ * The test project that the module belongs to.
675
398
  */
676
- isRootProject(): boolean;
677
- onTestsRerun(cb: OnTestsRerunHandler): void;
399
+ readonly project: TestProject;
678
400
  /**
679
- * Get all files in the project that match the globs in the config and the filters.
680
- * @param filters String filters to match the test files.
401
+ * The ID of the module in the Vite module graph. It is usually an absolute file path.
681
402
  */
682
- globTestFiles(filters?: string[]): Promise<{
683
- /**
684
- * Test files that match the filters.
685
- */
686
- testFiles: string[];
687
- /**
688
- * Typecheck test files that match the filters. This will be empty unless `typecheck.enabled` is `true`.
689
- */
690
- typecheckTestFiles: string[];
691
- }>;
692
- private globAllTestFiles;
693
- isBrowserEnabled(): boolean;
694
- private markTestFile;
403
+ readonly moduleId: string;
695
404
  /**
696
- * Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
405
+ * The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
406
+ * @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
697
407
  */
698
- matchesTestGlob(moduleId: string, source?: () => string): boolean;
699
- private isInSourceTestCode;
700
- private filterFiles;
701
- private _parentBrowser?;
408
+ readonly pool: Pool;
702
409
  /**
703
- * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
704
- * If the resources are needed again, create a new project.
410
+ * Line numbers of the test locations to run.
705
411
  */
706
- close(): Promise<void>;
412
+ readonly testLines: number[] | undefined;
413
+ constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
707
414
  /**
708
- * Import a file using Vite module runner.
709
- * @param moduleId The ID of the module in Vite module graph
415
+ * Test module associated with the specification.
710
416
  */
711
- import<T>(moduleId: string): Promise<T>;
712
- private _setHash;
713
- private _serializeOverriddenConfig;
714
- private clearTmpDir;
715
- }
716
- interface SerializedTestProject {
717
- name: string;
718
- serializedConfig: SerializedConfig;
719
- context: ProvidedContext;
417
+ get testModule(): TestModule | undefined;
418
+ toJSON(): SerializedTestSpecification;
720
419
  }
721
- interface InitializeProjectOptions extends TestProjectInlineConfiguration {
722
- configFile: string | false;
420
+
421
+ interface CoverageSummaryData {
422
+ lines: Totals;
423
+ statements: Totals;
424
+ branches: Totals;
425
+ functions: Totals;
723
426
  }
724
427
 
725
- declare class ReportedTaskImplementation {
726
- /**
727
- * The project associated with the test or suite.
728
- */
729
- readonly project: TestProject;
730
- /**
731
- * Unique identifier.
732
- * This ID is deterministic and will be the same for the same test across multiple runs.
733
- * The ID is based on the project name, module url and test order.
734
- */
735
- readonly id: string;
736
- /**
737
- * Location in the module where the test or suite is defined.
738
- */
739
- readonly location: {
740
- line: number;
741
- column: number;
742
- } | undefined;
743
- /**
744
- * Checks if the test did not fail the suite.
745
- * If the test is not finished yet or was skipped, it will return `true`.
746
- */
747
- ok(): boolean;
748
- /**
749
- * Custom metadata that was attached to the test during its execution.
750
- */
751
- meta(): TaskMeta;
428
+ declare class CoverageSummary {
429
+ constructor(data: CoverageSummary | CoverageSummaryData);
430
+ merge(obj: CoverageSummary): CoverageSummary;
431
+ toJSON(): CoverageSummaryData;
432
+ isEmpty(): boolean;
433
+ data: CoverageSummaryData;
434
+ lines: Totals;
435
+ statements: Totals;
436
+ branches: Totals;
437
+ functions: Totals;
752
438
  }
753
- declare class TestCase extends ReportedTaskImplementation {
754
- #private;
755
- readonly type = "test";
756
- /**
757
- * Direct reference to the test module where the test or suite is defined.
758
- */
759
- readonly module: TestModule;
760
- /**
761
- * Name of the test.
762
- */
763
- readonly name: string;
764
- /**
765
- * Options that the test was initiated with.
766
- */
767
- readonly options: TaskOptions;
768
- /**
769
- * Parent suite. If the test was called directly inside the module, the parent will be the module itself.
770
- */
771
- readonly parent: TestSuite | TestModule;
772
- /**
773
- * Full name of the test including all parent suites separated with `>`.
774
- */
775
- get fullName(): string;
776
- /**
777
- * Test results.
778
- * - **pending**: Test was collected, but didn't finish running yet.
779
- * - **passed**: Test passed successfully
780
- * - **failed**: Test failed to execute
781
- * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
782
- */
783
- result(): TestResult;
784
- /**
785
- * Test annotations added via the `task.annotate` API during the test execution.
786
- */
787
- annotations(): ReadonlyArray<TestAnnotation>;
788
- /**
789
- * Useful information about the test like duration, memory usage, etc.
790
- * Diagnostic is only available after the test has finished.
791
- */
792
- diagnostic(): TestDiagnostic | undefined;
793
- }
794
- declare class TestCollection {
795
- #private;
796
- constructor(task: Suite | File, project: TestProject);
797
- /**
798
- * Returns the test or suite at a specific index.
799
- */
800
- at(index: number): TestCase | TestSuite | undefined;
801
- /**
802
- * The number of tests and suites in the collection.
803
- */
804
- get size(): number;
805
- /**
806
- * Returns the collection in array form for easier manipulation.
807
- */
808
- array(): (TestCase | TestSuite)[];
809
- /**
810
- * Filters all tests that are part of this collection and its children.
811
- */
812
- allTests(state?: TestState): Generator<TestCase, undefined, void>;
813
- /**
814
- * Filters only the tests that are part of this collection.
815
- */
816
- tests(state?: TestState): Generator<TestCase, undefined, void>;
817
- /**
818
- * Filters only the suites that are part of this collection.
819
- */
820
- suites(): Generator<TestSuite, undefined, void>;
821
- /**
822
- * Filters all suites that are part of this collection and its children.
823
- */
824
- allSuites(): Generator<TestSuite, undefined, void>;
825
- [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
826
- }
827
-
828
- type ReportedHookContext = {
829
- readonly name: "beforeAll" | "afterAll";
830
- readonly entity: TestSuite | TestModule;
831
- } | {
832
- readonly name: "beforeEach" | "afterEach";
833
- readonly entity: TestCase;
834
- };
835
- declare abstract class SuiteImplementation extends ReportedTaskImplementation {
836
- /**
837
- * Collection of suites and tests that are part of this suite.
838
- */
839
- readonly children: TestCollection;
840
- /**
841
- * Errors that happened outside of the test run during collection, like syntax errors.
842
- */
843
- errors(): SerializedError[];
844
- }
845
- declare class TestSuite extends SuiteImplementation {
846
- #private;
847
- readonly type = "suite";
848
- /**
849
- * Name of the test or the suite.
850
- */
851
- readonly name: string;
852
- /**
853
- * Direct reference to the test module where the test or suite is defined.
854
- */
855
- readonly module: TestModule;
856
- /**
857
- * Parent suite. If suite was called directly inside the module, the parent will be the module itself.
858
- */
859
- readonly parent: TestSuite | TestModule;
860
- /**
861
- * Options that suite was initiated with.
862
- */
863
- readonly options: TaskOptions;
864
- /**
865
- * Checks if the suite has any failed tests.
866
- * This will also return `false` if suite failed during collection.
867
- */
868
- ok: () => boolean;
869
- /**
870
- * The meta information attached to the suite during its collection or execution.
871
- */
872
- meta: () => TaskMeta;
873
- /**
874
- * Checks the running state of the suite.
875
- */
876
- state(): TestSuiteState;
877
- /**
878
- * Full name of the suite including all parent suites separated with `>`.
879
- */
880
- get fullName(): string;
881
- }
882
- declare class TestModule extends SuiteImplementation {
883
- readonly location: undefined;
884
- readonly type = "module";
885
- /**
886
- * This is usually an absolute UNIX file path.
887
- * It can be a virtual ID if the file is not on the disk.
888
- * This value corresponds to the ID in the Vite's module graph.
889
- */
890
- readonly moduleId: string;
891
- /**
892
- * Module id relative to the project. This is the same as `task.name`.
893
- */
894
- readonly relativeModuleId: string;
895
- /**
896
- * Checks the running state of the test file.
897
- */
898
- state(): TestModuleState;
899
- /**
900
- * Checks if the module has any failed tests.
901
- * This will also return `false` if module failed during collection.
902
- */
903
- ok: () => boolean;
904
- /**
905
- * The meta information attached to the module during its collection or execution.
906
- */
907
- meta: () => TaskMeta;
908
- /**
909
- * Useful information about the module like duration, memory usage, etc.
910
- * If the module was not executed yet, all diagnostic values will return `0`.
911
- */
912
- diagnostic(): ModuleDiagnostic;
913
- }
914
- interface TaskOptions {
915
- readonly each: boolean | undefined;
916
- readonly fails: boolean | undefined;
917
- readonly concurrent: boolean | undefined;
918
- readonly shuffle: boolean | undefined;
919
- readonly retry: number | undefined;
920
- readonly repeats: number | undefined;
921
- readonly mode: "run" | "only" | "skip" | "todo";
922
- }
923
- type TestSuiteState = "skipped" | "pending" | "failed" | "passed";
924
- type TestModuleState = TestSuiteState | "queued";
925
- type TestState = TestResult["state"];
926
- type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
927
- interface TestResultPending {
928
- /**
929
- * The test was collected, but didn't finish running yet.
930
- */
931
- readonly state: "pending";
932
- /**
933
- * Pending tests have no errors.
934
- */
935
- readonly errors: undefined;
936
- }
937
- interface TestResultPassed {
938
- /**
939
- * The test passed successfully.
940
- */
941
- readonly state: "passed";
942
- /**
943
- * Errors that were thrown during the test execution.
944
- *
945
- * **Note**: If test was retried successfully, errors will still be reported.
946
- */
947
- readonly errors: ReadonlyArray<TestError> | undefined;
948
- }
949
- interface TestResultFailed {
950
- /**
951
- * The test failed to execute.
952
- */
953
- readonly state: "failed";
954
- /**
955
- * Errors that were thrown during the test execution.
956
- */
957
- readonly errors: ReadonlyArray<TestError>;
958
- }
959
- interface TestResultSkipped {
960
- /**
961
- * The test was skipped with `only` (on another test), `skip` or `todo` flag.
962
- * You can see which one was used in the `options.mode` option.
963
- */
964
- readonly state: "skipped";
965
- /**
966
- * Skipped tests have no errors.
967
- */
968
- readonly errors: undefined;
969
- /**
970
- * A custom note passed down to `ctx.skip(note)`.
971
- */
972
- readonly note: string | undefined;
973
- }
974
- interface TestDiagnostic {
975
- /**
976
- * If the duration of the test is above `slowTestThreshold`.
977
- */
978
- readonly slow: boolean;
979
- /**
980
- * The amount of memory used by the test in bytes.
981
- * This value is only available if the test was executed with `logHeapUsage` flag.
982
- */
983
- readonly heap: number | undefined;
984
- /**
985
- * The time it takes to execute the test in ms.
986
- */
987
- readonly duration: number;
988
- /**
989
- * The time in ms when the test started.
990
- */
991
- readonly startTime: number;
992
- /**
993
- * The amount of times the test was retried.
994
- */
995
- readonly retryCount: number;
996
- /**
997
- * The amount of times the test was repeated as configured by `repeats` option.
998
- * This value can be lower if the test failed during the repeat and no `retry` is configured.
999
- */
1000
- readonly repeatCount: number;
1001
- /**
1002
- * If test passed on a second retry.
1003
- */
1004
- readonly flaky: boolean;
1005
- }
1006
- interface ModuleDiagnostic {
1007
- /**
1008
- * The time it takes to import and initiate an environment.
1009
- */
1010
- readonly environmentSetupDuration: number;
1011
- /**
1012
- * The time it takes Vitest to setup test harness (runner, mocks, etc.).
1013
- */
1014
- readonly prepareDuration: number;
1015
- /**
1016
- * The time it takes to import the test module.
1017
- * This includes importing everything in the module and executing suite callbacks.
1018
- */
1019
- readonly collectDuration: number;
1020
- /**
1021
- * The time it takes to import the setup module.
1022
- */
1023
- readonly setupDuration: number;
1024
- /**
1025
- * Accumulated duration of all tests and hooks in the module.
1026
- */
1027
- readonly duration: number;
1028
- /**
1029
- * The amount of memory used by the test module in bytes.
1030
- * This value is only available if the test was executed with `logHeapUsage` flag.
1031
- */
1032
- readonly heap: number | undefined;
1033
- /**
1034
- * The time spent importing every non-externalized dependency that Vitest has processed.
1035
- */
1036
- readonly importDurations: Record<string, ImportDuration>;
1037
- }
1038
- declare function experimental_getRunnerTask(entity: TestCase): Test;
1039
- declare function experimental_getRunnerTask(entity: TestSuite): Suite;
1040
- declare function experimental_getRunnerTask(entity: TestModule): File;
1041
- declare function experimental_getRunnerTask(entity: TestCase | TestSuite | TestModule): Suite | File | Test;
1042
-
1043
- interface CoverageSummaryData {
1044
- lines: Totals;
1045
- statements: Totals;
1046
- branches: Totals;
1047
- functions: Totals;
1048
- }
1049
-
1050
- declare class CoverageSummary {
1051
- constructor(data: CoverageSummary | CoverageSummaryData);
1052
- merge(obj: CoverageSummary): CoverageSummary;
1053
- toJSON(): CoverageSummaryData;
1054
- isEmpty(): boolean;
1055
- data: CoverageSummaryData;
1056
- lines: Totals;
1057
- statements: Totals;
1058
- branches: Totals;
1059
- functions: Totals;
1060
- }
1061
-
1062
- interface CoverageMapData {
1063
- [key: string]: FileCoverage | FileCoverageData;
439
+
440
+ interface CoverageMapData {
441
+ [key: string]: FileCoverage | FileCoverageData;
1064
442
  }
1065
443
 
1066
444
  declare class CoverageMap {
@@ -1525,6 +903,80 @@ declare class VitestPackageInstaller {
1525
903
  ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1526
904
  }
1527
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
+
1528
980
  interface BlobOptions {
1529
981
  outputFile?: string;
1530
982
  }
@@ -1551,7 +1003,6 @@ declare class StateManager {
1551
1003
  idMap: Map<string, Task>;
1552
1004
  taskFileMap: WeakMap<Task, File>;
1553
1005
  errorsSet: Set<unknown>;
1554
- processTimeoutCauses: Set<string>;
1555
1006
  reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1556
1007
  blobs?: MergedBlobs;
1557
1008
  transformTime: number;
@@ -1572,408 +1023,907 @@ declare class StateManager {
1572
1023
  catchError(error: unknown, type: string): void;
1573
1024
  clearErrors(): void;
1574
1025
  getUnhandledErrors(): unknown[];
1575
- addProcessTimeoutCause(cause: string): void;
1576
- getProcessTimeoutCauses(): string[];
1577
1026
  getPaths(): string[];
1578
1027
  /**
1579
- * Return files that were running or collected.
1028
+ * Return files that were running or collected.
1029
+ */
1030
+ getFiles(keys?: string[]): File[];
1031
+ getTestModules(keys?: string[]): TestModule[];
1032
+ getFilepaths(): string[];
1033
+ getFailedFilepaths(): string[];
1034
+ collectPaths(paths?: string[]): void;
1035
+ collectFiles(project: TestProject, files?: File[]): void;
1036
+ clearFiles(project: TestProject, paths?: string[]): void;
1037
+ updateId(task: Task, project: TestProject): void;
1038
+ getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1039
+ getReportedEntityById(taskId: string): TestModule | TestCase | TestSuite | undefined;
1040
+ updateTasks(packs: TaskResultPack[]): void;
1041
+ updateUserLog(log: UserConsoleLog): void;
1042
+ getCountOfFailedTests(): number;
1043
+ cancelFiles(files: FileSpecification[], project: TestProject): void;
1044
+ }
1045
+
1046
+ declare class VitestWatcher {
1047
+ private vitest;
1048
+ /**
1049
+ * Modules that will be invalidated on the next run.
1050
+ */
1051
+ readonly invalidates: Set<string>;
1052
+ /**
1053
+ * Test files that have changed and need to be rerun.
1054
+ */
1055
+ readonly changedTests: Set<string>;
1056
+ private readonly _onRerun;
1057
+ constructor(vitest: Vitest);
1058
+ unregisterWatcher: () => void;
1059
+ registerWatcher(): this;
1060
+ private scheduleRerun;
1061
+ private getTestFilesFromWatcherTrigger;
1062
+ onFileChange: (id: string) => void;
1063
+ onFileDelete: (id: string) => void;
1064
+ onFileCreate: (id: string) => void;
1065
+ private handleSetupFile;
1066
+ /**
1067
+ * @returns A value indicating whether rerun is needed (changedTests was mutated)
1068
+ */
1069
+ private handleFileChanged;
1070
+ }
1071
+ interface WatcherTriggerPattern {
1072
+ pattern: RegExp;
1073
+ testsToRun: (file: string, match: RegExpMatchArray) => string[] | string | null | undefined | void;
1074
+ }
1075
+
1076
+ interface VitestOptions {
1077
+ packageInstaller?: VitestPackageInstaller;
1078
+ stdin?: NodeJS.ReadStream;
1079
+ stdout?: NodeJS.WriteStream | Writable;
1080
+ stderr?: NodeJS.WriteStream | Writable;
1081
+ }
1082
+ declare class Vitest {
1083
+ readonly mode: VitestRunMode;
1084
+ /**
1085
+ * Current Vitest version.
1086
+ * @example '2.0.0'
1087
+ */
1088
+ readonly version: string;
1089
+ static readonly version: string;
1090
+ /**
1091
+ * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
1092
+ * It's possible to override stdout and stderr streams when initiating Vitest.
1093
+ * @example
1094
+ * new Vitest('test', {
1095
+ * stdout: new Writable(),
1096
+ * })
1097
+ */
1098
+ readonly logger: Logger;
1099
+ /**
1100
+ * The package installer instance used to install Vitest packages.
1101
+ * @example
1102
+ * await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
1103
+ */
1104
+ readonly packageInstaller: VitestPackageInstaller;
1105
+ /**
1106
+ * A path to the built Vitest directory. This is usually a folder in `node_modules`.
1107
+ */
1108
+ readonly distPath: string;
1109
+ /**
1110
+ * A list of projects that are currently running.
1111
+ * If projects were filtered with `--project` flag, they won't appear here.
1112
+ */
1113
+ projects: TestProject[];
1114
+ /**
1115
+ * A watcher handler. This is not the file system watcher. The handler only
1116
+ * exposes methods to handle changed files.
1117
+ *
1118
+ * If you have your own watcher, you can use these methods to replicate
1119
+ * Vitest behaviour.
1120
+ */
1121
+ readonly watcher: VitestWatcher;
1122
+ private isFirstRun;
1123
+ private restartsCount;
1124
+ private readonly specifications;
1125
+ private pool;
1126
+ private _config?;
1127
+ private _vite?;
1128
+ private _state?;
1129
+ private _cache?;
1130
+ private _snapshot?;
1131
+ private _coverageProvider?;
1132
+ constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
1133
+ private _onRestartListeners;
1134
+ private _onClose;
1135
+ private _onSetServer;
1136
+ private _onCancelListeners;
1137
+ private _onUserTestsRerun;
1138
+ private _onFilterWatchedSpecification;
1139
+ /**
1140
+ * The global config.
1141
+ */
1142
+ get config(): ResolvedConfig;
1143
+ /**
1144
+ * Global Vite's dev server instance.
1145
+ */
1146
+ get vite(): ViteDevServer;
1147
+ /**
1148
+ * The global test state manager.
1149
+ * @experimental The State API is experimental and not subject to semver.
1150
+ */
1151
+ get state(): StateManager;
1152
+ /**
1153
+ * The global snapshot manager. You can access the current state on `snapshot.summary`.
1154
+ */
1155
+ get snapshot(): SnapshotManager;
1156
+ /**
1157
+ * Test results and test file stats cache. Primarily used by the sequencer to sort tests.
1158
+ */
1159
+ get cache(): VitestCache;
1160
+ enableCoverage(): Promise<void>;
1161
+ disableCoverage(): void;
1162
+ private _coverageOverrideCache;
1163
+ /**
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.
1580
1267
  */
1581
- getFiles(keys?: string[]): File[];
1582
- getTestModules(keys?: string[]): TestModule[];
1583
- getFilepaths(): string[];
1584
- getFailedFilepaths(): string[];
1585
- collectPaths(paths?: string[]): void;
1586
- collectFiles(project: TestProject, files?: File[]): void;
1587
- clearFiles(project: TestProject, paths?: string[]): void;
1588
- updateId(task: Task, project: TestProject): void;
1589
- getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1590
- getReportedEntityById(taskId: string): TestModule | TestCase | TestSuite | undefined;
1591
- updateTasks(packs: TaskResultPack[]): void;
1592
- updateUserLog(log: UserConsoleLog): void;
1593
- getCountOfFailedTests(): number;
1594
- cancelFiles(files: string[], project: TestProject): void;
1595
- }
1596
-
1597
- declare class VitestWatcher {
1598
- private vitest;
1268
+ cancelCurrentRun(reason: CancelReason): Promise<void>;
1269
+ private initializeGlobalSetup;
1599
1270
  /**
1600
- * Modules that will be invalidated on the next run.
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
1601
1273
  */
1602
- readonly invalidates: Set<string>;
1274
+ updateSnapshot(files?: string[]): Promise<TestRunResult>;
1603
1275
  /**
1604
- * Test files that have changed and need to be rerun.
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`.
1605
1281
  */
1606
- readonly changedTests: Set<string>;
1607
- private readonly _onRerun;
1608
- constructor(vitest: Vitest);
1609
- unregisterWatcher: () => void;
1610
- registerWatcher(): this;
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;
1611
1301
  private scheduleRerun;
1612
- private getTestFilesFromWatcherTrigger;
1613
- onFileChange: (id: string) => void;
1614
- onFileDelete: (id: string) => void;
1615
- onFileCreate: (id: string) => void;
1616
- private handleSetupFile;
1617
1302
  /**
1618
- * @returns A value indicating whether rerun is needed (changedTests was mutated)
1303
+ * Invalidate a file in all projects.
1619
1304
  */
1620
- private handleFileChanged;
1621
- }
1622
- interface WatcherTriggerPattern {
1623
- pattern: RegExp;
1624
- testsToRun: (file: string, match: RegExpMatchArray) => string[] | string | null | undefined | void;
1625
- }
1626
-
1627
- interface VitestOptions {
1628
- packageInstaller?: VitestPackageInstaller;
1629
- stdin?: NodeJS.ReadStream;
1630
- stdout?: NodeJS.WriteStream | Writable;
1631
- stderr?: NodeJS.WriteStream | Writable;
1632
- }
1633
- declare class Vitest {
1634
- readonly mode: VitestRunMode;
1305
+ invalidateFile(filepath: string): void;
1306
+ private reportCoverage;
1635
1307
  /**
1636
- * Current Vitest version.
1637
- * @example '2.0.0'
1308
+ * Closes all projects and their associated resources.
1309
+ * This can only be called once; the closing promise is cached until the server restarts.
1638
1310
  */
1639
- readonly version: string;
1640
- static readonly version: string;
1311
+ close(): Promise<void>;
1641
1312
  /**
1642
- * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
1643
- * It's possible to override stdout and stderr streams when initiating Vitest.
1644
- * @example
1645
- * new Vitest('test', {
1646
- * stdout: new Writable(),
1647
- * })
1313
+ * Closes all projects and exit the process
1314
+ * @param force If true, the process will exit immediately after closing the projects.
1648
1315
  */
1649
- readonly logger: Logger;
1316
+ exit(force?: boolean): Promise<void>;
1650
1317
  /**
1651
- * The package installer instance used to install Vitest packages.
1652
- * @example
1653
- * await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
1318
+ * Should the server be kept running after the tests are done.
1654
1319
  */
1655
- readonly packageInstaller: VitestPackageInstaller;
1320
+ shouldKeepServer(): boolean;
1656
1321
  /**
1657
- * A path to the built Vitest directory. This is usually a folder in `node_modules`.
1322
+ * Register a handler that will be called when the server is restarted due to a config change.
1658
1323
  */
1659
- readonly distPath: string;
1324
+ onServerRestart(fn: OnServerRestartHandler): void;
1660
1325
  /**
1661
- * A list of projects that are currently running.
1662
- * If projects were filtered with `--project` flag, they won't appear here.
1326
+ * Register a handler that will be called when the test run is cancelled with `vitest.cancelCurrentRun`.
1663
1327
  */
1664
- projects: TestProject[];
1328
+ onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1665
1329
  /**
1666
- * A watcher handler. This is not the file system watcher. The handler only
1667
- * exposes methods to handle changed files.
1668
- *
1669
- * If you have your own watcher, you can use these methods to replicate
1670
- * Vitest behaviour.
1330
+ * Register a handler that will be called when the server is closed.
1671
1331
  */
1672
- readonly watcher: VitestWatcher;
1673
- private isFirstRun;
1674
- private restartsCount;
1675
- private readonly specifications;
1676
- private pool;
1677
- private _config?;
1678
- private _vite?;
1679
- private _state?;
1680
- private _cache?;
1681
- private _snapshot?;
1682
- private _coverageProvider?;
1683
- constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
1684
- private _onRestartListeners;
1685
- private _onClose;
1686
- private _onSetServer;
1687
- private _onCancelListeners;
1688
- private _onUserTestsRerun;
1689
- private _onFilterWatchedSpecification;
1332
+ onClose(fn: () => Awaitable<void>): void;
1690
1333
  /**
1691
- * The global config.
1334
+ * Register a handler that will be called when the tests are rerunning.
1692
1335
  */
1693
- get config(): ResolvedConfig;
1336
+ onTestsRerun(fn: OnTestsRerunHandler): void;
1694
1337
  /**
1695
- * Global Vite's dev server instance.
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))
1696
1343
  */
1697
- get vite(): ViteDevServer;
1344
+ onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
1698
1345
  /**
1699
- * The global test state manager.
1700
- * @experimental The State API is experimental and not subject to semver.
1346
+ * Check if the project with a given name should be included.
1701
1347
  */
1702
- get state(): StateManager;
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[];
1703
1386
  /**
1704
- * The global snapshot manager. You can access the current state on `snapshot.summary`.
1387
+ * @experimental opt-in into file parallelisation
1705
1388
  */
1706
- get snapshot(): SnapshotManager;
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"> {
1707
1399
  /**
1708
- * Test results and test file stats cache. Primarily used by the sequencer to sort tests.
1400
+ * Name of the browser
1709
1401
  */
1710
- get cache(): VitestCache;
1711
- enableCoverage(): Promise<void>;
1712
- disableCoverage(): void;
1713
- private _coverageOverrideCache;
1402
+ browser: keyof _BrowserNames extends never ? string : _BrowserNames[keyof _BrowserNames];
1403
+ name?: string;
1404
+ provider?: BrowserProviderOption;
1405
+ }
1406
+ interface BrowserConfigOptions {
1714
1407
  /**
1715
- * Inject new test projects into the workspace.
1716
- * @param config Glob, config path or a custom config options.
1717
- * @returns An array of new test projects. Can be empty if the name was filtered out.
1408
+ * if running tests in the browser should be the default
1409
+ *
1410
+ * @default false
1718
1411
  */
1719
- private injectTestProject;
1412
+ enabled?: boolean;
1720
1413
  /**
1721
- * Provide a value to the test context. This value will be available to all tests with `inject`.
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
1722
1448
  */
1723
- provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1449
+ isolate?: boolean;
1724
1450
  /**
1725
- * Get global provided context.
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"
1726
1455
  */
1727
- getProvidedContext(): ProvidedContext;
1456
+ fileParallelism?: boolean;
1728
1457
  /**
1729
- * Return project that has the root (or "global") config.
1458
+ * Show Vitest UI
1459
+ *
1460
+ * @default !process.env.CI
1730
1461
  */
1731
- getRootProject(): TestProject;
1732
- getProjectByName(name: string): TestProject;
1462
+ ui?: boolean;
1733
1463
  /**
1734
- * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
1735
- * @param moduleId The ID of the module in Vite module graph
1464
+ * Default viewport size
1736
1465
  */
1737
- import<T>(moduleId: string): Promise<T>;
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
+ };
1738
1478
  /**
1739
- * Creates a coverage provider if `coverage` is enabled in the config.
1479
+ * Locator options
1740
1480
  */
1741
- createCoverageProvider(): Promise<CoverageProvider | null>;
1742
- private resolveProjects;
1481
+ locators?: {
1482
+ /**
1483
+ * Attribute used to locate elements by test id
1484
+ * @default 'data-testid'
1485
+ */
1486
+ testIdAttribute?: string;
1487
+ };
1743
1488
  /**
1744
- * Glob test files in every project and create a TestSpecification for each file and pool.
1745
- * @param filters String filters to match the test files.
1489
+ * Generate traces that can be viewed on https://trace.playwright.dev/
1490
+ *
1491
+ * This option is supported only by **playwright** provider.
1746
1492
  */
1747
- globTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1748
- private initCoverageProvider;
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
+ };
1749
1513
  /**
1750
- * Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
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__
1751
1518
  */
1752
- mergeReports(directory?: string): Promise<TestRunResult>;
1519
+ screenshotDirectory?: string;
1753
1520
  /**
1754
- * Returns the seed, if tests are running in a random order.
1521
+ * Should Vitest take screenshots if the test fails
1522
+ * @default !browser.ui
1755
1523
  */
1756
- getSeed(): number | null;
1757
- collect(filters?: string[]): Promise<TestRunResult>;
1524
+ screenshotFailures?: boolean;
1758
1525
  /**
1759
- * Returns the list of test files that match the config and filters.
1760
- * @param filters String filters to match the test files
1526
+ * Path to the index.html file that will be used to run tests.
1761
1527
  */
1762
- getRelevantTestSpecifications(filters?: string[]): Promise<TestSpecification[]>;
1528
+ testerHtmlPath?: string;
1763
1529
  /**
1764
- * Initialize reporters, the coverage provider, and run tests.
1765
- * This method can throw an error:
1766
- * - `FilesNotFoundError` if no tests are found
1767
- * - `GitNotFoundError` if `--related` flag is used, but git repository is not initialized
1768
- * - `Error` from the user reporters
1769
- * @param filters String filters to match the test files
1530
+ * Scripts injected into the main window.
1770
1531
  */
1771
- start(filters?: string[]): Promise<TestRunResult>;
1532
+ orchestratorScripts?: BrowserScript[];
1772
1533
  /**
1773
- * Initialize reporters and the coverage provider. This method doesn't run any tests.
1774
- * 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}
1775
1537
  */
1776
- init(): Promise<void>;
1538
+ commands?: Record<string, BrowserCommand<any>>;
1777
1539
  /**
1778
- * If there is a test run happening, returns a promise that will
1779
- * resolve when the test run is finished.
1540
+ * Timeout for connecting to the browser
1541
+ * @default 30000
1780
1542
  */
1781
- 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
+ };
1782
1555
  /**
1783
- * 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.
1784
1557
  *
1785
- * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
1786
- * @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
1787
1562
  */
1788
- 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 {
1789
1608
  /**
1790
- * 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`
1791
1613
  */
1792
- clearSpecificationsCache(moduleId?: string): void;
1614
+ id?: string;
1793
1615
  /**
1794
- * Run tests for the given test specifications. This does not trigger `onWatcher*` events.
1795
- * @param specifications A list of specifications to run.
1796
- * @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.
1797
1619
  */
1798
- runTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1620
+ content?: string;
1799
1621
  /**
1800
- * Rerun files and trigger `onWatcherRerun`, `onWatcherStart` and `onTestsRerun` events.
1801
- * @param specifications A list of specifications to run.
1802
- * @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.
1803
1623
  */
1804
- rerunTestSpecifications(specifications: TestSpecification[], allTestsRun?: boolean): Promise<TestRunResult>;
1805
- private runFiles;
1806
- experimental_parseSpecifications(specifications: TestSpecification[], options?: {
1807
- /** @default os.availableParallelism() */
1808
- concurrency?: number;
1809
- }): Promise<TestModule[]>;
1810
- experimental_parseSpecification(specification: TestSpecification): Promise<TestModule>;
1624
+ src?: string;
1811
1625
  /**
1812
- * Collect tests in specified modules. Vitest will run the files to collect tests.
1813
- * @param specifications A list of specifications to run.
1626
+ * If the script should be loaded asynchronously.
1814
1627
  */
1815
- collectTests(specifications: TestSpecification[]): Promise<TestRunResult>;
1628
+ async?: boolean;
1816
1629
  /**
1817
- * Gracefully cancel the current test run. Vitest will wait until all running tests are finished before cancelling.
1630
+ * Script type.
1631
+ * @default 'module'
1818
1632
  */
1819
- cancelCurrentRun(reason: CancelReason): Promise<void>;
1820
- 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: {
1821
1659
  /**
1822
- * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
1823
- * @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"
1824
1678
  */
1825
- updateSnapshot(files?: string[]): Promise<TestRunResult>;
1679
+ arg: string;
1826
1680
  /**
1827
- * Enable the mode that allows updating snapshots when running tests.
1828
- * This method doesn't run any tests.
1681
+ * Screenshot extension, with leading dot.
1829
1682
  *
1830
- * Every test that runs after this method is called will update snapshots.
1831
- * 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.
1832
1685
  */
1833
- enableSnapshotUpdate(): void;
1686
+ ext: string;
1834
1687
  /**
1835
- * Disable the mode that allows updating snapshots when running tests.
1688
+ * The instance's browser name.
1836
1689
  */
1837
- resetSnapshotUpdate(): void;
1690
+ browserName: string;
1838
1691
  /**
1839
- * Set the global test name pattern to a regexp.
1840
- * This method doesn't run any tests.
1692
+ * The value of {@linkcode process.platform}.
1841
1693
  */
1842
- setGlobalTestNamePattern(pattern: string | RegExp): void;
1694
+ platform: NodeJS.Platform;
1843
1695
  /**
1844
- * 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.
1845
1699
  */
1846
- getGlobalTestNamePattern(): RegExp | undefined;
1700
+ screenshotDirectory: string;
1847
1701
  /**
1848
- * 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}.
1849
1704
  */
1850
- resetGlobalTestNamePattern(): void;
1851
- private _rerunTimer;
1852
- private scheduleRerun;
1705
+ root: string;
1853
1706
  /**
1854
- * 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}.
1855
1709
  */
1856
- invalidateFile(filepath: string): void;
1857
- private reportCoverage;
1710
+ testFileDirectory: string;
1858
1711
  /**
1859
- * Closes all projects and their associated resources.
1860
- * This can only be called once; the closing promise is cached until the server restarts.
1712
+ * The test's filename.
1861
1713
  */
1862
- close(): Promise<void>;
1714
+ testFileName: string;
1863
1715
  /**
1864
- * Closes all projects and exit the process
1865
- * @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.
1866
1718
  */
1867
- exit(force?: boolean): Promise<void>;
1719
+ testName: string;
1868
1720
  /**
1869
- * 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.
1870
1724
  */
1871
- shouldKeepServer(): boolean;
1725
+ attachmentsDir: string;
1726
+ }) => string;
1727
+ interface ToMatchScreenshotOptions {
1872
1728
  /**
1873
- * 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}`
1874
1732
  */
1875
- onServerRestart(fn: OnServerRestartHandler): void;
1733
+ resolveScreenshotPath?: ToMatchScreenshotResolvePath;
1876
1734
  /**
1877
- * 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}`
1878
1738
  */
1879
- onCancel(fn: (reason: CancelReason) => Awaitable<void>): void;
1739
+ resolveDiffPath?: ToMatchScreenshotResolvePath;
1740
+ }
1741
+ interface ToMatchScreenshotComparators {}
1742
+
1743
+ declare class TestProject {
1744
+ options?: InitializeProjectOptions | undefined;
1880
1745
  /**
1881
- * Register a handler that will be called when the server is closed.
1746
+ * The global Vitest instance.
1882
1747
  */
1883
- onClose(fn: () => Awaitable<void>): void;
1748
+ readonly vitest: Vitest;
1884
1749
  /**
1885
- * 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`.
1886
1751
  */
1887
- onTestsRerun(fn: OnTestsRerunHandler): void;
1752
+ readonly globalConfig: ResolvedConfig;
1888
1753
  /**
1889
- * Register a handler that will be called when a file is changed.
1890
- * This callback should return `true` of `false` indicating whether the test file needs to be rerun.
1891
- * @example
1892
- * const testsToRun = [resolve('./test.spec.ts')]
1893
- * 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.
1894
1755
  */
1895
- onFilterWatchedSpecification(fn: (specification: TestSpecification) => boolean): void;
1756
+ browser?: ProjectBrowser;
1896
1757
  /**
1897
- * 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.
1898
1759
  */
1899
- matchesProjectFilter(name: string): boolean;
1900
- }
1901
- type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1902
- type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
1903
-
1904
- type TestRunEndReason = "passed" | "interrupted" | "failed";
1905
- interface Reporter {
1906
- 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);
1907
1768
  /**
1908
- * Called when the project initiated the browser instance.
1909
- * project.browser will always be defined.
1910
- * @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.
1911
1772
  */
1912
- onBrowserInit?: (project: TestProject) => Awaitable<void>;
1913
- onTestRemoved?: (trigger?: string) => Awaitable<void>;
1914
- onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
1915
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
1916
- onServerRestart?: (reason?: string) => Awaitable<void>;
1917
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
1918
- onProcessTimeout?: () => Awaitable<void>;
1773
+ get hash(): string;
1919
1774
  /**
1920
- * 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`.
1921
1776
  */
1922
- onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable<void>;
1777
+ provide: <T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]) => void;
1923
1778
  /**
1924
- * Called when the test run is finished.
1779
+ * Get the provided context. The project context is merged with the global context.
1925
1780
  */
1926
- onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable<void>;
1781
+ getProvidedContext(): ProvidedContext;
1927
1782
  /**
1928
- * 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
1929
1785
  */
1930
- onTestModuleQueued?: (testModule: TestModule) => Awaitable<void>;
1786
+ createSpecification(moduleId: string, locations?: number[] | undefined, pool?: string): TestSpecification;
1787
+ toJSON(): SerializedTestProject;
1931
1788
  /**
1932
- * 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.
1933
1790
  */
1934
- onTestModuleCollected?: (testModule: TestModule) => Awaitable<void>;
1791
+ get vite(): ViteDevServer;
1935
1792
  /**
1936
- * Called when starting to run tests of the test file
1793
+ * Resolved project configuration.
1937
1794
  */
1938
- onTestModuleStart?: (testModule: TestModule) => Awaitable<void>;
1795
+ get config(): ResolvedConfig;
1939
1796
  /**
1940
- * Called when all tests of the test file have finished running.
1797
+ * The name of the project or an empty string if not set.
1941
1798
  */
1942
- onTestModuleEnd?: (testModule: TestModule) => Awaitable<void>;
1799
+ get name(): string;
1943
1800
  /**
1944
- * Called when test case is ready to run.
1945
- * Called before the `beforeEach` hooks for the test are run.
1801
+ * The color used when reporting tasks of this project.
1946
1802
  */
1947
- onTestCaseReady?: (testCase: TestCase) => Awaitable<void>;
1803
+ get color(): ProjectName["color"];
1948
1804
  /**
1949
- * Called after the test and its hooks are finished running.
1950
- * The `result()` cannot be `pending`.
1805
+ * Serialized project configuration. This is the config that tests receive.
1951
1806
  */
1952
- onTestCaseResult?: (testCase: TestCase) => Awaitable<void>;
1807
+ get serializedConfig(): SerializedConfig;
1953
1808
  /**
1954
- * 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.
1955
1810
  */
1956
- onTestCaseAnnotate?: (testCase: TestCase, annotation: TestAnnotation) => Awaitable<void>;
1811
+ isRootProject(): boolean;
1812
+ onTestsRerun(cb: OnTestsRerunHandler): void;
1957
1813
  /**
1958
- * Called when test suite is ready to run.
1959
- * 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.
1960
1816
  */
1961
- onTestSuiteReady?: (testSuite: TestSuite) => Awaitable<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;
1962
1830
  /**
1963
- * Called after the test suite and its hooks are finished running.
1964
- * 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`.
1965
1832
  */
1966
- onTestSuiteResult?: (testSuite: TestSuite) => Awaitable<void>;
1833
+ matchesTestGlob(moduleId: string, source?: () => string): boolean;
1834
+ private isInSourceTestCode;
1835
+ private filterFiles;
1836
+ private _parentBrowser?;
1967
1837
  /**
1968
- * 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.
1969
1840
  */
1970
- onHookStart?: (hook: ReportedHookContext) => Awaitable<void>;
1841
+ close(): Promise<void>;
1971
1842
  /**
1972
- * 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
1973
1845
  */
1974
- onHookEnd?: (hook: ReportedHookContext) => Awaitable<void>;
1975
- onCoverage?: (coverage: unknown) => Awaitable<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;
1976
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: Record<string, string>;
1872
+ }
1873
+ interface PoolWorker {
1874
+ readonly name: string;
1875
+ readonly execArgv: string[];
1876
+ readonly env: Record<string, string>;
1877
+ readonly reportMemory?: boolean;
1878
+ readonly cacheFs?: boolean;
1879
+ on: (event: string, callback: (arg: any) => void) => void;
1880
+ off: (event: string, callback: (arg: any) => void) => void;
1881
+ send: (message: WorkerRequest) => void;
1882
+ deserialize: (data: unknown) => unknown;
1883
+ start: () => Promise<void>;
1884
+ stop: () => Promise<void>;
1885
+ }
1886
+ interface PoolTask {
1887
+ worker: "forks" | "threads" | "vmForks" | "vmThreads" | (string & {});
1888
+ project: TestProject;
1889
+ isolate: boolean;
1890
+ env: Record<string, string>;
1891
+ execArgv: string[];
1892
+ context: ContextRPC;
1893
+ memoryLimit: number | null;
1894
+ }
1895
+ type WorkerRequest = {
1896
+ __vitest_worker_request__: true;
1897
+ } & ({
1898
+ type: "start";
1899
+ options: {
1900
+ reportMemory: boolean;
1901
+ };
1902
+ } | {
1903
+ type: "stop";
1904
+ } | {
1905
+ type: "run";
1906
+ context: ContextRPC;
1907
+ poolId: number;
1908
+ } | {
1909
+ type: "collect";
1910
+ context: ContextRPC;
1911
+ poolId: number;
1912
+ } | {
1913
+ type: "cancel";
1914
+ });
1915
+ type WorkerResponse = {
1916
+ __vitest_worker_response__: true;
1917
+ } & ({
1918
+ type: "started";
1919
+ } | {
1920
+ type: "stopped";
1921
+ error?: unknown;
1922
+ } | {
1923
+ type: "testfileFinished";
1924
+ usedMemory?: number;
1925
+ error?: unknown;
1926
+ });
1977
1927
 
1978
1928
  interface BaseOptions {
1979
1929
  isTTY?: boolean;
@@ -2331,7 +2281,6 @@ interface BenchmarkUserOptions {
2331
2281
 
2332
2282
  type BuiltinEnvironment = "node" | "jsdom" | "happy-dom" | "edge-runtime";
2333
2283
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
2334
-
2335
2284
  type CSSModuleScopeStrategy = "stable" | "scoped" | "non-scoped";
2336
2285
  type ApiConfig = Pick<ServerOptions, "port" | "strictPort" | "host" | "middlewareMode">;
2337
2286
  interface EnvironmentOptions {
@@ -2468,6 +2417,8 @@ interface ResolveSnapshotPathHandlerContext {
2468
2417
  config: SerializedConfig;
2469
2418
  }
2470
2419
  type ResolveSnapshotPathHandler = (testPath: string, snapExtension: string, context: ResolveSnapshotPathHandlerContext) => string;
2420
+ type BuiltinPool = "browser" | "threads" | "forks" | "vmThreads" | "vmForks" | "typescript";
2421
+ type Pool = BuiltinPool | (string & {});
2471
2422
  interface InlineConfig {
2472
2423
  /**
2473
2424
  * Name of the project. Will be used to display in the reporter.
@@ -2550,25 +2501,38 @@ interface InlineConfig {
2550
2501
  /**
2551
2502
  * Run tests in an isolated environment. This option has no effect on vmThreads pool.
2552
2503
  *
2553
- * Disabling this option might improve performance if your code doesn't rely on side effects.
2504
+ * Disabling this option improves performance if your code doesn't rely on side effects.
2554
2505
  *
2555
2506
  * @default true
2556
2507
  */
2557
2508
  isolate?: boolean;
2558
2509
  /**
2559
- * Pool used to run tests in.
2510
+ * Pass additional arguments to `node` process when spawning the worker.
2560
2511
  *
2561
- * Supports 'threads', 'forks', 'vmThreads'
2512
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
2562
2513
  *
2563
- * @default 'forks'
2514
+ * Set to `process.execArgv` to pass all arguments of the current process.
2515
+ *
2516
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
2517
+ *
2518
+ * @default [] // no execution arguments are passed
2519
+ */
2520
+ execArgv?: string[];
2521
+ /**
2522
+ * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
2523
+ * If you see memory leaks, try to tinker this value.
2564
2524
  */
2565
- pool?: Exclude<Pool, "browser">;
2525
+ vmMemoryLimit?: string | number;
2566
2526
  /**
2567
- * Pool options
2527
+ * Pool used to run tests in.
2528
+ *
2529
+ * Supports 'threads', 'forks', 'vmThreads', 'vmForks'
2530
+ *
2531
+ * @default 'forks'
2568
2532
  */
2569
- poolOptions?: PoolOptions;
2533
+ pool?: Exclude<Pool, "browser"> | PoolRunnerInitializer;
2570
2534
  /**
2571
- * Maximum number or percentage of workers to run tests in. `poolOptions.{threads,vmThreads}.maxThreads`/`poolOptions.forks.maxForks` has higher priority.
2535
+ * Maximum number or percentage of workers to run tests in.
2572
2536
  */
2573
2537
  maxWorkers?: number | string;
2574
2538
  /**
@@ -2854,14 +2818,14 @@ interface InlineConfig {
2854
2818
  * Debug tests by opening `node:inspector` in worker / child process.
2855
2819
  * Provides similar experience as `--inspect` Node CLI argument.
2856
2820
  *
2857
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2821
+ * Requires `fileParallelism: false`.
2858
2822
  */
2859
2823
  inspect?: boolean | string;
2860
2824
  /**
2861
2825
  * Debug tests by opening `node:inspector` in worker / child process and wait for debugger to connect.
2862
2826
  * Provides similar experience as `--inspect-brk` Node CLI argument.
2863
2827
  *
2864
- * Requires `poolOptions.threads.singleThread: true` OR `poolOptions.forks.singleFork: true`.
2828
+ * Requires `fileParallelism: false`.
2865
2829
  */
2866
2830
  inspectBrk?: boolean | string;
2867
2831
  /**
@@ -3095,7 +3059,7 @@ interface UserConfig extends InlineConfig {
3095
3059
  type OnUnhandledErrorCallback = (error: (TestError | Error) & {
3096
3060
  type: string;
3097
3061
  }) => boolean | void;
3098
- 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"> {
3062
+ 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"> {
3099
3063
  mode: VitestRunMode;
3100
3064
  name: ProjectName["label"];
3101
3065
  color?: ProjectName["color"];
@@ -3112,7 +3076,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3112
3076
  snapshotOptions: SnapshotStateOptions;
3113
3077
  browser: ResolvedBrowserOptions;
3114
3078
  pool: Pool;
3115
- poolOptions?: ResolvedPoolOptions;
3079
+ poolRunner?: PoolRunnerInitializer;
3116
3080
  reporters: (InlineReporter | ReporterWithOptions)[];
3117
3081
  defines: Record<string, any>;
3118
3082
  api: ApiConfig & {
@@ -3145,9 +3109,10 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3145
3109
  };
3146
3110
  runner?: string;
3147
3111
  maxWorkers: number;
3112
+ vmMemoryLimit?: UserConfig["vmMemoryLimit"];
3148
3113
  dumpDir?: string;
3149
3114
  }
3150
- 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";
3115
+ 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";
3151
3116
  interface ServerDepsOptions {
3152
3117
  /**
3153
3118
  * Externalize means that Vite will bpass the package to native Node.
@@ -3172,15 +3137,11 @@ interface ServerDepsOptions {
3172
3137
  */
3173
3138
  fallbackCJS?: boolean;
3174
3139
  }
3175
- type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps" | "poolOptions"> & {
3140
+ type ProjectConfig = Omit<InlineConfig, NonProjectOptions | "sequencer" | "deps"> & {
3176
3141
  mode?: string;
3177
3142
  sequencer?: Omit<SequenceOptions, "sequencer" | "seed">;
3178
3143
  deps?: Omit<DepsOptions, "moduleDirectories">;
3179
- poolOptions?: {
3180
- threads?: Pick<NonNullable<PoolOptions["threads"]>, "singleThread" | "isolate">;
3181
- vmThreads?: Pick<NonNullable<PoolOptions["vmThreads"]>, "singleThread">;
3182
- forks?: Pick<NonNullable<PoolOptions["forks"]>, "singleFork" | "isolate">;
3183
- };
3144
+ fileParallelism?: boolean;
3184
3145
  };
3185
3146
  type ResolvedProjectConfig = Omit<ResolvedConfig, Exclude<NonProjectOptions, "coverage" | "watch">>;
3186
3147
  interface UserWorkspaceConfig extends UserConfig$1 {
@@ -3198,5 +3159,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3198
3159
  });
3199
3160
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3200
3161
 
3201
- export { TestSuite as B, CoverageMap as C, experimental_getRunnerTask as E, Logger as L, TestProject as T, Vitest as V, BenchmarkReportsMap as aA, DefaultReporter as aB, DotReporter as aC, GithubActionsReporter as aD, HangingProcessReporter as aE, JsonReporter as aF, JUnitReporter as aG, ReportersMap as aH, TapFlatReporter as aI, TapReporter as aJ, VerboseBenchmarkReporter as aK, VerboseReporter as aL, BaseReporter as aM, BenchmarkReporter as az, TestSpecification as k, VitestPackageInstaller as n, TestCase as q, TestCollection as r, TestModule as t };
3202
- export type { BrowserOrchestrator 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, _BrowserNames as _, TestProjectConfiguration as a, BrowserProvider as a0, BrowserProviderOption as a1, BrowserScript as a2, BrowserServerFactory as a3, BrowserServerOptions as a4, BrowserServerState as a5, BrowserServerStateSession as a6, CDPSession as a7, ParentProjectBrowser as a8, ProjectBrowser as a9, BenchmarkBuiltinReporters as aN, BuiltinReporterOptions as aO, BuiltinReporters as aP, JsonAssertionResult as aQ, JsonTestResult as aR, JsonTestResults as aS, ResolvedBrowserOptions as aa, ToMatchScreenshotComparators as ab, ToMatchScreenshotOptions as ac, BuiltinEnvironment as ad, CSSModuleScopeStrategy as ae, DepsOptimizationOptions as af, EnvironmentOptions as ag, PoolOptions as ah, ProjectConfig as ai, ResolvedProjectConfig as aj, ResolveSnapshotPathHandler as ak, ResolveSnapshotPathHandlerContext as al, TypecheckConfig as am, VitestEnvironment as an, BaseCoverageOptions as ao, CoverageIstanbulOptions as ap, CoverageOptions as aq, CoverageProvider as ar, CoverageProviderModule as as, CoverageReporter as at, CustomProviderOptions as au, TestRunResult as av, ReportedHookContext as aw, Reporter as ax, TestRunEndReason as ay, 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 };
3162
+ 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 };
3163
+ 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 };