vitest 3.0.0-beta.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/browser.d.ts +2 -2
  2. package/dist/chunks/{base.BJ8KO-VX.js → base.CUDzyU2J.js} +1 -1
  3. package/dist/chunks/{cac.BAYqQ2aM.js → cac.DZC9WjGM.js} +6 -6
  4. package/dist/chunks/{cli-api.Dhl34Trr.js → cli-api.CmJw5Cd_.js} +901 -65
  5. package/dist/chunks/{creator.Ot9GlSGw.js → creator.DztqrnyH.js} +1 -1
  6. package/dist/chunks/global.CnI8_G5V.d.ts +133 -0
  7. package/dist/chunks/{index.B2M9nD1V.js → index.CUcwvygK.js} +4 -4
  8. package/dist/chunks/{index.DQboAxJm.js → index.D9C26wCk.js} +1 -0
  9. package/dist/chunks/{index.CAueP3cK.js → index.TKSL1HjN.js} +188 -933
  10. package/dist/chunks/{reporters.Dcdq51WE.d.ts → reporters.Y8BYiXBN.d.ts} +340 -239
  11. package/dist/chunks/{resolveConfig.kZFMjKCQ.js → resolveConfig.CSLLD33d.js} +137 -52
  12. package/dist/chunks/{rpc.C3q9uwRX.js → rpc.TVf73xOu.js} +0 -1
  13. package/dist/chunks/{runBaseTests.URiUrnWK.js → runBaseTests.C0T_TQwH.js} +2 -2
  14. package/dist/chunks/{RandomSequencer.DB__To1b.js → typechecker.BJMkWMXo.js} +53 -106
  15. package/dist/chunks/{utils.yHKcm4dz.js → utils.DJWL04yX.js} +1 -1
  16. package/dist/chunks/{vite.DzluO1Kj.d.ts → vite.CQ0dHgkN.d.ts} +1 -1
  17. package/dist/chunks/{worker.BIVMnzXw.d.ts → worker.B1y96qmv.d.ts} +1 -1
  18. package/dist/chunks/{worker.Hz_LAzfd.d.ts → worker.CIpff8Eg.d.ts} +2 -4
  19. package/dist/cli.js +1 -1
  20. package/dist/config.d.ts +3 -3
  21. package/dist/coverage.d.ts +1 -1
  22. package/dist/coverage.js +5 -4
  23. package/dist/execute.d.ts +1 -1
  24. package/dist/index.d.ts +17 -118
  25. package/dist/node.d.ts +11 -8
  26. package/dist/node.js +25 -23
  27. package/dist/reporters.d.ts +1 -1
  28. package/dist/reporters.js +4 -6
  29. package/dist/runners.d.ts +1 -0
  30. package/dist/runners.js +7 -7
  31. package/dist/worker.js +1 -1
  32. package/dist/workers/forks.js +1 -1
  33. package/dist/workers/runVmTests.js +2 -2
  34. package/dist/workers/threads.js +1 -1
  35. package/dist/workers.d.ts +2 -2
  36. package/dist/workers.js +2 -2
  37. package/package.json +13 -13
  38. package/dist/chunks/types.BOjykUpq.d.ts +0 -27
@@ -1,7 +1,7 @@
1
1
  import * as _vitest_runner from '@vitest/runner';
2
2
  import { TaskMeta, Suite, File, TaskResultPack, Task, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
3
3
  import { b as Awaitable, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, P as ProvidedContext } from './environment.d8YfPkTm.js';
4
- import { TestError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
4
+ import { TestError, SerializedError, ParsedStack, Arrayable, ErrorWithDiff, Awaitable as Awaitable$1 } from '@vitest/utils';
5
5
  import { Writable } from 'node:stream';
6
6
  import { TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv, ViteDevServer, ModuleNode } from 'vite';
7
7
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
@@ -75,13 +75,13 @@ declare class TestCase extends ReportedTaskImplementation {
75
75
  */
76
76
  get fullName(): string;
77
77
  /**
78
- * Test results. Will be `undefined` if test is skipped, not finished yet or was just collected.
78
+ * Test results.
79
+ * - **pending**: Test was collected, but didn't finish running yet.
80
+ * - **passed**: Test passed successfully
81
+ * - **failed**: Test failed to execute
82
+ * - **skipped**: Test was skipped during collection or dynamically with `ctx.skip()`.
79
83
  */
80
- result(): TestResult | undefined;
81
- /**
82
- * Checks if the test was skipped during collection or dynamically with `ctx.skip()`.
83
- */
84
- skipped(): boolean;
84
+ result(): TestResult;
85
85
  /**
86
86
  * Custom metadata that was attached to the test during its execution.
87
87
  */
@@ -110,11 +110,11 @@ declare class TestCollection {
110
110
  /**
111
111
  * Filters all tests that are part of this collection and its children.
112
112
  */
113
- allTests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
113
+ allTests(state?: TestState): Generator<TestCase, undefined, void>;
114
114
  /**
115
115
  * Filters only the tests that are part of this collection.
116
116
  */
117
- tests(state?: TestResult['state'] | 'running'): Generator<TestCase, undefined, void>;
117
+ tests(state?: TestState): Generator<TestCase, undefined, void>;
118
118
  /**
119
119
  * Filters only the suites that are part of this collection.
120
120
  */
@@ -126,19 +126,22 @@ declare class TestCollection {
126
126
  [Symbol.iterator](): Generator<TestSuite | TestCase, undefined, void>;
127
127
  }
128
128
 
129
+ type ReportedHookContext = {
130
+ readonly name: 'beforeAll' | 'afterAll';
131
+ readonly entity: TestSuite | TestModule;
132
+ } | {
133
+ readonly name: 'beforeEach' | 'afterEach';
134
+ readonly entity: TestCase;
135
+ };
129
136
  declare abstract class SuiteImplementation extends ReportedTaskImplementation {
130
137
  /**
131
138
  * Collection of suites and tests that are part of this suite.
132
139
  */
133
140
  readonly children: TestCollection;
134
- /**
135
- * Checks if the suite was skipped during collection.
136
- */
137
- skipped(): boolean;
138
141
  /**
139
142
  * Errors that happened outside of the test run during collection, like syntax errors.
140
143
  */
141
- errors(): TestError[];
144
+ errors(): SerializedError[];
142
145
  }
143
146
  declare class TestSuite extends SuiteImplementation {
144
147
  #private;
@@ -164,6 +167,10 @@ declare class TestSuite extends SuiteImplementation {
164
167
  * This will also return `false` if suite failed during collection.
165
168
  */
166
169
  ok: () => boolean;
170
+ /**
171
+ * Checks the running state of the suite.
172
+ */
173
+ state(): TestSuiteState;
167
174
  /**
168
175
  * Full name of the suite including all parent suites separated with `>`.
169
176
  */
@@ -174,19 +181,19 @@ declare class TestModule extends SuiteImplementation {
174
181
  readonly type = "module";
175
182
  /**
176
183
  * This is usually an absolute UNIX file path.
177
- * It can be a virtual id if the file is not on the disk.
178
- * This value corresponds to Vite's `ModuleGraph` id.
184
+ * It can be a virtual ID if the file is not on the disk.
185
+ * This value corresponds to the ID in the Vite's module graph.
179
186
  */
180
187
  readonly moduleId: string;
188
+ /**
189
+ * Checks the running state of the test file.
190
+ */
191
+ state(): TestModuleState;
181
192
  /**
182
193
  * Checks if the module has any failed tests.
183
194
  * This will also return `false` if module failed during collection.
184
195
  */
185
196
  ok: () => boolean;
186
- /**
187
- * Checks if the module was skipped and didn't run.
188
- */
189
- skipped: () => boolean;
190
197
  /**
191
198
  * Useful information about the module like duration, memory usage, etc.
192
199
  * If the module was not executed yet, all diagnostic values will return `0`.
@@ -194,114 +201,319 @@ declare class TestModule extends SuiteImplementation {
194
201
  diagnostic(): ModuleDiagnostic;
195
202
  }
196
203
  interface TaskOptions {
197
- each: boolean | undefined;
198
- concurrent: boolean | undefined;
199
- shuffle: boolean | undefined;
200
- retry: number | undefined;
201
- repeats: number | undefined;
202
- mode: 'run' | 'only' | 'skip' | 'todo' | 'queued';
203
- }
204
- type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped;
204
+ readonly each: boolean | undefined;
205
+ readonly fails: boolean | undefined;
206
+ readonly concurrent: boolean | undefined;
207
+ readonly shuffle: boolean | undefined;
208
+ readonly retry: number | undefined;
209
+ readonly repeats: number | undefined;
210
+ readonly mode: 'run' | 'only' | 'skip' | 'todo';
211
+ }
212
+ type TestSuiteState = 'skipped' | 'pending' | 'failed' | 'passed';
213
+ type TestModuleState = TestSuiteState | 'queued';
214
+ type TestState = TestResult['state'];
215
+ type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped | TestResultPending;
216
+ interface TestResultPending {
217
+ /**
218
+ * The test was collected, but didn't finish running yet.
219
+ */
220
+ readonly state: 'pending';
221
+ /**
222
+ * Pending tests have no errors.
223
+ */
224
+ readonly errors: undefined;
225
+ }
205
226
  interface TestResultPassed {
206
227
  /**
207
228
  * The test passed successfully.
208
229
  */
209
- state: 'passed';
230
+ readonly state: 'passed';
210
231
  /**
211
232
  * Errors that were thrown during the test execution.
212
233
  *
213
234
  * **Note**: If test was retried successfully, errors will still be reported.
214
235
  */
215
- errors: TestError[] | undefined;
236
+ readonly errors: ReadonlyArray<TestError> | undefined;
216
237
  }
217
238
  interface TestResultFailed {
218
239
  /**
219
240
  * The test failed to execute.
220
241
  */
221
- state: 'failed';
242
+ readonly state: 'failed';
222
243
  /**
223
244
  * Errors that were thrown during the test execution.
224
245
  */
225
- errors: TestError[];
246
+ readonly errors: ReadonlyArray<TestError>;
226
247
  }
227
248
  interface TestResultSkipped {
228
249
  /**
229
250
  * The test was skipped with `only` (on another test), `skip` or `todo` flag.
230
251
  * You can see which one was used in the `options.mode` option.
231
252
  */
232
- state: 'skipped';
253
+ readonly state: 'skipped';
233
254
  /**
234
255
  * Skipped tests have no errors.
235
256
  */
236
- errors: undefined;
257
+ readonly errors: undefined;
237
258
  /**
238
259
  * A custom note passed down to `ctx.skip(note)`.
239
260
  */
240
- note: string | undefined;
261
+ readonly note: string | undefined;
241
262
  }
242
263
  interface TestDiagnostic {
243
264
  /**
244
265
  * If the duration of the test is above `slowTestThreshold`.
245
266
  */
246
- slow: boolean;
267
+ readonly slow: boolean;
247
268
  /**
248
269
  * The amount of memory used by the test in bytes.
249
270
  * This value is only available if the test was executed with `logHeapUsage` flag.
250
271
  */
251
- heap: number | undefined;
272
+ readonly heap: number | undefined;
252
273
  /**
253
274
  * The time it takes to execute the test in ms.
254
275
  */
255
- duration: number;
276
+ readonly duration: number;
256
277
  /**
257
278
  * The time in ms when the test started.
258
279
  */
259
- startTime: number;
280
+ readonly startTime: number;
260
281
  /**
261
282
  * The amount of times the test was retried.
262
283
  */
263
- retryCount: number;
284
+ readonly retryCount: number;
264
285
  /**
265
286
  * The amount of times the test was repeated as configured by `repeats` option.
266
287
  * This value can be lower if the test failed during the repeat and no `retry` is configured.
267
288
  */
268
- repeatCount: number;
289
+ readonly repeatCount: number;
269
290
  /**
270
291
  * If test passed on a second retry.
271
292
  */
272
- flaky: boolean;
293
+ readonly flaky: boolean;
273
294
  }
274
295
  interface ModuleDiagnostic {
275
296
  /**
276
297
  * The time it takes to import and initiate an environment.
277
298
  */
278
- environmentSetupDuration: number;
299
+ readonly environmentSetupDuration: number;
279
300
  /**
280
301
  * The time it takes Vitest to setup test harness (runner, mocks, etc.).
281
302
  */
282
- prepareDuration: number;
303
+ readonly prepareDuration: number;
283
304
  /**
284
305
  * The time it takes to import the test module.
285
306
  * This includes importing everything in the module and executing suite callbacks.
286
307
  */
287
- collectDuration: number;
308
+ readonly collectDuration: number;
288
309
  /**
289
310
  * The time it takes to import the setup module.
290
311
  */
291
- setupDuration: number;
312
+ readonly setupDuration: number;
292
313
  /**
293
314
  * Accumulated duration of all tests and hooks in the module.
294
315
  */
295
- duration: number;
316
+ readonly duration: number;
317
+ }
318
+
319
+ type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
320
+ type Pool = BuiltinPool | (string & {});
321
+ interface PoolOptions extends Record<string, unknown> {
322
+ /**
323
+ * Run tests in `node:worker_threads`.
324
+ *
325
+ * Test isolation (when enabled) is done by spawning a new thread for each test file.
326
+ *
327
+ * This pool is used by default.
328
+ */
329
+ threads?: ThreadsOptions & WorkerContextOptions;
330
+ /**
331
+ * Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
332
+ *
333
+ * Test isolation (when enabled) is done by spawning a new child process for each test file.
334
+ */
335
+ forks?: ForksOptions & WorkerContextOptions;
336
+ /**
337
+ * Run tests in isolated `node:vm`.
338
+ * Test files are run parallel using `node:worker_threads`.
339
+ *
340
+ * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
341
+ */
342
+ vmThreads?: ThreadsOptions & VmOptions;
343
+ /**
344
+ * Run tests in isolated `node:vm`.
345
+ *
346
+ * Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
347
+ *
348
+ * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
349
+ */
350
+ vmForks?: ForksOptions & VmOptions;
351
+ }
352
+ interface ResolvedPoolOptions extends PoolOptions {
353
+ threads?: ResolvedThreadsOptions & WorkerContextOptions;
354
+ forks?: ResolvedForksOptions & WorkerContextOptions;
355
+ vmThreads?: ResolvedThreadsOptions & VmOptions;
356
+ vmForks?: ResolvedForksOptions & VmOptions;
357
+ }
358
+ interface ThreadsOptions {
359
+ /** Minimum amount of threads to use */
360
+ minThreads?: number | string;
361
+ /** Maximum amount of threads to use */
362
+ maxThreads?: number | string;
363
+ /**
364
+ * Run tests inside a single thread.
365
+ *
366
+ * @default false
367
+ */
368
+ singleThread?: boolean;
369
+ /**
370
+ * Use Atomics to synchronize threads
371
+ *
372
+ * This can improve performance in some cases, but might cause segfault in older Node versions.
373
+ *
374
+ * @default false
375
+ */
376
+ useAtomics?: boolean;
377
+ }
378
+ interface ResolvedThreadsOptions extends ThreadsOptions {
379
+ minThreads?: number;
380
+ maxThreads?: number;
381
+ }
382
+ interface ForksOptions {
383
+ /** Minimum amount of child processes to use */
384
+ minForks?: number | string;
385
+ /** Maximum amount of child processes to use */
386
+ maxForks?: number | string;
387
+ /**
388
+ * Run tests inside a single fork.
389
+ *
390
+ * @default false
391
+ */
392
+ singleFork?: boolean;
393
+ }
394
+ interface ResolvedForksOptions extends ForksOptions {
395
+ minForks?: number;
396
+ maxForks?: number;
397
+ }
398
+ interface WorkerContextOptions {
399
+ /**
400
+ * Isolate test environment by recycling `worker_threads` or `child_process` after each test
401
+ *
402
+ * @default true
403
+ */
404
+ isolate?: boolean;
405
+ /**
406
+ * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
407
+ *
408
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
409
+ *
410
+ * Set to `process.execArgv` to pass all arguments of the current process.
411
+ *
412
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
413
+ *
414
+ * @default [] // no execution arguments are passed
415
+ */
416
+ execArgv?: string[];
417
+ }
418
+ interface VmOptions {
419
+ /**
420
+ * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
421
+ * If you see memory leaks, try to tinker this value.
422
+ */
423
+ memoryLimit?: string | number;
424
+ /** Isolation is always enabled */
425
+ isolate?: true;
426
+ /**
427
+ * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
428
+ *
429
+ * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
430
+ *
431
+ * Set to `process.execArgv` to pass all arguments of the current process.
432
+ *
433
+ * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
434
+ *
435
+ * @default [] // no execution arguments are passed
436
+ */
437
+ execArgv?: string[];
438
+ }
439
+
440
+ declare class TestSpecification {
441
+ /**
442
+ * @deprecated use `project` instead
443
+ */
444
+ readonly 0: TestProject;
445
+ /**
446
+ * @deprecated use `moduleId` instead
447
+ */
448
+ readonly 1: string;
449
+ /**
450
+ * @deprecated use `pool` instead
451
+ */
452
+ readonly 2: {
453
+ pool: Pool;
454
+ };
455
+ /**
456
+ * The task ID associated with the test module.
457
+ */
458
+ readonly taskId: string;
459
+ /**
460
+ * The test project that the module belongs to.
461
+ */
462
+ readonly project: TestProject;
463
+ /**
464
+ * The ID of the module in the Vite module graph. It is usually an absolute file path.
465
+ */
466
+ readonly moduleId: string;
467
+ /**
468
+ * The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
469
+ * @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
470
+ */
471
+ readonly pool: Pool;
472
+ /**
473
+ * Line numbers of the test locations to run.
474
+ */
475
+ readonly testLines: number[] | undefined;
476
+ constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
477
+ /**
478
+ * Test module associated with the specification.
479
+ */
480
+ get testModule(): TestModule | undefined;
481
+ toJSON(): SerializedTestSpecification;
482
+ /**
483
+ * for backwards compatibility
484
+ * @deprecated
485
+ */
486
+ [Symbol.iterator](): Generator<string | TestProject, void, unknown>;
296
487
  }
297
488
 
489
+ type TestRunEndReason = 'passed' | 'interrupted' | 'failed';
298
490
  interface Reporter {
299
- onInit?: (ctx: Vitest) => void;
491
+ onInit?: (vitest: Vitest) => void;
492
+ /**
493
+ * Called when the project initiated the browser instance.
494
+ * project.browser will always be defined.
495
+ * @experimental
496
+ */
497
+ onBrowserInit?: (project: TestProject) => Awaitable<void>;
498
+ /**
499
+ * @deprecated use `onTestRunStart` instead
500
+ */
300
501
  onPathsCollected?: (paths?: string[]) => Awaitable<void>;
502
+ /**
503
+ * @deprecated use `onTestRunStart` instead
504
+ */
301
505
  onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
302
- onTestModuleQueued?: (file: TestModule) => Awaitable<void>;
303
- onCollected?: (files?: File[]) => Awaitable<void>;
506
+ /**
507
+ * @deprecated use `onTestModuleCollected` instead
508
+ */
509
+ onCollected?: (files: File[]) => Awaitable<void>;
510
+ /**
511
+ * @deprecated use `onTestRunEnd` instead
512
+ */
304
513
  onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
514
+ /**
515
+ * @deprecated use `onTestModuleQueued`, `onTestModuleStart`, `onTestModuleEnd`, `onTestCaseReady`, `onTestCaseResult` instead
516
+ */
305
517
  onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
306
518
  onTestRemoved?: (trigger?: string) => Awaitable<void>;
307
519
  onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
@@ -309,6 +521,59 @@ interface Reporter {
309
521
  onServerRestart?: (reason?: string) => Awaitable<void>;
310
522
  onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
311
523
  onProcessTimeout?: () => Awaitable<void>;
524
+ /**
525
+ * Called when the new test run starts.
526
+ */
527
+ onTestRunStart?: (specifications: ReadonlyArray<TestSpecification>) => Awaitable<void>;
528
+ /**
529
+ * Called when the test run is finished.
530
+ */
531
+ onTestRunEnd?: (testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason) => Awaitable<void>;
532
+ /**
533
+ * Called when the module is enqueued for testing. The file itself is not loaded yet.
534
+ */
535
+ onTestModuleQueued?: (testModule: TestModule) => Awaitable<void>;
536
+ /**
537
+ * Called when the test file is loaded and the module is ready to run tests.
538
+ */
539
+ onTestModuleCollected?: (testModule: TestModule) => Awaitable<void>;
540
+ /**
541
+ * Called when starting to run tests of the test file
542
+ */
543
+ onTestModuleStart?: (testModule: TestModule) => Awaitable<void>;
544
+ /**
545
+ * Called when all tests of the test file have finished running.
546
+ */
547
+ onTestModuleEnd?: (testModule: TestModule) => Awaitable<void>;
548
+ /**
549
+ * Called when test case is ready to run.
550
+ * Called before the `beforeEach` hooks for the test are run.
551
+ */
552
+ onTestCaseReady?: (testCase: TestCase) => Awaitable<void>;
553
+ /**
554
+ * Called after the test and its hooks are finished running.
555
+ * The `result()` cannot be `pending`.
556
+ */
557
+ onTestCaseResult?: (testCase: TestCase) => Awaitable<void>;
558
+ /**
559
+ * Called when test suite is ready to run.
560
+ * Called before the `beforeAll` hooks for the test are run.
561
+ */
562
+ onTestSuiteReady?: (testSuite: TestSuite) => Awaitable<void>;
563
+ /**
564
+ * Called after the test suite and its hooks are finished running.
565
+ * The `state` cannot be `pending`.
566
+ */
567
+ onTestSuiteResult?: (testSuite: TestSuite) => Awaitable<void>;
568
+ /**
569
+ * Called before the hook starts to run.
570
+ */
571
+ onHookStart?: (hook: ReportedHookContext) => Awaitable<void>;
572
+ /**
573
+ * Called after the hook finished running.
574
+ */
575
+ onHookEnd?: (hook: ReportedHookContext) => Awaitable<void>;
576
+ onCoverage?: (coverage: unknown) => Awaitable<void>;
312
577
  }
313
578
 
314
579
  interface BaseOptions {
@@ -368,12 +633,17 @@ declare class DefaultReporter extends BaseReporter {
368
633
  private options;
369
634
  private summary?;
370
635
  constructor(options?: DefaultReporterOptions);
636
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
371
637
  onTestModuleQueued(file: TestModule): void;
638
+ onTestModuleCollected(module: TestModule): void;
639
+ onTestModuleEnd(module: TestModule): void;
640
+ onTestCaseReady(test: TestCase): void;
641
+ onTestCaseResult(test: TestCase): void;
642
+ onHookStart(hook: ReportedHookContext): void;
643
+ onHookEnd(hook: ReportedHookContext): void;
372
644
  onInit(ctx: Vitest): void;
373
645
  onPathsCollected(paths?: string[]): void;
374
- onTaskUpdate(packs: TaskResultPack[]): void;
375
- onWatcherRerun(files: string[], trigger?: string): void;
376
- onFinished(files?: File[], errors?: unknown[]): void;
646
+ onTestRunEnd(): void;
377
647
  }
378
648
 
379
649
  interface HTMLOptions {
@@ -387,11 +657,18 @@ declare class BasicReporter extends BaseReporter {
387
657
  }
388
658
 
389
659
  declare class DotReporter extends BaseReporter {
390
- private summary?;
660
+ private renderer?;
661
+ private tests;
662
+ private finishedTests;
391
663
  onInit(ctx: Vitest): void;
392
- onTaskUpdate(packs: TaskResultPack[]): void;
664
+ printTask(task: Task): void;
393
665
  onWatcherRerun(files: string[], trigger?: string): void;
394
666
  onFinished(files?: File[], errors?: unknown[]): void;
667
+ onTestModuleCollected(module: TestModule): void;
668
+ onTestCaseReady(test: TestCase): void;
669
+ onTestCaseResult(test: TestCase): void;
670
+ onTestModuleEnd(): void;
671
+ private createSummary;
395
672
  }
396
673
 
397
674
  declare class GithubActionsReporter implements Reporter {
@@ -662,16 +939,6 @@ declare const BenchmarkReportsMap: {
662
939
  };
663
940
  type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
664
941
 
665
- /**
666
- * @deprecated Use `TestModule` instead
667
- */
668
- declare const TestFile: typeof TestModule;
669
-
670
- /**
671
- * @deprecated Use `ModuleDiagnostic` instead
672
- */
673
- type FileDiagnostic = ModuleDiagnostic;
674
-
675
942
  declare const ReportersMap: {
676
943
  default: typeof DefaultReporter;
677
944
  basic: typeof BasicReporter;
@@ -707,10 +974,6 @@ declare class TypeCheckError extends Error {
707
974
  constructor(message: string, stacks: ParsedStack[]);
708
975
  }
709
976
 
710
- interface PrintErrorResult {
711
- nearest?: ParsedStack;
712
- }
713
-
714
977
  interface ErrorOptions {
715
978
  type?: string;
716
979
  fullStack?: boolean;
@@ -736,7 +999,7 @@ declare class Logger {
736
999
  clearFullScreen(message?: string): void;
737
1000
  clearScreen(message: string, force?: boolean): void;
738
1001
  private _clearScreen;
739
- printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
1002
+ printError(err: unknown, options?: ErrorOptions): void;
740
1003
  clearHighlightCache(filename?: string): void;
741
1004
  highlight(filename: string, source: string): string;
742
1005
  printNoTestFound(filters?: string[]): void;
@@ -752,168 +1015,6 @@ declare class Logger {
752
1015
 
753
1016
  type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
754
1017
 
755
- type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
756
- type Pool = BuiltinPool | (string & {});
757
- interface PoolOptions extends Record<string, unknown> {
758
- /**
759
- * Run tests in `node:worker_threads`.
760
- *
761
- * Test isolation (when enabled) is done by spawning a new thread for each test file.
762
- *
763
- * This pool is used by default.
764
- */
765
- threads?: ThreadsOptions & WorkerContextOptions;
766
- /**
767
- * Run tests in `node:child_process` using [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
768
- *
769
- * Test isolation (when enabled) is done by spawning a new child process for each test file.
770
- */
771
- forks?: ForksOptions & WorkerContextOptions;
772
- /**
773
- * Run tests in isolated `node:vm`.
774
- * Test files are run parallel using `node:worker_threads`.
775
- *
776
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
777
- */
778
- vmThreads?: ThreadsOptions & VmOptions;
779
- /**
780
- * Run tests in isolated `node:vm`.
781
- *
782
- * Test files are run parallel using `node:child_process` [`fork()`](https://nodejs.org/api/child_process.html#child_processforkmodulepath-args-options)
783
- *
784
- * This makes tests run faster, but VM module is unstable. Your tests might leak memory.
785
- */
786
- vmForks?: ForksOptions & VmOptions;
787
- }
788
- interface ResolvedPoolOptions extends PoolOptions {
789
- threads?: ResolvedThreadsOptions & WorkerContextOptions;
790
- forks?: ResolvedForksOptions & WorkerContextOptions;
791
- vmThreads?: ResolvedThreadsOptions & VmOptions;
792
- vmForks?: ResolvedForksOptions & VmOptions;
793
- }
794
- interface ThreadsOptions {
795
- /** Minimum amount of threads to use */
796
- minThreads?: number | string;
797
- /** Maximum amount of threads to use */
798
- maxThreads?: number | string;
799
- /**
800
- * Run tests inside a single thread.
801
- *
802
- * @default false
803
- */
804
- singleThread?: boolean;
805
- /**
806
- * Use Atomics to synchronize threads
807
- *
808
- * This can improve performance in some cases, but might cause segfault in older Node versions.
809
- *
810
- * @default false
811
- */
812
- useAtomics?: boolean;
813
- }
814
- interface ResolvedThreadsOptions extends ThreadsOptions {
815
- minThreads?: number;
816
- maxThreads?: number;
817
- }
818
- interface ForksOptions {
819
- /** Minimum amount of child processes to use */
820
- minForks?: number | string;
821
- /** Maximum amount of child processes to use */
822
- maxForks?: number | string;
823
- /**
824
- * Run tests inside a single fork.
825
- *
826
- * @default false
827
- */
828
- singleFork?: boolean;
829
- }
830
- interface ResolvedForksOptions extends ForksOptions {
831
- minForks?: number;
832
- maxForks?: number;
833
- }
834
- interface WorkerContextOptions {
835
- /**
836
- * Isolate test environment by recycling `worker_threads` or `child_process` after each test
837
- *
838
- * @default true
839
- */
840
- isolate?: boolean;
841
- /**
842
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
843
- *
844
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
845
- *
846
- * Set to `process.execArgv` to pass all arguments of the current process.
847
- *
848
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
849
- *
850
- * @default [] // no execution arguments are passed
851
- */
852
- execArgv?: string[];
853
- }
854
- interface VmOptions {
855
- /**
856
- * Specifies the memory limit for `worker_thread` or `child_process` before they are recycled.
857
- * If you see memory leaks, try to tinker this value.
858
- */
859
- memoryLimit?: string | number;
860
- /** Isolation is always enabled */
861
- isolate?: true;
862
- /**
863
- * Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.
864
- *
865
- * See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information.
866
- *
867
- * Set to `process.execArgv` to pass all arguments of the current process.
868
- *
869
- * Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103
870
- *
871
- * @default [] // no execution arguments are passed
872
- */
873
- execArgv?: string[];
874
- }
875
-
876
- declare class TestSpecification {
877
- /**
878
- * @deprecated use `project` instead
879
- */
880
- readonly 0: TestProject;
881
- /**
882
- * @deprecated use `moduleId` instead
883
- */
884
- readonly 1: string;
885
- /**
886
- * @deprecated use `pool` instead
887
- */
888
- readonly 2: {
889
- pool: Pool;
890
- };
891
- /**
892
- * The test project that the module belongs to.
893
- */
894
- readonly project: TestProject;
895
- /**
896
- * The ID of the module in the Vite module graph. It is usually an absolute file path.
897
- */
898
- readonly moduleId: string;
899
- /**
900
- * The current test pool. It's possible to have multiple pools in a single test project with `poolMatchGlob` and `typecheck.enabled`.
901
- * @experimental In Vitest 4, the project will only support a single pool and this property will be removed.
902
- */
903
- readonly pool: Pool;
904
- /**
905
- * Line numbers of the test locations to run.
906
- */
907
- readonly testLines: number[] | undefined;
908
- constructor(project: TestProject, moduleId: string, pool: Pool, testLines?: number[] | undefined);
909
- toJSON(): SerializedTestSpecification;
910
- /**
911
- * for backwards compatibility
912
- * @deprecated
913
- */
914
- [Symbol.iterator](): Generator<string | TestProject, void, unknown>;
915
- }
916
-
917
1018
  interface TestSequencer {
918
1019
  /**
919
1020
  * Slicing tests into shards. Will be run before `sort`.
@@ -2197,7 +2298,7 @@ interface BrowserConfigOptions {
2197
2298
  enabled?: boolean;
2198
2299
  /**
2199
2300
  * Name of the browser
2200
- * @deprecated use `configs` instead. if both are defined, this will filter `configs` by name.
2301
+ * @deprecated use `instances` instead. if both are defined, this will filter `instances` by name.
2201
2302
  */
2202
2303
  name?: string;
2203
2304
  /**
@@ -2219,7 +2320,7 @@ interface BrowserConfigOptions {
2219
2320
  *
2220
2321
  * @example
2221
2322
  * { playwright: { launch: { devtools: true } }
2222
- * @deprecated use `configs` instead
2323
+ * @deprecated use `instances` instead
2223
2324
  */
2224
2325
  providerOptions?: BrowserProviderOptions;
2225
2326
  /**
@@ -2430,7 +2531,6 @@ declare class TestProject {
2430
2531
  private typecheckFilesList;
2431
2532
  private _globalSetups?;
2432
2533
  private _provided;
2433
- private _vite?;
2434
2534
  constructor(
2435
2535
  /** @deprecated */
2436
2536
  path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
@@ -2518,6 +2618,8 @@ declare class TestProject {
2518
2618
  isTargetFile(id: string, source?: string): Promise<boolean>;
2519
2619
  private isInSourceTestCode;
2520
2620
  private filterFiles;
2621
+ private _parentBrowser?;
2622
+ private _parent?;
2521
2623
  /**
2522
2624
  * Closes the project and all associated resources. This can only be called once; the closing promise is cached until the server restarts.
2523
2625
  * If the resources are needed again, create a new project.
@@ -2545,7 +2647,6 @@ interface SerializedTestProject {
2545
2647
  }
2546
2648
  interface InitializeProjectOptions extends UserWorkspaceConfig {
2547
2649
  configFile: string | false;
2548
- extends?: string;
2549
2650
  }
2550
2651
 
2551
2652
  /**
@@ -2635,7 +2736,7 @@ declare class StateManager {
2635
2736
  taskFileMap: WeakMap<Task, File>;
2636
2737
  errorsSet: Set<unknown>;
2637
2738
  processTimeoutCauses: Set<string>;
2638
- reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
2739
+ reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
2639
2740
  catchError(err: unknown, type: string): void;
2640
2741
  clearErrors(): void;
2641
2742
  getUnhandledErrors(): unknown[];
@@ -2653,7 +2754,7 @@ declare class StateManager {
2653
2754
  collectFiles(project: TestProject, files?: File[]): void;
2654
2755
  clearFiles(project: TestProject, paths?: string[]): void;
2655
2756
  updateId(task: Task, project: TestProject): void;
2656
- getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
2757
+ getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
2657
2758
  updateTasks(packs: TaskResultPack[]): void;
2658
2759
  updateUserLog(log: UserConsoleLog): void;
2659
2760
  getCountOfFailedTests(): number;
@@ -2930,4 +3031,4 @@ declare class Vitest {
2930
3031
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
2931
3032
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
2932
3033
 
2933
- export { type JUnitOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, TestProject as E, type TestSequencer as F, TestSpecification as G, TestModule as H, type InlineConfig as I, type OnTestsRerunHandler as J, VitestPackageInstaller as K, Logger as L, type ModuleDiagnostic as M, type ProcessPool as N, type OnServerRestartHandler as O, type Pool as P, type WorkspaceSpec as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TestProjectConfiguration as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, type SerializedTestProject as Y, type HTMLOptions as Z, type JsonOptions$1 as _, type ReportContext as a, type TaskOptions as a0, TestCase as a1, TestCollection as a2, type TestDiagnostic as a3, type TestResult as a4, type TestResultFailed as a5, type TestResultPassed as a6, type TestResultSkipped as a7, TestSuite as a8, type TestSequencerConstructor as a9, TapFlatReporter as aA, TapReporter as aB, VerboseReporter as aC, BaseReporter as aD, TestFile as aE, type FileDiagnostic as aF, ReportersMap as aG, type BuiltinReporters as aH, type BuiltinReporterOptions as aI, type JsonAssertionResult as aJ, type JsonTestResult as aK, type JsonTestResults as aL, BenchmarkReportsMap as aM, type BenchmarkBuiltinReporters as aN, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserInstanceOption as ad, type BrowserOrchestrator as ae, type BrowserProvider as af, type BrowserProviderInitializationOptions as ag, type BrowserProviderModule as ah, type BrowserProviderOptions as ai, type BrowserServerState as aj, type BrowserServerStateSession as ak, type CDPSession as al, type ParentProjectBrowser as am, type ProjectBrowser as an, type ResolvedBrowserOptions as ao, type ResolvedProjectConfig as ap, type ResolveSnapshotPathHandler as aq, type ResolveSnapshotPathHandlerContext as ar, type TestRunResult as as, BasicReporter as at, DefaultReporter as au, DotReporter as av, GithubActionsReporter as aw, HangingProcessReporter as ax, JsonReporter as ay, JUnitReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type CoverageReporter as g, type CoverageProviderName as h, type CoverageOptions as i, type CoverageIstanbulOptions as j, type CustomProviderOptions as k, type Reporter as l, type BrowserScript as m, type BrowserConfigOptions as n, type BuiltinEnvironment as o, type VitestEnvironment as p, type PoolOptions as q, type CSSModuleScopeStrategy as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type UserConfig as v, type ResolvedConfig as w, type ProjectConfig as x, type BenchmarkUserOptions as y, type VitestOptions as z };
3034
+ export { type JUnitOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, TestProject as E, type TestSequencer as F, TestSpecification as G, TestModule as H, type InlineConfig as I, type OnTestsRerunHandler as J, VitestPackageInstaller as K, Logger as L, type ModuleDiagnostic as M, type ProcessPool as N, type OnServerRestartHandler as O, type Pool as P, type WorkspaceSpec as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TestProjectConfiguration as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, getFilePoolName as X, type SerializedTestProject as Y, type HTMLOptions as Z, type JsonOptions$1 as _, type ReportContext as a, type TaskOptions as a0, TestCase as a1, TestCollection as a2, type TestDiagnostic as a3, type TestModuleState as a4, type TestResult as a5, type TestResultFailed as a6, type TestResultPassed as a7, type TestResultSkipped as a8, type TestState as a9, 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, type BenchmarkBuiltinReporters as aN, type BuiltinReporterOptions as aO, type BuiltinReporters as aP, type JsonAssertionResult as aQ, type JsonTestResult as aR, type JsonTestResults as aS, TestSuite as aa, type TestSuiteState as ab, type TestSequencerConstructor as ac, type BrowserBuiltinProvider as ad, type BrowserCommand as ae, type BrowserCommandContext as af, type BrowserInstanceOption as ag, type BrowserOrchestrator as ah, type BrowserProvider as ai, type BrowserProviderInitializationOptions as aj, type BrowserProviderModule as ak, type BrowserProviderOptions as al, type BrowserServerState as am, type BrowserServerStateSession as an, type CDPSession as ao, type ParentProjectBrowser as ap, type ProjectBrowser as aq, type ResolvedBrowserOptions as ar, type ResolvedProjectConfig as as, type ResolveSnapshotPathHandler as at, type ResolveSnapshotPathHandlerContext as au, type TestRunResult as av, type ReportedHookContext as aw, type TestRunEndReason as ax, BasicReporter as ay, BenchmarkReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type CoverageReporter as g, type CoverageProviderName as h, type CoverageOptions as i, type CoverageIstanbulOptions as j, type CustomProviderOptions as k, type Reporter as l, type BrowserScript as m, type BrowserConfigOptions as n, type BuiltinEnvironment as o, type VitestEnvironment as p, type PoolOptions as q, type CSSModuleScopeStrategy as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type UserConfig as v, type ResolvedConfig as w, type ProjectConfig as x, type BenchmarkUserOptions as y, type VitestOptions as z };