vitest 3.0.0-beta.2 → 3.0.0-beta.4

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 (51) hide show
  1. package/LICENSE.md +1 -315
  2. package/config.d.ts +2 -0
  3. package/dist/browser.d.ts +3 -3
  4. package/dist/browser.js +1 -1
  5. package/dist/chunks/{RandomSequencer.gisBJ77r.js → RandomSequencer.DB__To1b.js} +38 -8
  6. package/dist/chunks/{base.CUgXReRN.js → base.BJ8KO-VX.js} +2 -2
  7. package/dist/chunks/{cac.Xzv7eNWw.js → cac.BAYqQ2aM.js} +21 -10
  8. package/dist/chunks/{cli-api.CETCDGgZ.js → cli-api.Dhl34Trr.js} +263 -58
  9. package/dist/chunks/{config.BTPBhmK5.d.ts → config.BRtC-JeT.d.ts} +6 -0
  10. package/dist/chunks/{console.BYGVloWk.js → console.CN7AiMGV.js} +16 -7
  11. package/dist/chunks/{creator.DcAcUhMD.js → creator.Ot9GlSGw.js} +16 -14
  12. package/dist/chunks/{execute.2pr0rHgK.js → execute.BMOaRArH.js} +27 -16
  13. package/dist/chunks/{globals.BFncSRNA.js → globals.C5RQxaV3.js} +2 -2
  14. package/dist/chunks/{index.DoV7W5gc.js → index.B2M9nD1V.js} +6 -1
  15. package/dist/chunks/{index.CkWmZCXU.js → index.BQbxGbG9.js} +1 -1
  16. package/dist/chunks/index.CAueP3cK.js +3205 -0
  17. package/dist/chunks/{reporters.DTtxC3KQ.d.ts → reporters.Dcdq51WE.d.ts} +211 -257
  18. package/dist/chunks/{resolveConfig.BA-_OKEx.js → resolveConfig.kZFMjKCQ.js} +28 -6
  19. package/dist/chunks/{runBaseTests.D0dWpzZV.js → runBaseTests.URiUrnWK.js} +8 -6
  20. package/dist/chunks/{setup-common.Cp_bu5q3.js → setup-common.D0zLenuv.js} +1 -1
  21. package/dist/chunks/{utils.CMUTX-p8.js → utils.yHKcm4dz.js} +10 -21
  22. package/dist/chunks/{vi.S4Fq8wSo.js → vi.Da_PT3Vw.js} +554 -272
  23. package/dist/chunks/{vite.CXaetSK3.d.ts → vite.DzluO1Kj.d.ts} +1 -1
  24. package/dist/chunks/{vm.DGhTouO3.js → vm.DrFVeTXo.js} +4 -4
  25. package/dist/chunks/{worker.ClntunZp.d.ts → worker.BIVMnzXw.d.ts} +1 -1
  26. package/dist/chunks/{worker.o1PBoDdo.d.ts → worker.Hz_LAzfd.d.ts} +2 -1
  27. package/dist/cli.js +1 -1
  28. package/dist/config.cjs +1 -0
  29. package/dist/config.d.ts +4 -4
  30. package/dist/config.js +1 -0
  31. package/dist/coverage.d.ts +2 -2
  32. package/dist/coverage.js +33 -8
  33. package/dist/execute.d.ts +3 -3
  34. package/dist/execute.js +1 -1
  35. package/dist/index.d.ts +7 -7
  36. package/dist/index.js +2 -2
  37. package/dist/node.d.ts +6 -6
  38. package/dist/node.js +10 -11
  39. package/dist/reporters.d.ts +2 -2
  40. package/dist/reporters.js +3 -7
  41. package/dist/runners.d.ts +1 -1
  42. package/dist/runners.js +5 -12
  43. package/dist/workers/forks.js +2 -2
  44. package/dist/workers/runVmTests.js +7 -5
  45. package/dist/workers/threads.js +2 -2
  46. package/dist/workers/vmForks.js +3 -3
  47. package/dist/workers/vmThreads.js +3 -3
  48. package/dist/workers.d.ts +3 -3
  49. package/dist/workers.js +4 -4
  50. package/package.json +17 -19
  51. package/dist/chunks/index.9ZEBV_TJ.js +0 -5442
@@ -1,11 +1,11 @@
1
1
  import * as _vitest_runner from '@vitest/runner';
2
- import { File, TaskResultPack, Task, TaskMeta, Suite, SequenceHooks, SequenceSetupFiles, CancelReason } from '@vitest/runner';
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
4
  import { TestError, 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';
8
- import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.BTPBhmK5.js';
8
+ import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.BRtC-JeT.js';
9
9
  import { PrettyFormatOptions } from '@vitest/pretty-format';
10
10
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
11
11
  import { SerializedDiffOptions } from '@vitest/utils/diff';
@@ -27,89 +27,9 @@ type SerializedTestSpecification = [
27
27
  }
28
28
  ];
29
29
 
30
- interface Reporter {
31
- onInit?: (ctx: Vitest) => void;
32
- onPathsCollected?: (paths?: string[]) => Awaitable<void>;
33
- onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
34
- onCollected?: (files?: File[]) => Awaitable<void>;
35
- onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
36
- onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
37
- onTestRemoved?: (trigger?: string) => Awaitable<void>;
38
- onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
39
- onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
40
- onServerRestart?: (reason?: string) => Awaitable<void>;
41
- onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
42
- onProcessTimeout?: () => Awaitable<void>;
43
- }
44
-
45
- interface BaseOptions {
46
- isTTY?: boolean;
47
- }
48
- declare abstract class BaseReporter implements Reporter {
49
- start: number;
50
- end: number;
51
- watchFilters?: string[];
52
- failedUnwatchedFiles: Task[];
53
- isTTY: boolean;
54
- ctx: Vitest;
55
- renderSucceed: boolean;
56
- protected verbose: boolean;
57
- private _filesInWatchMode;
58
- private _timeStart;
59
- constructor(options?: BaseOptions);
60
- onInit(ctx: Vitest): void;
61
- log(...messages: any): void;
62
- error(...messages: any): void;
63
- relative(path: string): string;
64
- onFinished(files?: File[], errors?: unknown[]): void;
65
- onTaskUpdate(packs: TaskResultPack[]): void;
66
- protected printTask(task: Task): void;
67
- private getDurationPrefix;
68
- onWatcherStart(files?: File[], errors?: unknown[]): void;
69
- onWatcherRerun(files: string[], trigger?: string): void;
70
- onUserConsoleLog(log: UserConsoleLog): void;
71
- onTestRemoved(trigger?: string): void;
72
- shouldLog(log: UserConsoleLog): boolean;
73
- onServerRestart(reason?: string): void;
74
- reportSummary(files: File[], errors: unknown[]): void;
75
- reportTestSummary(files: File[], errors: unknown[]): void;
76
- private printErrorsSummary;
77
- reportBenchmarkSummary(files: File[]): void;
78
- private printTaskErrors;
79
- }
80
-
81
- interface BlobOptions {
82
- outputFile?: string;
83
- }
84
- declare class BlobReporter implements Reporter {
85
- ctx: Vitest;
86
- options: BlobOptions;
87
- constructor(options: BlobOptions);
88
- onInit(ctx: Vitest): void;
89
- onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
90
- }
91
-
92
- interface DefaultReporterOptions extends BaseOptions {
93
- summary?: boolean;
94
- }
95
- declare class DefaultReporter extends BaseReporter {
96
- private options;
97
- private summary?;
98
- constructor(options?: DefaultReporterOptions);
99
- onInit(ctx: Vitest): void;
100
- onPathsCollected(paths?: string[]): void;
101
- onTaskUpdate(packs: TaskResultPack[]): void;
102
- onWatcherRerun(files: string[], trigger?: string): void;
103
- onFinished(files?: File[], errors?: unknown[]): void;
104
- }
105
-
106
- interface HTMLOptions {
107
- outputFile?: string;
108
- }
109
-
110
30
  declare class ReportedTaskImplementation {
111
31
  /**
112
- * The project assosiacted with the test or suite.
32
+ * The project associated with the test or suite.
113
33
  */
114
34
  readonly project: TestProject;
115
35
  /**
@@ -279,7 +199,7 @@ interface TaskOptions {
279
199
  shuffle: boolean | undefined;
280
200
  retry: number | undefined;
281
201
  repeats: number | undefined;
282
- mode: 'run' | 'only' | 'skip' | 'todo';
202
+ mode: 'run' | 'only' | 'skip' | 'todo' | 'queued';
283
203
  }
284
204
  type TestResult = TestResultPassed | TestResultFailed | TestResultSkipped;
285
205
  interface TestResultPassed {
@@ -375,6 +295,91 @@ interface ModuleDiagnostic {
375
295
  duration: number;
376
296
  }
377
297
 
298
+ interface Reporter {
299
+ onInit?: (ctx: Vitest) => void;
300
+ onPathsCollected?: (paths?: string[]) => Awaitable<void>;
301
+ onSpecsCollected?: (specs?: SerializedTestSpecification[]) => Awaitable<void>;
302
+ onTestModuleQueued?: (file: TestModule) => Awaitable<void>;
303
+ onCollected?: (files?: File[]) => Awaitable<void>;
304
+ onFinished?: (files: File[], errors: unknown[], coverage?: unknown) => Awaitable<void>;
305
+ onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
306
+ onTestRemoved?: (trigger?: string) => Awaitable<void>;
307
+ onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
308
+ onWatcherRerun?: (files: string[], trigger?: string) => Awaitable<void>;
309
+ onServerRestart?: (reason?: string) => Awaitable<void>;
310
+ onUserConsoleLog?: (log: UserConsoleLog) => Awaitable<void>;
311
+ onProcessTimeout?: () => Awaitable<void>;
312
+ }
313
+
314
+ interface BaseOptions {
315
+ isTTY?: boolean;
316
+ }
317
+ declare abstract class BaseReporter implements Reporter {
318
+ start: number;
319
+ end: number;
320
+ watchFilters?: string[];
321
+ failedUnwatchedFiles: Task[];
322
+ isTTY: boolean;
323
+ ctx: Vitest;
324
+ renderSucceed: boolean;
325
+ protected verbose: boolean;
326
+ private _filesInWatchMode;
327
+ private _timeStart;
328
+ constructor(options?: BaseOptions);
329
+ onInit(ctx: Vitest): void;
330
+ log(...messages: any): void;
331
+ error(...messages: any): void;
332
+ relative(path: string): string;
333
+ onFinished(files?: File[], errors?: unknown[]): void;
334
+ onTaskUpdate(packs: TaskResultPack[]): void;
335
+ /**
336
+ * Callback invoked with a single `Task` from `onTaskUpdate`
337
+ */
338
+ protected printTask(task: Task): void;
339
+ private getDurationPrefix;
340
+ onWatcherStart(files?: File[], errors?: unknown[]): void;
341
+ onWatcherRerun(files: string[], trigger?: string): void;
342
+ onUserConsoleLog(log: UserConsoleLog): void;
343
+ onTestRemoved(trigger?: string): void;
344
+ shouldLog(log: UserConsoleLog): boolean;
345
+ onServerRestart(reason?: string): void;
346
+ reportSummary(files: File[], errors: unknown[]): void;
347
+ reportTestSummary(files: File[], errors: unknown[]): void;
348
+ private printErrorsSummary;
349
+ reportBenchmarkSummary(files: File[]): void;
350
+ private printTaskErrors;
351
+ }
352
+
353
+ interface BlobOptions {
354
+ outputFile?: string;
355
+ }
356
+ declare class BlobReporter implements Reporter {
357
+ ctx: Vitest;
358
+ options: BlobOptions;
359
+ constructor(options: BlobOptions);
360
+ onInit(ctx: Vitest): void;
361
+ onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
362
+ }
363
+
364
+ interface DefaultReporterOptions extends BaseOptions {
365
+ summary?: boolean;
366
+ }
367
+ declare class DefaultReporter extends BaseReporter {
368
+ private options;
369
+ private summary?;
370
+ constructor(options?: DefaultReporterOptions);
371
+ onTestModuleQueued(file: TestModule): void;
372
+ onInit(ctx: Vitest): void;
373
+ onPathsCollected(paths?: string[]): void;
374
+ onTaskUpdate(packs: TaskResultPack[]): void;
375
+ onWatcherRerun(files: string[], trigger?: string): void;
376
+ onFinished(files?: File[], errors?: unknown[]): void;
377
+ }
378
+
379
+ interface HTMLOptions {
380
+ outputFile?: string;
381
+ }
382
+
378
383
  declare class BasicReporter extends BaseReporter {
379
384
  constructor();
380
385
  onInit(ctx: Vitest): void;
@@ -622,166 +627,38 @@ declare class TapFlatReporter extends TapReporter {
622
627
  declare class VerboseReporter extends DefaultReporter {
623
628
  protected verbose: boolean;
624
629
  renderSucceed: boolean;
625
- onTaskUpdate(packs: TaskResultPack[]): void;
626
- }
627
-
628
- declare class TypeCheckError extends Error {
629
- message: string;
630
- stacks: ParsedStack[];
631
- name: string;
632
- constructor(message: string, stacks: ParsedStack[]);
633
- }
634
-
635
- interface PrintErrorResult {
636
- nearest?: ParsedStack;
637
- }
638
-
639
- interface Options {
640
- /**
641
- Show the cursor. This can be useful when a CLI accepts input from a user.
642
-
643
- @example
644
- ```
645
- import {createLogUpdate} from 'log-update';
646
-
647
- // Write output but don't hide the cursor
648
- const log = createLogUpdate(process.stdout, {
649
- showCursor: true
650
- });
651
- ```
652
- */
653
- readonly showCursor?: boolean;
630
+ printTask(task: Task): void;
654
631
  }
655
632
 
656
- type LogUpdateMethods = {
657
- /**
658
- Clear the logged output.
659
- */
660
- clear(): void;
661
-
662
- /**
663
- Persist the logged output. Useful if you want to start a new log session below the current one.
664
- */
665
- done(): void;
633
+ type FormattedBenchmarkResult = BenchmarkResult & {
634
+ id: string;
666
635
  };
667
636
 
668
- /**
669
- Log to `stdout` by overwriting the previous output in the terminal.
670
-
671
- @param text - The text to log to `stdout`.
672
-
673
- @example
674
- ```
675
- import logUpdate from 'log-update';
676
-
677
- const frames = ['-', '\\', '|', '/'];
678
- let index = 0;
679
-
680
- setInterval(() => {
681
- const frame = frames[index = ++index % frames.length];
682
-
683
- logUpdate(
684
- `
685
- ♥♥
686
- ${frame} unicorns ${frame}
687
- ♥♥
688
- `
689
- );
690
- }, 80);
691
- ```
692
- */
693
- declare const logUpdate: ((...text: string[]) => void) & LogUpdateMethods;
694
-
695
-
696
- /**
697
- Get a `logUpdate` method that logs to the specified stream.
698
-
699
- @param stream - The stream to log to.
700
-
701
- @example
702
- ```
703
- import {createLogUpdate} from 'log-update';
704
-
705
- // Write output but don't hide the cursor
706
- const log = createLogUpdate(process.stdout);
707
- ```
708
- */
709
- declare function createLogUpdate(
710
- stream: NodeJS.WritableStream,
711
- options?: Options
712
- ): typeof logUpdate;
713
-
714
- interface ErrorOptions {
715
- type?: string;
716
- fullStack?: boolean;
717
- project?: TestProject;
718
- verbose?: boolean;
719
- screenshotPaths?: string[];
720
- task?: Task;
721
- showCodeFrame?: boolean;
722
- }
723
- declare class Logger {
724
- ctx: Vitest;
725
- outputStream: NodeJS.WriteStream | Writable;
726
- errorStream: NodeJS.WriteStream | Writable;
727
- logUpdate: ReturnType<typeof createLogUpdate>;
728
- private _clearScreenPending;
729
- private _highlights;
730
- console: Console;
731
- constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
732
- log(...args: any[]): void;
733
- error(...args: any[]): void;
734
- warn(...args: any[]): void;
735
- clearFullScreen(message?: string): void;
736
- clearScreen(message: string, force?: boolean): void;
737
- private _clearScreen;
738
- printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
739
- clearHighlightCache(filename?: string): void;
740
- highlight(filename: string, source: string): string;
741
- printNoTestFound(filters?: string[]): void;
742
- printBanner(): void;
743
- printBrowserBanner(project: TestProject): void;
744
- printUnhandledErrors(errors: unknown[]): void;
745
- printSourceTypeErrors(errors: TypeCheckError[]): void;
746
- private registerUnhandledRejection;
747
- }
748
-
749
- interface TableRendererOptions {
750
- renderSucceed?: boolean;
751
- logger: Logger;
637
+ declare function renderTable(options: {
638
+ tasks: Task[];
639
+ level: number;
640
+ shallow?: boolean;
752
641
  showHeap: boolean;
642
+ columns: number;
753
643
  slowTestThreshold: number;
754
- compare?: FlatBenchmarkReport;
755
- }
756
- declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
757
- start(): /*elided*/ any;
758
- update(_tasks: Task[]): /*elided*/ any;
759
- stop(): /*elided*/ any;
760
- clear(): void;
761
- };
644
+ compare?: Record<Task['id'], FormattedBenchmarkResult>;
645
+ }): string;
762
646
 
763
- declare class TableReporter extends BaseReporter {
764
- renderer?: ReturnType<typeof createTableRenderer>;
765
- rendererOptions: TableRendererOptions;
766
- onTestRemoved(trigger?: string): void;
767
- onCollected(): Promise<void>;
647
+ declare class BenchmarkReporter extends DefaultReporter {
648
+ compare?: Parameters<typeof renderTable>[0]['compare'];
649
+ onInit(ctx: Vitest): Promise<void>;
768
650
  onTaskUpdate(packs: TaskResultPack[]): void;
769
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
770
- onWatcherStart(): Promise<void>;
771
- stopListRender(): void;
772
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
773
- onUserConsoleLog(log: UserConsoleLog): void;
651
+ printTask(task: Task): void;
652
+ onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
774
653
  }
775
- interface FlatBenchmarkReport {
776
- [id: string]: FormattedBenchmarkResult;
654
+
655
+ declare class VerboseBenchmarkReporter extends BenchmarkReporter {
656
+ protected verbose: boolean;
777
657
  }
778
- type FormattedBenchmarkResult = BenchmarkResult & {
779
- id: string;
780
- };
781
658
 
782
659
  declare const BenchmarkReportsMap: {
783
- default: typeof TableReporter;
784
- verbose: typeof VerboseReporter;
660
+ default: typeof BenchmarkReporter;
661
+ verbose: typeof VerboseBenchmarkReporter;
785
662
  };
786
663
  type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
787
664
 
@@ -823,6 +700,56 @@ interface BuiltinReporterOptions {
823
700
  'html': HTMLOptions;
824
701
  }
825
702
 
703
+ declare class TypeCheckError extends Error {
704
+ message: string;
705
+ stacks: ParsedStack[];
706
+ name: string;
707
+ constructor(message: string, stacks: ParsedStack[]);
708
+ }
709
+
710
+ interface PrintErrorResult {
711
+ nearest?: ParsedStack;
712
+ }
713
+
714
+ interface ErrorOptions {
715
+ type?: string;
716
+ fullStack?: boolean;
717
+ project?: TestProject;
718
+ verbose?: boolean;
719
+ screenshotPaths?: string[];
720
+ task?: Task;
721
+ showCodeFrame?: boolean;
722
+ }
723
+ type Listener = () => void;
724
+ declare class Logger {
725
+ ctx: Vitest;
726
+ outputStream: NodeJS.WriteStream | Writable;
727
+ errorStream: NodeJS.WriteStream | Writable;
728
+ private _clearScreenPending;
729
+ private _highlights;
730
+ private cleanupListeners;
731
+ console: Console;
732
+ constructor(ctx: Vitest, outputStream?: NodeJS.WriteStream | Writable, errorStream?: NodeJS.WriteStream | Writable);
733
+ log(...args: any[]): void;
734
+ error(...args: any[]): void;
735
+ warn(...args: any[]): void;
736
+ clearFullScreen(message?: string): void;
737
+ clearScreen(message: string, force?: boolean): void;
738
+ private _clearScreen;
739
+ printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
740
+ clearHighlightCache(filename?: string): void;
741
+ highlight(filename: string, source: string): string;
742
+ printNoTestFound(filters?: string[]): void;
743
+ printBanner(): void;
744
+ printBrowserBanner(project: TestProject): void;
745
+ printUnhandledErrors(errors: unknown[]): void;
746
+ printSourceTypeErrors(errors: TypeCheckError[]): void;
747
+ getColumns(): number;
748
+ onTerminalCleanup(listener: Listener): void;
749
+ private addCleanupListeners;
750
+ private registerUnhandledRejection;
751
+ }
752
+
826
753
  type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
827
754
 
828
755
  type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
@@ -2019,7 +1946,7 @@ interface InlineConfig {
2019
1946
  /**
2020
1947
  * By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
2021
1948
  * This is also required for console log preview on Vitest UI.
2022
- * However, disabling such interception might help when you want to debug a code with normal synchronus terminal console logging.
1949
+ * However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
2023
1950
  *
2024
1951
  * This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
2025
1952
  *
@@ -2041,7 +1968,7 @@ interface InlineConfig {
2041
1968
  }
2042
1969
  interface TypecheckConfig {
2043
1970
  /**
2044
- * Run typechecking tests alongisde regular tests.
1971
+ * Run typechecking tests alongside regular tests.
2045
1972
  */
2046
1973
  enabled?: boolean;
2047
1974
  /**
@@ -2195,8 +2122,9 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2195
2122
  maxWorkers: number;
2196
2123
  minWorkers: number;
2197
2124
  }
2198
- type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism';
2199
- type ProjectConfig = Omit<UserConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
2125
+ type NonProjectOptions = 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'coverage' | 'maxWorkers' | 'minWorkers' | 'fileParallelism' | 'workspace';
2126
+ type ProjectConfig = Omit<InlineConfig, NonProjectOptions | 'sequencer' | 'deps' | 'poolOptions'> & {
2127
+ mode?: string;
2200
2128
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2201
2129
  deps?: Omit<DepsOptions, 'moduleDirectories'>;
2202
2130
  poolOptions?: {
@@ -2241,9 +2169,9 @@ interface BrowserProvider {
2241
2169
  getSupportedBrowsers: () => readonly string[];
2242
2170
  beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
2243
2171
  afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
2244
- getCommandsContext: (contextId: string) => Record<string, unknown>;
2245
- openPage: (contextId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
2246
- getCDPSession?: (contextId: string) => Promise<CDPSession>;
2172
+ getCommandsContext: (sessionId: string) => Record<string, unknown>;
2173
+ openPage: (sessionId: string, url: string, beforeNavigate?: () => Promise<void>) => Promise<void>;
2174
+ getCDPSession?: (sessionId: string) => Promise<CDPSession>;
2247
2175
  close: () => Awaitable$1<void>;
2248
2176
  initialize(ctx: TestProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
2249
2177
  }
@@ -2253,6 +2181,13 @@ interface BrowserProviderModule {
2253
2181
  interface BrowserProviderOptions {
2254
2182
  }
2255
2183
  type BrowserBuiltinProvider = 'webdriverio' | 'playwright' | 'preview';
2184
+ type UnsupportedProperties = 'browser' | 'typecheck' | 'alias' | 'sequence' | 'root' | 'pool' | 'poolOptions' | 'runner' | 'api' | 'deps' | 'testTransformMode' | 'poolMatchGlobs' | 'environmentMatchGlobs' | 'environment' | 'environmentOptions' | 'server' | 'benchmark';
2185
+ interface BrowserInstanceOption extends BrowserProviderOptions, Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, 'headless' | 'locators' | 'viewport' | 'testerHtmlPath' | 'screenshotDirectory' | 'screenshotFailures'> {
2186
+ /**
2187
+ * Name of the browser
2188
+ */
2189
+ browser: string;
2190
+ }
2256
2191
  interface BrowserConfigOptions {
2257
2192
  /**
2258
2193
  * if running tests in the browser should be the default
@@ -2262,8 +2197,13 @@ interface BrowserConfigOptions {
2262
2197
  enabled?: boolean;
2263
2198
  /**
2264
2199
  * Name of the browser
2200
+ * @deprecated use `configs` instead. if both are defined, this will filter `configs` by name.
2265
2201
  */
2266
- name: string;
2202
+ name?: string;
2203
+ /**
2204
+ * Configurations for different browser setups
2205
+ */
2206
+ instances?: BrowserInstanceOption[];
2267
2207
  /**
2268
2208
  * Browser provider
2269
2209
  *
@@ -2279,6 +2219,7 @@ interface BrowserConfigOptions {
2279
2219
  *
2280
2220
  * @example
2281
2221
  * { playwright: { launch: { devtools: true } }
2222
+ * @deprecated use `configs` instead
2282
2223
  */
2283
2224
  providerOptions?: BrowserProviderOptions;
2284
2225
  /**
@@ -2368,16 +2309,25 @@ interface BrowserConfigOptions {
2368
2309
  * @see {@link https://vitest.dev/guide/browser/commands}
2369
2310
  */
2370
2311
  commands?: Record<string, BrowserCommand<any>>;
2312
+ /**
2313
+ * Timeout for connecting to the browser
2314
+ * @default 30000
2315
+ */
2316
+ connectTimeout?: number;
2371
2317
  }
2372
2318
  interface BrowserCommandContext {
2373
2319
  testPath: string | undefined;
2374
2320
  provider: BrowserProvider;
2375
2321
  project: TestProject;
2322
+ /** @deprecated use `sessionId` instead */
2376
2323
  contextId: string;
2324
+ sessionId: string;
2377
2325
  }
2378
- interface BrowserServerStateContext {
2326
+ interface BrowserServerStateSession {
2379
2327
  files: string[];
2380
2328
  method: 'run' | 'collect';
2329
+ project: TestProject;
2330
+ connected: () => void;
2381
2331
  resolve: () => void;
2382
2332
  reject: (v: unknown) => void;
2383
2333
  }
@@ -2388,15 +2338,16 @@ interface BrowserOrchestrator {
2388
2338
  }
2389
2339
  interface BrowserServerState {
2390
2340
  orchestrators: Map<string, BrowserOrchestrator>;
2391
- getContext: (contextId: string) => BrowserServerStateContext | undefined;
2392
- createAsyncContext: (method: 'collect' | 'run', contextId: string, files: string[]) => Promise<void>;
2393
2341
  }
2394
- interface BrowserServer {
2342
+ interface ParentProjectBrowser {
2343
+ spawn: (project: TestProject) => ProjectBrowser;
2344
+ }
2345
+ interface ProjectBrowser {
2395
2346
  vite: ViteDevServer;
2396
2347
  state: BrowserServerState;
2397
2348
  provider: BrowserProvider;
2398
2349
  close: () => Promise<void>;
2399
- initBrowserProvider: () => Promise<void>;
2350
+ initBrowserProvider: (project: TestProject) => Promise<void>;
2400
2351
  parseStacktrace: (stack: string) => ParsedStack[];
2401
2352
  parseErrorStacktrace: (error: ErrorWithDiff, options?: StackTraceParserOptions) => ParsedStack[];
2402
2353
  }
@@ -2432,6 +2383,8 @@ interface BrowserScript {
2432
2383
  type?: string;
2433
2384
  }
2434
2385
  interface ResolvedBrowserOptions extends BrowserConfigOptions {
2386
+ name: string;
2387
+ providerOptions?: BrowserProviderOptions;
2435
2388
  enabled: boolean;
2436
2389
  headless: boolean;
2437
2390
  isolate: boolean;
@@ -2451,7 +2404,6 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
2451
2404
  declare class TestProject {
2452
2405
  /** @deprecated */
2453
2406
  path: string | number;
2454
- /** @deprecated */
2455
2407
  options?: InitializeProjectOptions | undefined;
2456
2408
  /**
2457
2409
  * The global Vitest instance.
@@ -2465,7 +2417,7 @@ declare class TestProject {
2465
2417
  /**
2466
2418
  * Browser instance if the browser is enabled. This is initialized when the tests run for the first time.
2467
2419
  */
2468
- browser?: BrowserServer;
2420
+ browser?: ProjectBrowser;
2469
2421
  /** @deprecated use `vitest` instead */
2470
2422
  ctx: Vitest;
2471
2423
  /**
@@ -2478,13 +2430,10 @@ declare class TestProject {
2478
2430
  private typecheckFilesList;
2479
2431
  private _globalSetups?;
2480
2432
  private _provided;
2481
- private _config?;
2482
2433
  private _vite?;
2483
2434
  constructor(
2484
2435
  /** @deprecated */
2485
- path: string | number, vitest: Vitest,
2486
- /** @deprecated */
2487
- options?: InitializeProjectOptions | undefined);
2436
+ path: string | number, vitest: Vitest, options?: InitializeProjectOptions | undefined);
2488
2437
  /**
2489
2438
  * Provide a value to the test context. This value will be available to all tests with `inject`.
2490
2439
  */
@@ -2583,7 +2532,7 @@ declare class TestProject {
2583
2532
  getName(): string;
2584
2533
  /** @deprecated internal */
2585
2534
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
2586
- private _serializeOverridenConfig;
2535
+ private _serializeOverriddenConfig;
2587
2536
  private clearTmpDir;
2588
2537
  /** @deprecated */
2589
2538
  initBrowserProvider(): Promise<void>;
@@ -2686,7 +2635,7 @@ declare class StateManager {
2686
2635
  taskFileMap: WeakMap<Task, File>;
2687
2636
  errorsSet: Set<unknown>;
2688
2637
  processTimeoutCauses: Set<string>;
2689
- reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
2638
+ reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
2690
2639
  catchError(err: unknown, type: string): void;
2691
2640
  clearErrors(): void;
2692
2641
  getUnhandledErrors(): unknown[];
@@ -2704,7 +2653,7 @@ declare class StateManager {
2704
2653
  collectFiles(project: TestProject, files?: File[]): void;
2705
2654
  clearFiles(project: TestProject, paths?: string[]): void;
2706
2655
  updateId(task: Task, project: TestProject): void;
2707
- getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
2656
+ getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
2708
2657
  updateTasks(packs: TaskResultPack[]): void;
2709
2658
  updateUserLog(log: UserConsoleLog): void;
2710
2659
  getCountOfFailedTests(): number;
@@ -2861,14 +2810,14 @@ declare class Vitest {
2861
2810
  /** @deprecated */
2862
2811
  getFileWorkspaceSpecs(file: string): WorkspaceSpec[];
2863
2812
  /**
2864
- * Get test specifications assosiated with the given module. If module is not a test file, an empty array is returned.
2813
+ * Get test specifications associated with the given module. If module is not a test file, an empty array is returned.
2865
2814
  *
2866
2815
  * **Note:** this method relies on a cache generated by `globTestSpecifications`. If the file was not processed yet, use `project.matchesGlobPattern` instead.
2867
2816
  * @param moduleId The module ID to get test specifications for.
2868
2817
  */
2869
2818
  getModuleSpecifications(moduleId: string): TestSpecification[];
2870
2819
  /**
2871
- * Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache alltogether.
2820
+ * Vitest automatically caches test specifications for each file. This method clears the cache for the given file or the whole cache altogether.
2872
2821
  */
2873
2822
  clearSpecificationsCache(moduleId?: string): void;
2874
2823
  /**
@@ -2894,6 +2843,11 @@ declare class Vitest {
2894
2843
  */
2895
2844
  cancelCurrentRun(reason: CancelReason): Promise<void>;
2896
2845
  private initializeGlobalSetup;
2846
+ /**
2847
+ * Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.
2848
+ * @param files The list of files on the file system
2849
+ */
2850
+ updateSnapshot(files?: string[]): Promise<TestRunResult>;
2897
2851
  /**
2898
2852
  * Enable the mode that allows updating snapshots when running tests.
2899
2853
  * This method doesn't run any tests.
@@ -2976,4 +2930,4 @@ declare class Vitest {
2976
2930
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
2977
2931
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
2978
2932
 
2979
- 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, VerboseReporter as aA, BaseReporter as aB, TestFile as aC, type FileDiagnostic as aD, ReportersMap as aE, type BuiltinReporters as aF, type BuiltinReporterOptions as aG, type JsonAssertionResult as aH, type JsonTestResult as aI, type JsonTestResults as aJ, BenchmarkReportsMap as aK, type BenchmarkBuiltinReporters as aL, type BrowserBuiltinProvider as aa, type BrowserCommand as ab, type BrowserCommandContext as ac, type BrowserOrchestrator as ad, type BrowserProvider as ae, type BrowserProviderInitializationOptions as af, type BrowserProviderModule as ag, type BrowserProviderOptions as ah, type BrowserServer as ai, type BrowserServerState as aj, type BrowserServerStateContext as ak, type CDPSession as al, type ResolvedBrowserOptions as am, type ResolvedProjectConfig as an, type ResolveSnapshotPathHandler as ao, type ResolveSnapshotPathHandlerContext as ap, type TestRunResult as aq, BasicReporter as ar, DefaultReporter as as, DotReporter as at, GithubActionsReporter as au, HangingProcessReporter as av, JsonReporter as aw, JUnitReporter as ax, TapFlatReporter as ay, TapReporter 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 };
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 };