vitest 1.6.0 → 2.0.0-beta.10

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 (74) hide show
  1. package/LICENSE.md +173 -1
  2. package/dist/browser.d.ts +22 -2
  3. package/dist/browser.js +6 -4
  4. package/dist/chunks/{environments-node.vcoXCoKs.js → environments-node.39w4gmlF.js} +2 -2
  5. package/dist/chunks/{install-pkg.LE8oaA1t.js → install-pkg.DNUmWFkO.js} +2 -2
  6. package/dist/chunks/integrations-globals.C6Ah-pUW.js +31 -0
  7. package/dist/chunks/{runtime-console.EO5ha7qv.js → runtime-console.DiVMr5d4.js} +62 -32
  8. package/dist/chunks/{runtime-runBaseTests.oAvMKtQC.js → runtime-runBaseTests.Cukyr5-I.js} +18 -18
  9. package/dist/cli.js +3 -3
  10. package/dist/config.cjs +4 -5
  11. package/dist/config.d.ts +2 -2
  12. package/dist/config.js +4 -5
  13. package/dist/coverage.d.ts +1 -1
  14. package/dist/coverage.js +34 -8
  15. package/dist/environments.d.ts +1 -1
  16. package/dist/environments.js +1 -1
  17. package/dist/execute.d.ts +3 -2
  18. package/dist/execute.js +2 -2
  19. package/dist/index.d.ts +777 -65
  20. package/dist/index.js +12 -12
  21. package/dist/node.d.ts +7 -7
  22. package/dist/node.js +24 -23
  23. package/dist/{reporters-yx5ZTtEV.d.ts → reporters-CYVC6LOl.d.ts} +439 -219
  24. package/dist/reporters.d.ts +1 -1
  25. package/dist/reporters.js +11 -12
  26. package/dist/runners.d.ts +4 -2
  27. package/dist/runners.js +25 -18
  28. package/dist/snapshot.js +3 -3
  29. package/dist/{suite-IbNSsUWN.d.ts → suite-Dpu9EC_k.d.ts} +1 -1
  30. package/dist/suite.d.ts +2 -2
  31. package/dist/suite.js +4 -4
  32. package/dist/vendor/{base.Ybri3C14.js → base.Dln9yllP.js} +3 -3
  33. package/dist/vendor/{base.5NT-gWu5.js → base._gnK9Slw.js} +1 -2
  34. package/dist/vendor/{benchmark.yGkUTKnC.js → benchmark.BNLebNi5.js} +1 -1
  35. package/dist/vendor/{cac.EdDItJD-.js → cac.CtYFkoSJ.js} +66 -25
  36. package/dist/vendor/{cli-api.E07AF1Yq.js → cli-api.CUtJc4r3.js} +11851 -7276
  37. package/dist/vendor/{constants.5J7I254_.js → constants.TCjCaw2D.js} +4 -3
  38. package/dist/vendor/{execute.fL3szUAI.js → execute.BHj6OMh4.js} +4 -4
  39. package/dist/vendor/{index.DpVgvm2P.js → index.B5SKBLvV.js} +5 -5
  40. package/dist/vendor/{index.Q04MCqDO.js → index.BOMEjpjj.js} +680 -160
  41. package/dist/vendor/{index.8bPxjt7g.js → index.BpSiYbpB.js} +5 -1
  42. package/dist/vendor/{index.xL8XjTLv.js → index.CThipSqB.js} +2538 -2525
  43. package/dist/vendor/{index.dI9lHwVn.js → index.D3hs2WiI.js} +8 -6
  44. package/dist/vendor/{index.SMVOaj7F.js → index._7XLd8Kd.js} +2 -2
  45. package/dist/vendor/{index.GVFv9dZ0.js → index.kpsSqFiz.js} +2 -1
  46. package/dist/vendor/{rpc.joBhAkyK.js → rpc.DRDE9Pu1.js} +2 -2
  47. package/dist/vendor/{run-once.Olz_Zkd8.js → run-once.DLomgGUH.js} +1 -1
  48. package/dist/vendor/{setup-common.8nJLd4ay.js → setup-common.DAu7t7mY.js} +2 -2
  49. package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
  50. package/dist/vendor/{tasks.IknbGB2n.js → tasks.WC7M-K-v.js} +4 -1
  51. package/dist/vendor/{utils.dEtNIEgr.js → utils.YuQ3LT2a.js} +2 -2
  52. package/dist/vendor/{vi.YFlodzP_.js → vi.hATFzZbX.js} +124 -56
  53. package/dist/vendor/{vm.QEE48c0T.js → vm.Ow-X2mkS.js} +47 -59
  54. package/dist/worker.js +6 -6
  55. package/dist/workers/forks.js +5 -5
  56. package/dist/workers/runVmTests.js +17 -17
  57. package/dist/workers/threads.js +5 -5
  58. package/dist/workers/vmForks.js +8 -8
  59. package/dist/workers/vmThreads.js +8 -8
  60. package/dist/workers.d.ts +1 -1
  61. package/dist/workers.js +13 -13
  62. package/package.json +35 -35
  63. package/suppress-warnings.cjs +2 -1
  64. package/vitest.mjs +1 -1
  65. package/dist/chunks/integrations-globals.kw4co3rx.js +0 -31
  66. package/dist/cli-wrapper.js +0 -119
  67. /package/dist/chunks/{node-git.Hw101KjS.js → node-git.CCI8evVZ.js} +0 -0
  68. /package/dist/vendor/{_commonjsHelpers.jjO7Zipk.js → _commonjsHelpers.BFTU3MAI.js} +0 -0
  69. /package/dist/vendor/{coverage.E7sG1b3r.js → coverage.ChSqD-qS.js} +0 -0
  70. /package/dist/vendor/{date.Ns1pGd_X.js → date.BKM1wewY.js} +0 -0
  71. /package/dist/vendor/{env.AtSIuHFg.js → env.bmJgw1qP.js} +0 -0
  72. /package/dist/vendor/{global.CkGT_TMy.js → global.7bFbnyXl.js} +0 -0
  73. /package/dist/vendor/{inspector.IgLX3ur5.js → inspector.hPQncR7V.js} +0 -0
  74. /package/dist/vendor/{utils.0uYuCbzo.js → utils.CUjzkRH7.js} +0 -0
@@ -1,10 +1,10 @@
1
1
  import * as vite from 'vite';
2
- import { ViteDevServer, TransformResult as TransformResult$1, UserConfig as UserConfig$1, ConfigEnv, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
2
+ import { TransformResult as TransformResult$1, ViteDevServer, UserConfig as UserConfig$1, ConfigEnv, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
3
3
  import * as _vitest_runner from '@vitest/runner';
4
- import { File, Test as Test$1, Suite, TaskResultPack, Task, CancelReason, Custom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
- import { RawSourceMap, FetchResult, ViteNodeResolveId, ModuleCacheMap, ViteNodeServerOptions } from 'vite-node';
6
- import { SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
7
- import { ExpectStatic } from '@vitest/expect';
4
+ import { File, Test as Test$1, Suite, TaskResultPack, CancelReason, Task, TaskMeta, Custom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
+ import { RawSourceMap, ViteNodeResolveId, FetchResult, ModuleCacheMap, ViteNodeServerOptions } from 'vite-node';
6
+ import { SnapshotResult, SnapshotSummary, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
7
+ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
8
8
  import { ChainableFunction } from '@vitest/runner/utils';
9
9
  import { ParsedStack, Awaitable as Awaitable$1, Arrayable as Arrayable$1 } from '@vitest/utils';
10
10
  import { TaskResult, Bench, Options as Options$1 } from 'tinybench';
@@ -632,13 +632,13 @@ declare class Logger {
632
632
  clearFullScreen(message: string): void;
633
633
  clearScreen(message: string, force?: boolean): void;
634
634
  private _clearScreen;
635
- printError(err: unknown, options?: ErrorOptions): Promise<void>;
635
+ printError(err: unknown, options?: ErrorOptions): void;
636
636
  clearHighlightCache(filename?: string): void;
637
637
  highlight(filename: string, source: string): string;
638
638
  printNoTestFound(filters?: string[]): void;
639
639
  printBanner(): void;
640
- printUnhandledErrors(errors: unknown[]): Promise<void>;
641
- printSourceTypeErrors(errors: TypeCheckError[]): Promise<void>;
640
+ printUnhandledErrors(errors: unknown[]): void;
641
+ printSourceTypeErrors(errors: TypeCheckError[]): void;
642
642
  }
643
643
 
644
644
  interface BrowserProviderInitializationOptions {
@@ -647,8 +647,15 @@ interface BrowserProviderInitializationOptions {
647
647
  }
648
648
  interface BrowserProvider {
649
649
  name: string;
650
+ /**
651
+ * @experimental opt-in into file parallelisation
652
+ */
653
+ supportsParallelism: boolean;
650
654
  getSupportedBrowsers: () => readonly string[];
651
- openPage: (url: string) => Awaitable$1<void>;
655
+ beforeCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
656
+ afterCommand?: (command: string, args: unknown[]) => Awaitable$1<void>;
657
+ getCommandsContext: (contextId: string) => Record<string, unknown>;
658
+ openPage: (contextId: string, url: string) => Promise<void>;
652
659
  close: () => Awaitable$1<void>;
653
660
  initialize(ctx: WorkspaceProject, options: BrowserProviderInitializationOptions): Awaitable$1<void>;
654
661
  }
@@ -668,9 +675,9 @@ interface BrowserConfigOptions {
668
675
  /**
669
676
  * Browser provider
670
677
  *
671
- * @default 'webdriverio'
678
+ * @default 'preview'
672
679
  */
673
- provider?: 'webdriverio' | 'playwright' | 'none' | (string & {});
680
+ provider?: 'webdriverio' | 'playwright' | 'preview' | (string & {});
674
681
  /**
675
682
  * Options that are passed down to a browser provider.
676
683
  * To support type hinting, add one of the types to your tsconfig.json "compilerOptions.types" field:
@@ -694,14 +701,6 @@ interface BrowserConfigOptions {
694
701
  * The default port is 63315.
695
702
  */
696
703
  api?: ApiConfig | number;
697
- /**
698
- * Update ESM imports so they can be spied/stubbed with vi.spyOn.
699
- * Enabled by default when running in browser.
700
- *
701
- * @default false
702
- * @experimental
703
- */
704
- slowHijackESM?: boolean;
705
704
  /**
706
705
  * Isolate test environment after each test
707
706
  *
@@ -709,11 +708,40 @@ interface BrowserConfigOptions {
709
708
  */
710
709
  isolate?: boolean;
711
710
  /**
712
- * Run test files in parallel. Fallbacks to `test.fileParallelism`.
711
+ * Run test files in parallel if provider supports this option
712
+ * This option only has effect in headless mode (enabled in CI by default)
713
713
  *
714
- * @default test.fileParallelism
714
+ * @default // Same as "test.fileParallelism"
715
715
  */
716
716
  fileParallelism?: boolean;
717
+ /**
718
+ * Show Vitest UI
719
+ *
720
+ * @default !process.env.CI
721
+ */
722
+ ui?: boolean;
723
+ /**
724
+ * Default viewport size
725
+ */
726
+ viewport?: {
727
+ /**
728
+ * Width of the viewport
729
+ * @default 414
730
+ */
731
+ width: number;
732
+ /**
733
+ * Height of the viewport
734
+ * @default 896
735
+ */
736
+ height: number;
737
+ };
738
+ /**
739
+ * Directory where screenshots will be saved when page.screenshot() is called
740
+ * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
741
+ * If this is set, it will be resolved relative to the project root.
742
+ * @default __screenshots__
743
+ */
744
+ screenshotDirectory?: string;
717
745
  /**
718
746
  * Scripts injected into the tester iframe.
719
747
  */
@@ -721,7 +749,22 @@ interface BrowserConfigOptions {
721
749
  /**
722
750
  * Scripts injected into the main window.
723
751
  */
724
- indexScripts?: BrowserScript[];
752
+ orchestratorScripts?: BrowserScript[];
753
+ /**
754
+ * Commands that will be executed on the server
755
+ * via the browser `import("@vitest/browser/context").commands` API.
756
+ * @see {@link https://vitest.dev/guide/browser#commands}
757
+ */
758
+ commands?: Record<string, BrowserCommand<any>>;
759
+ }
760
+ interface BrowserCommandContext {
761
+ testPath: string | undefined;
762
+ provider: BrowserProvider;
763
+ project: WorkspaceProject;
764
+ contextId: string;
765
+ }
766
+ interface BrowserCommand<Payload extends unknown[]> {
767
+ (context: BrowserCommandContext, ...payload: Payload): Awaitable$1<any>;
725
768
  }
726
769
  interface BrowserScript {
727
770
  /**
@@ -755,8 +798,159 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
755
798
  enabled: boolean;
756
799
  headless: boolean;
757
800
  isolate: boolean;
801
+ fileParallelism: boolean;
758
802
  api: ApiConfig;
803
+ ui: boolean;
804
+ viewport: {
805
+ width: number;
806
+ height: number;
807
+ };
808
+ }
809
+
810
+ declare class VitestBrowserServerMocker {
811
+ #private;
812
+ mocks: Map<string, {
813
+ sessionId: string;
814
+ mock: string | null | undefined;
815
+ }>;
816
+ constructor(project: WorkspaceProject);
817
+ resolveMock(rawId: string, importer: string, hasFactory: boolean): Promise<{
818
+ type: "factory";
819
+ resolvedId: string;
820
+ mockPath?: undefined;
821
+ } | {
822
+ type: "redirect" | "automock";
823
+ mockPath: string | null;
824
+ resolvedId: string;
825
+ }>;
826
+ private resolveId;
827
+ resolveMockPath(mockPath: string, external: string | null): string | null;
828
+ }
829
+
830
+ type ArgumentsType$1<T> = T extends (...args: infer A) => any ? A : never;
831
+ type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
832
+ type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType$1<T>) => Promise<Awaited<ReturnType$1<T>>>;
833
+ type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
834
+ interface ChannelOptions {
835
+ /**
836
+ * Function to post raw message
837
+ */
838
+ post: (data: any, ...extras: any[]) => any | Promise<any>;
839
+ /**
840
+ * Listener to receive raw message
841
+ */
842
+ on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
843
+ /**
844
+ * Custom function to serialize data
845
+ *
846
+ * by default it passes the data as-is
847
+ */
848
+ serialize?: (data: any) => any;
849
+ /**
850
+ * Custom function to deserialize data
851
+ *
852
+ * by default it passes the data as-is
853
+ */
854
+ deserialize?: (data: any) => any;
855
+ }
856
+ interface EventOptions<Remote> {
857
+ /**
858
+ * Names of remote functions that do not need response.
859
+ */
860
+ eventNames?: (keyof Remote)[];
861
+ /**
862
+ * Maximum timeout for waiting for response, in milliseconds.
863
+ *
864
+ * @default 60_000
865
+ */
866
+ timeout?: number;
867
+ /**
868
+ * Custom resolver to resolve function to be called
869
+ *
870
+ * For advanced use cases only
871
+ */
872
+ resolver?: BirpcResolver;
873
+ /**
874
+ * Custom error handler
875
+ */
876
+ onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
877
+ /**
878
+ * Custom error handler for timeouts
879
+ */
880
+ onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
881
+ }
882
+ type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
883
+ type BirpcFn<T> = PromisifyFn<T> & {
884
+ /**
885
+ * Send event without asking for response
886
+ */
887
+ asEvent: (...args: ArgumentsType$1<T>) => void;
888
+ };
889
+ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
890
+ [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
891
+ } & {
892
+ $functions: LocalFunctions;
893
+ };
894
+
895
+ interface TransformResultWithSource extends TransformResult$1 {
896
+ source?: string;
897
+ }
898
+ interface WebSocketHandlers {
899
+ onCollected: (files?: File[]) => Promise<void>;
900
+ onTaskUpdate: (packs: TaskResultPack[]) => void;
901
+ getFiles: () => File[];
902
+ getTestFiles: () => Promise<[{
903
+ name: string;
904
+ root: string;
905
+ }, file: string][]>;
906
+ getPaths: () => string[];
907
+ getConfig: () => ResolvedConfig;
908
+ getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
909
+ getTransformResult: (projectName: string, id: string, browser?: boolean) => Promise<TransformResultWithSource | undefined>;
910
+ readTestFile: (id: string) => Promise<string | null>;
911
+ saveTestFile: (id: string, content: string) => Promise<void>;
912
+ rerun: (files: string[]) => Promise<void>;
913
+ updateSnapshot: (file?: File) => Promise<void>;
914
+ getUnhandledErrors: () => unknown[];
915
+ }
916
+ interface WebSocketBrowserHandlers {
917
+ resolveSnapshotPath: (testPath: string) => string;
918
+ resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
919
+ onUnhandledError: (error: unknown, type: string) => Promise<void>;
920
+ onCollected: (files?: File[]) => Promise<void>;
921
+ onTaskUpdate: (packs: TaskResultPack[]) => void;
922
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
923
+ onCancel: (reason: CancelReason) => void;
924
+ getCountOfFailedTests: () => number;
925
+ readSnapshotFile: (id: string) => Promise<string | null>;
926
+ saveSnapshotFile: (id: string, content: string) => Promise<void>;
927
+ removeSnapshotFile: (id: string) => Promise<void>;
928
+ sendLog: (log: UserConsoleLog) => void;
929
+ finishBrowserTests: (contextId: string) => void;
930
+ snapshotSaved: (snapshot: SnapshotResult) => void;
931
+ debug: (...args: string[]) => void;
932
+ resolveId: (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
933
+ triggerCommand: <T>(contextId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>;
934
+ resolveMock: (id: string, importer: string, hasFactory: boolean) => Promise<{
935
+ type: 'factory' | 'redirect' | 'automock';
936
+ mockPath?: string | null;
937
+ resolvedId: string;
938
+ }>;
939
+ automock: (id: string) => Promise<string>;
940
+ invalidate: (ids: string[]) => void;
941
+ getBrowserFileSourceMap: (id: string) => Promise<TransformResult$1['map'] | undefined>;
942
+ getProvidedContext: () => ProvidedContext;
943
+ }
944
+ interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected' | 'onSpecsCollected'> {
945
+ onFinishedReportCoverage: () => void;
946
+ }
947
+ interface WebSocketBrowserEvents {
948
+ onCancel: (reason: CancelReason) => void;
949
+ startMocking: (id: string) => Promise<string[]>;
950
+ createTesters: (files: string[]) => Promise<void>;
759
951
  }
952
+ type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
953
+ type WebSocketBrowserRPC = BirpcReturn<WebSocketBrowserEvents, WebSocketBrowserHandlers>;
760
954
 
761
955
  interface InitializeProjectOptions extends UserWorkspaceConfig {
762
956
  workspaceConfigPath: string;
@@ -775,11 +969,16 @@ declare class WorkspaceProject {
775
969
  typechecker?: Typechecker;
776
970
  closingPromise: Promise<unknown> | undefined;
777
971
  browserProvider: BrowserProvider | undefined;
778
- browserState: {
972
+ browserMocker: VitestBrowserServerMocker;
973
+ browserRpc: {
974
+ orchestrators: Map<string, WebSocketBrowserRPC>;
975
+ testers: Map<string, WebSocketBrowserRPC>;
976
+ };
977
+ browserState: Map<string, {
779
978
  files: string[];
780
979
  resolve: () => void;
781
980
  reject: (v: unknown) => void;
782
- } | undefined;
981
+ }>;
783
982
  testFilesList: string[] | null;
784
983
  readonly id: string;
785
984
  readonly tmpDir: string;
@@ -823,11 +1022,12 @@ interface ProcessPool {
823
1022
  runTests: RunWithFiles;
824
1023
  close?: () => Awaitable$1<void>;
825
1024
  }
1025
+ declare function getFilePoolName(project: WorkspaceProject, file: string): Pool;
826
1026
 
827
1027
  type Awaitable<T> = T | PromiseLike<T>;
828
1028
  type Nullable<T> = T | null | undefined;
829
1029
  type Arrayable<T> = T | Array<T>;
830
- type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
1030
+ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
831
1031
  type MutableArray<T extends readonly any[]> = {
832
1032
  -readonly [k in keyof T]: T[k];
833
1033
  };
@@ -856,6 +1056,8 @@ interface Environment {
856
1056
  }
857
1057
  interface UserConsoleLog {
858
1058
  content: string;
1059
+ origin?: string;
1060
+ browser?: boolean;
859
1061
  type: 'stdout' | 'stderr';
860
1062
  taskId?: string;
861
1063
  time: number;
@@ -890,7 +1092,8 @@ declare class StateManager {
890
1092
  collectFiles(files?: File[]): void;
891
1093
  clearFiles(_project: {
892
1094
  config: {
893
- name: string;
1095
+ name: string | undefined;
1096
+ root: string;
894
1097
  };
895
1098
  }, paths?: string[]): void;
896
1099
  updateId(task: Task): void;
@@ -910,6 +1113,7 @@ declare class ResultsCache {
910
1113
  private cachePath;
911
1114
  private version;
912
1115
  private root;
1116
+ constructor(version: string);
913
1117
  getCachePath(): string | null;
914
1118
  setConfig(root: string, config: ResolvedConfig['cache']): void;
915
1119
  getResults(key: string): SuiteResultCache | undefined;
@@ -931,6 +1135,7 @@ declare class FilesStatsCache {
931
1135
  declare class VitestCache {
932
1136
  results: ResultsCache;
933
1137
  stats: FilesStatsCache;
1138
+ constructor(version: string);
934
1139
  getFileTestResults(key: string): SuiteResultCache | undefined;
935
1140
  getFileStats(key: string): {
936
1141
  size: number;
@@ -950,6 +1155,7 @@ interface VitestOptions {
950
1155
  }
951
1156
  declare class Vitest {
952
1157
  readonly mode: VitestRunMode;
1158
+ version: string;
953
1159
  config: ResolvedConfig;
954
1160
  configOverride: Partial<ResolvedConfig>;
955
1161
  server: ViteDevServer;
@@ -986,10 +1192,12 @@ declare class Vitest {
986
1192
  private createCoreProject;
987
1193
  getCoreWorkspaceProject(): WorkspaceProject;
988
1194
  getProjectByTaskId(taskId: string): WorkspaceProject;
1195
+ getProjectByName(name?: string): WorkspaceProject;
989
1196
  private getWorkspaceConfigPath;
990
1197
  private resolveWorkspace;
991
1198
  private initCoverageProvider;
992
1199
  private initBrowserProviders;
1200
+ mergeReports(): Promise<void>;
993
1201
  start(filters?: string[]): Promise<void>;
994
1202
  init(): Promise<void>;
995
1203
  private getTestDependencies;
@@ -997,7 +1205,7 @@ declare class Vitest {
997
1205
  getProjectsByTestFile(file: string): WorkspaceSpec[];
998
1206
  initializeGlobalSetup(paths: WorkspaceSpec[]): Promise<void>;
999
1207
  private initializeDistPath;
1000
- runFiles(paths: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
1208
+ runFiles(specs: WorkspaceSpec[], allTestsRun: boolean): Promise<void>;
1001
1209
  cancelCurrentRun(reason: CancelReason): Promise<void>;
1002
1210
  rerunFiles(files?: string[], trigger?: string): Promise<void>;
1003
1211
  changeProjectName(pattern: string): Promise<void>;
@@ -1024,7 +1232,7 @@ declare class Vitest {
1024
1232
  * Close the thread pool and exit the process
1025
1233
  */
1026
1234
  exit(force?: boolean): Promise<void>;
1027
- report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
1235
+ report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
1028
1236
  getTestFilepaths(): Promise<string[]>;
1029
1237
  globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
1030
1238
  shouldKeepServer(): boolean;
@@ -1046,91 +1254,6 @@ interface TestSequencerConstructor {
1046
1254
  new (ctx: Vitest): TestSequencer;
1047
1255
  }
1048
1256
 
1049
- declare abstract class BaseReporter implements Reporter {
1050
- start: number;
1051
- end: number;
1052
- watchFilters?: string[];
1053
- isTTY: boolean;
1054
- ctx: Vitest;
1055
- private _filesInWatchMode;
1056
- private _lastRunTimeout;
1057
- private _lastRunTimer;
1058
- private _lastRunCount;
1059
- private _timeStart;
1060
- private _offUnhandledRejection?;
1061
- constructor();
1062
- get mode(): VitestRunMode;
1063
- onInit(ctx: Vitest): void;
1064
- relative(path: string): string;
1065
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
1066
- onTaskUpdate(packs: TaskResultPack[]): void;
1067
- onWatcherStart(files?: File[], errors?: unknown[]): Promise<void>;
1068
- private resetLastRunLog;
1069
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1070
- onUserConsoleLog(log: UserConsoleLog): void;
1071
- shouldLog(log: UserConsoleLog): boolean;
1072
- onServerRestart(reason?: string): void;
1073
- reportSummary(files: File[], errors: unknown[]): Promise<void>;
1074
- reportTestSummary(files: File[], errors: unknown[]): Promise<void>;
1075
- private printErrorsSummary;
1076
- reportBenchmarkSummary(files: File[]): Promise<void>;
1077
- private printTaskErrors;
1078
- registerUnhandledRejection(): void;
1079
- }
1080
-
1081
- declare class BasicReporter extends BaseReporter {
1082
- isTTY: boolean;
1083
- reportSummary(files: File[], errors: unknown[]): Promise<void>;
1084
- }
1085
-
1086
- interface ListRendererOptions {
1087
- renderSucceed?: boolean;
1088
- logger: Logger;
1089
- showHeap: boolean;
1090
- slowTestThreshold: number;
1091
- mode: VitestRunMode;
1092
- }
1093
- declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
1094
- start(): any;
1095
- update(_tasks: Task[]): any;
1096
- stop(): Promise<any>;
1097
- clear(): void;
1098
- };
1099
-
1100
- declare class DefaultReporter extends BaseReporter {
1101
- renderer?: ReturnType<typeof createListRenderer>;
1102
- rendererOptions: ListRendererOptions;
1103
- private renderSucceedDefault?;
1104
- onPathsCollected(paths?: string[]): void;
1105
- onTestRemoved(trigger?: string): Promise<void>;
1106
- onCollected(): void;
1107
- onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
1108
- onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
1109
- stopListRender(): Promise<void>;
1110
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1111
- onUserConsoleLog(log: UserConsoleLog): void;
1112
- }
1113
-
1114
- interface DotRendererOptions {
1115
- logger: Logger;
1116
- }
1117
- declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
1118
- start(): any;
1119
- update(_tasks: Task[]): any;
1120
- stop(): Promise<any>;
1121
- clear(): void;
1122
- };
1123
-
1124
- declare class DotReporter extends BaseReporter {
1125
- renderer?: ReturnType<typeof createDotRenderer>;
1126
- onCollected(): void;
1127
- onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
1128
- onWatcherStart(): Promise<void>;
1129
- stopListRender(): Promise<void>;
1130
- onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1131
- onUserConsoleLog(log: UserConsoleLog): void;
1132
- }
1133
-
1134
1257
  type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
1135
1258
  type Milliseconds = number;
1136
1259
  interface Callsite {
@@ -1142,8 +1265,9 @@ interface JsonAssertionResult {
1142
1265
  fullName: string;
1143
1266
  status: Status;
1144
1267
  title: string;
1268
+ meta: TaskMeta;
1145
1269
  duration?: Milliseconds | null;
1146
- failureMessages: Array<string>;
1270
+ failureMessages: Array<string> | null;
1147
1271
  location?: Callsite | null;
1148
1272
  }
1149
1273
  interface JsonTestResult {
@@ -1167,6 +1291,7 @@ interface JsonTestResults {
1167
1291
  startTime: number;
1168
1292
  success: boolean;
1169
1293
  testResults: Array<JsonTestResult>;
1294
+ snapshot: SnapshotSummary;
1170
1295
  }
1171
1296
  interface JsonOptions$1 {
1172
1297
  outputFile?: string;
@@ -1185,19 +1310,14 @@ declare class JsonReporter implements Reporter {
1185
1310
  * @param report
1186
1311
  */
1187
1312
  writeReport(report: string): Promise<void>;
1188
- protected getFailureLocation(test: Task): Promise<Callsite | undefined>;
1189
- }
1190
-
1191
- declare class VerboseReporter extends DefaultReporter {
1192
- constructor();
1193
- onTaskUpdate(packs: TaskResultPack[]): void;
1194
1313
  }
1195
1314
 
1196
1315
  interface Reporter {
1197
1316
  onInit?: (ctx: Vitest) => void;
1198
1317
  onPathsCollected?: (paths?: string[]) => Awaitable<void>;
1318
+ onSpecsCollected?: (specs?: SerializableSpec[]) => Awaitable<void>;
1199
1319
  onCollected?: (files?: File[]) => Awaitable<void>;
1200
- onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
1320
+ onFinished?: (files?: File[], errors?: unknown[], coverage?: unknown) => Awaitable<void>;
1201
1321
  onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
1202
1322
  onTestRemoved?: (trigger?: string) => Awaitable<void>;
1203
1323
  onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
@@ -1207,15 +1327,10 @@ interface Reporter {
1207
1327
  onProcessTimeout?: () => Awaitable<void>;
1208
1328
  }
1209
1329
 
1210
- declare class TapReporter implements Reporter {
1211
- protected ctx: Vitest;
1212
- private logger;
1213
- onInit(ctx: Vitest): void;
1214
- static getComment(task: Task): string;
1215
- private logErrorDetails;
1216
- protected logTasks(tasks: Task[]): void;
1217
- onFinished(files?: _vitest_runner.File[]): Promise<void>;
1218
- }
1330
+ type SerializableSpec = [project: {
1331
+ name: string | undefined;
1332
+ root: string;
1333
+ }, file: string];
1219
1334
 
1220
1335
  interface JUnitOptions {
1221
1336
  outputFile?: string;
@@ -1248,9 +1363,116 @@ declare class JUnitReporter implements Reporter {
1248
1363
  onFinished(files?: _vitest_runner.File[]): Promise<void>;
1249
1364
  }
1250
1365
 
1366
+ interface HTMLOptions {
1367
+ outputFile?: string;
1368
+ }
1369
+
1370
+ interface BaseOptions {
1371
+ isTTY?: boolean;
1372
+ }
1373
+ declare abstract class BaseReporter implements Reporter {
1374
+ start: number;
1375
+ end: number;
1376
+ watchFilters?: string[];
1377
+ isTTY: boolean;
1378
+ ctx: Vitest;
1379
+ private _filesInWatchMode;
1380
+ private _lastRunTimeout;
1381
+ private _lastRunTimer;
1382
+ private _lastRunCount;
1383
+ private _timeStart;
1384
+ private _offUnhandledRejection?;
1385
+ constructor(options?: BaseOptions);
1386
+ get mode(): VitestRunMode;
1387
+ onInit(ctx: Vitest): void;
1388
+ relative(path: string): string;
1389
+ onFinished(files?: File[], errors?: unknown[]): void;
1390
+ onTaskUpdate(packs: TaskResultPack[]): void;
1391
+ onWatcherStart(files?: File[], errors?: unknown[]): void;
1392
+ private resetLastRunLog;
1393
+ onWatcherRerun(files: string[], trigger?: string): void;
1394
+ onUserConsoleLog(log: UserConsoleLog): void;
1395
+ shouldLog(log: UserConsoleLog): boolean;
1396
+ onServerRestart(reason?: string): void;
1397
+ reportSummary(files: File[], errors: unknown[]): void;
1398
+ reportTestSummary(files: File[], errors: unknown[]): void;
1399
+ private printErrorsSummary;
1400
+ reportBenchmarkSummary(files: File[]): void;
1401
+ private printTaskErrors;
1402
+ registerUnhandledRejection(): void;
1403
+ }
1404
+
1405
+ declare class BasicReporter extends BaseReporter {
1406
+ isTTY: boolean;
1407
+ reportSummary(files: File[], errors: unknown[]): void;
1408
+ }
1409
+
1410
+ interface ListRendererOptions {
1411
+ renderSucceed?: boolean;
1412
+ logger: Logger;
1413
+ showHeap: boolean;
1414
+ slowTestThreshold: number;
1415
+ mode: VitestRunMode;
1416
+ }
1417
+ declare function createListRenderer(_tasks: Task[], options: ListRendererOptions): {
1418
+ start(): any;
1419
+ update(_tasks: Task[]): any;
1420
+ stop(): any;
1421
+ clear(): void;
1422
+ };
1423
+
1424
+ declare class DefaultReporter extends BaseReporter {
1425
+ renderer?: ReturnType<typeof createListRenderer>;
1426
+ rendererOptions: ListRendererOptions;
1427
+ private renderSucceedDefault?;
1428
+ onPathsCollected(paths?: string[]): void;
1429
+ onTestRemoved(trigger?: string): Promise<void>;
1430
+ onCollected(): void;
1431
+ onFinished(files?: _vitest_runner.File[], errors?: unknown[]): void;
1432
+ onWatcherStart(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
1433
+ stopListRender(): void;
1434
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1435
+ onUserConsoleLog(log: UserConsoleLog): void;
1436
+ }
1437
+
1438
+ interface DotRendererOptions {
1439
+ logger: Logger;
1440
+ }
1441
+ declare function createDotRenderer(_tasks: Task[], options: DotRendererOptions): {
1442
+ start(): any;
1443
+ update(_tasks: Task[]): any;
1444
+ stop(): Promise<any>;
1445
+ clear(): void;
1446
+ };
1447
+
1448
+ declare class DotReporter extends BaseReporter {
1449
+ renderer?: ReturnType<typeof createDotRenderer>;
1450
+ onCollected(): void;
1451
+ onFinished(files?: _vitest_runner.File[], errors?: unknown[]): Promise<void>;
1452
+ onWatcherStart(): Promise<void>;
1453
+ stopListRender(): Promise<void>;
1454
+ onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1455
+ onUserConsoleLog(log: UserConsoleLog): void;
1456
+ }
1457
+
1458
+ declare class VerboseReporter extends DefaultReporter {
1459
+ constructor();
1460
+ onTaskUpdate(packs: TaskResultPack[]): void;
1461
+ }
1462
+
1463
+ declare class TapReporter implements Reporter {
1464
+ protected ctx: Vitest;
1465
+ private logger;
1466
+ onInit(ctx: Vitest): void;
1467
+ static getComment(task: Task): string;
1468
+ private logErrorDetails;
1469
+ protected logTasks(tasks: Task[]): void;
1470
+ onFinished(files?: _vitest_runner.File[]): void;
1471
+ }
1472
+
1251
1473
  declare class TapFlatReporter extends TapReporter {
1252
1474
  onInit(ctx: Vitest): void;
1253
- onFinished(files?: _vitest_runner.File[]): Promise<void>;
1475
+ onFinished(files?: _vitest_runner.File[]): void;
1254
1476
  }
1255
1477
 
1256
1478
  declare class HangingProcessReporter implements Reporter {
@@ -1262,7 +1484,18 @@ declare class HangingProcessReporter implements Reporter {
1262
1484
  declare class GithubActionsReporter implements Reporter {
1263
1485
  ctx: Vitest;
1264
1486
  onInit(ctx: Vitest): void;
1265
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
1487
+ onFinished(files?: File[], errors?: unknown[]): void;
1488
+ }
1489
+
1490
+ interface BlobOptions {
1491
+ outputFile?: string;
1492
+ }
1493
+ declare class BlobReporter implements Reporter {
1494
+ ctx: Vitest;
1495
+ options: BlobOptions;
1496
+ constructor(options: BlobOptions);
1497
+ onInit(ctx: Vitest): void;
1498
+ onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
1266
1499
  }
1267
1500
 
1268
1501
  interface TableRendererOptions {
@@ -1275,19 +1508,19 @@ interface TableRendererOptions {
1275
1508
  declare function createTableRenderer(_tasks: Task[], options: TableRendererOptions): {
1276
1509
  start(): any;
1277
1510
  update(_tasks: Task[]): any;
1278
- stop(): Promise<any>;
1511
+ stop(): any;
1279
1512
  clear(): void;
1280
1513
  };
1281
1514
 
1282
1515
  declare class TableReporter extends BaseReporter {
1283
1516
  renderer?: ReturnType<typeof createTableRenderer>;
1284
1517
  rendererOptions: TableRendererOptions;
1285
- onTestRemoved(trigger?: string): Promise<void>;
1518
+ onTestRemoved(trigger?: string): void;
1286
1519
  onCollected(): Promise<void>;
1287
1520
  onTaskUpdate(packs: TaskResultPack[]): void;
1288
1521
  onFinished(files?: File[], errors?: unknown[]): Promise<void>;
1289
1522
  onWatcherStart(): Promise<void>;
1290
- stopListRender(): Promise<void>;
1523
+ stopListRender(): void;
1291
1524
  onWatcherRerun(files: string[], trigger?: string): Promise<void>;
1292
1525
  onUserConsoleLog(log: UserConsoleLog): void;
1293
1526
  }
@@ -1297,6 +1530,7 @@ interface FlatBenchmarkReport {
1297
1530
  type FormattedBenchmarkResult = Omit<BenchmarkResult, 'samples'> & {
1298
1531
  id: string;
1299
1532
  sampleCount: number;
1533
+ median: number;
1300
1534
  };
1301
1535
 
1302
1536
  declare const BenchmarkReportsMap: {
@@ -1308,6 +1542,7 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
1308
1542
  declare const ReportersMap: {
1309
1543
  default: typeof DefaultReporter;
1310
1544
  basic: typeof BasicReporter;
1545
+ blob: typeof BlobReporter;
1311
1546
  verbose: typeof VerboseReporter;
1312
1547
  dot: typeof DotReporter;
1313
1548
  json: typeof JsonReporter;
@@ -1319,18 +1554,17 @@ declare const ReportersMap: {
1319
1554
  };
1320
1555
  type BuiltinReporters = keyof typeof ReportersMap;
1321
1556
  interface BuiltinReporterOptions {
1322
- 'default': never;
1323
- 'basic': never;
1557
+ 'default': BaseOptions;
1558
+ 'basic': BaseOptions;
1324
1559
  'verbose': never;
1325
- 'dot': never;
1560
+ 'dot': BaseOptions;
1326
1561
  'json': JsonOptions$1;
1562
+ 'blob': BlobOptions;
1327
1563
  'tap': never;
1328
1564
  'tap-flat': never;
1329
1565
  'junit': JUnitOptions;
1330
1566
  'hanging-process': never;
1331
- 'html': {
1332
- outputFile?: string;
1333
- };
1567
+ 'html': HTMLOptions;
1334
1568
  }
1335
1569
 
1336
1570
  type ChaiConfig = Omit<Partial<typeof chai.config>, 'useProxy' | 'proxyExcludedKeys'>;
@@ -1410,72 +1644,7 @@ interface LinkMapper {
1410
1644
  assetPath(node: Node, name: string): string;
1411
1645
  }
1412
1646
 
1413
- type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
1414
- type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
1415
- type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
1416
- type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
1417
- interface ChannelOptions {
1418
- /**
1419
- * Function to post raw message
1420
- */
1421
- post: (data: any, ...extras: any[]) => any | Promise<any>;
1422
- /**
1423
- * Listener to receive raw message
1424
- */
1425
- on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
1426
- /**
1427
- * Custom function to serialize data
1428
- *
1429
- * by default it passes the data as-is
1430
- */
1431
- serialize?: (data: any) => any;
1432
- /**
1433
- * Custom function to deserialize data
1434
- *
1435
- * by default it passes the data as-is
1436
- */
1437
- deserialize?: (data: any) => any;
1438
- }
1439
- interface EventOptions<Remote> {
1440
- /**
1441
- * Names of remote functions that do not need response.
1442
- */
1443
- eventNames?: (keyof Remote)[];
1444
- /**
1445
- * Maximum timeout for waiting for response, in milliseconds.
1446
- *
1447
- * @default 60_000
1448
- */
1449
- timeout?: number;
1450
- /**
1451
- * Custom resolver to resolve function to be called
1452
- *
1453
- * For advanced use cases only
1454
- */
1455
- resolver?: BirpcResolver;
1456
- /**
1457
- * Custom error handler
1458
- */
1459
- onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
1460
- /**
1461
- * Custom error handler for timeouts
1462
- */
1463
- onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
1464
- }
1465
- type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
1466
- type BirpcFn<T> = PromisifyFn<T> & {
1467
- /**
1468
- * Send event without asking for response
1469
- */
1470
- asEvent(...args: ArgumentsType<T>): void;
1471
- };
1472
- type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
1473
- [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1474
- } & {
1475
- $functions: LocalFunctions;
1476
- };
1477
-
1478
- type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
1647
+ type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M>() => Promise<T>) => any;
1479
1648
  type MockFactory = () => any;
1480
1649
  type MockMap = Map<string, Record<string, string | null | MockFactory>>;
1481
1650
  interface PendingSuiteMock {
@@ -1560,13 +1729,24 @@ interface WorkerGlobalState {
1560
1729
  }
1561
1730
 
1562
1731
  type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
1732
+ type CoverageResults = unknown;
1563
1733
  interface CoverageProvider {
1564
1734
  name: string;
1735
+ /** Called when provider is being initialized before tests run */
1565
1736
  initialize: (ctx: Vitest) => Promise<void> | void;
1737
+ /** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
1566
1738
  resolveOptions: () => ResolvedCoverageOptions;
1739
+ /** Callback to clean previous reports */
1567
1740
  clean: (clean?: boolean) => void | Promise<void>;
1741
+ /** Called with coverage results after a single test file has been run */
1568
1742
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
1569
- reportCoverage: (reportContext?: ReportContext) => void | Promise<void>;
1743
+ /** Callback to generate final coverage results */
1744
+ generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
1745
+ /** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
1746
+ reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
1747
+ /** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
1748
+ mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
1749
+ /** Callback called for instrumenting files with coverage counters. */
1570
1750
  onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
1571
1751
  }
1572
1752
  interface ReportContext {
@@ -1936,7 +2116,7 @@ declare const configDefaults: Readonly<{
1936
2116
  watch: boolean;
1937
2117
  globals: false;
1938
2118
  environment: "node";
1939
- pool: "threads";
2119
+ pool: "forks";
1940
2120
  clearMocks: false;
1941
2121
  restoreMocks: false;
1942
2122
  mockReset: false;
@@ -1945,7 +2125,6 @@ declare const configDefaults: Readonly<{
1945
2125
  testTimeout: number;
1946
2126
  hookTimeout: number;
1947
2127
  teardownTimeout: number;
1948
- watchExclude: string[];
1949
2128
  forceRerunTriggers: string[];
1950
2129
  update: false;
1951
2130
  reporters: never[];
@@ -2370,11 +2549,6 @@ interface InlineConfig {
2370
2549
  * Path to global setup files
2371
2550
  */
2372
2551
  globalSetup?: string | string[];
2373
- /**
2374
- * Glob pattern of file paths to be ignore from triggering watch rerun
2375
- * @deprecated Use server.watch.ignored instead
2376
- */
2377
- watchExclude?: string[];
2378
2552
  /**
2379
2553
  * Glob patter of file paths that will trigger the whole suite rerun
2380
2554
  *
@@ -2490,7 +2664,7 @@ interface InlineConfig {
2490
2664
  /**
2491
2665
  * Custom environment variables assigned to `process.env` before running tests.
2492
2666
  */
2493
- env?: Record<string, string>;
2667
+ env?: Partial<NodeJS.ProcessEnv>;
2494
2668
  /**
2495
2669
  * Options for @sinon/fake-timers
2496
2670
  */
@@ -2602,6 +2776,30 @@ interface InlineConfig {
2602
2776
  */
2603
2777
  waitForDebugger?: boolean;
2604
2778
  };
2779
+ /**
2780
+ * Configuration options for expect() matches.
2781
+ */
2782
+ expect?: {
2783
+ /**
2784
+ * Throw an error if tests don't have any expect() assertions.
2785
+ */
2786
+ requireAssertions?: boolean;
2787
+ /**
2788
+ * Default options for expect.poll()
2789
+ */
2790
+ poll?: {
2791
+ /**
2792
+ * Timeout in milliseconds
2793
+ * @default 1000
2794
+ */
2795
+ timeout?: number;
2796
+ /**
2797
+ * Polling interval in milliseconds
2798
+ * @default 50
2799
+ */
2800
+ interval?: number;
2801
+ };
2802
+ };
2605
2803
  /**
2606
2804
  * Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
2607
2805
  * https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
@@ -2631,6 +2829,12 @@ interface InlineConfig {
2631
2829
  * @default false
2632
2830
  */
2633
2831
  disableConsoleIntercept?: boolean;
2832
+ /**
2833
+ * Always print console stack traces.
2834
+ *
2835
+ * @default false
2836
+ */
2837
+ printConsoleTrace?: boolean;
2634
2838
  /**
2635
2839
  * Include "location" property inside the test definition
2636
2840
  *
@@ -2742,6 +2946,11 @@ interface UserConfig extends InlineConfig {
2742
2946
  * benchmark.outputJson option exposed at the top level for cli
2743
2947
  */
2744
2948
  outputJson?: string;
2949
+ /**
2950
+ * Directory of blob reports to merge
2951
+ * @default '.vitest-reports'
2952
+ */
2953
+ mergeReports?: string;
2745
2954
  }
2746
2955
  interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude'> {
2747
2956
  mode: VitestRunMode;
@@ -2783,7 +2992,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2783
2992
  };
2784
2993
  runner?: string;
2785
2994
  }
2786
- type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'poolOptions' | 'teardownTimeout' | 'silent' | 'watchExclude' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
2995
+ type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' | 'cache' | 'update' | 'reporters' | 'outputFile' | 'poolOptions' | 'teardownTimeout' | 'silent' | 'forceRerunTriggers' | 'testNamePattern' | 'ui' | 'open' | 'uiBase' | 'snapshotFormat' | 'resolveSnapshotPath' | 'passWithNoTests' | 'onConsoleLog' | 'onStackTrace' | 'dangerouslyIgnoreUnhandledErrors' | 'slowTestThreshold' | 'inspect' | 'inspectBrk' | 'deps' | 'coverage'> & {
2787
2996
  sequencer?: Omit<SequenceOptions, 'sequencer' | 'seed'>;
2788
2997
  deps?: Omit<DepsOptions, 'moduleDirectories'>;
2789
2998
  poolOptions?: {
@@ -2792,7 +3001,7 @@ type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' |
2792
3001
  forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
2793
3002
  };
2794
3003
  };
2795
- type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
3004
+ type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
2796
3005
  sequence?: {
2797
3006
  concurrent?: boolean;
2798
3007
  hooks?: SequenceHooks;
@@ -2836,7 +3045,18 @@ declare module '@vitest/expect' {
2836
3045
  environment: VitestEnvironment;
2837
3046
  snapshotState: SnapshotState;
2838
3047
  }
3048
+ interface ExpectPollOptions {
3049
+ interval?: number;
3050
+ timeout?: number;
3051
+ message?: string;
3052
+ }
2839
3053
  interface ExpectStatic {
3054
+ unreachable: (message?: string) => never;
3055
+ soft: <T>(actual: T, message?: string) => Assertion<T>;
3056
+ poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
3057
+ addEqualityTesters: (testers: Array<Tester>) => void;
3058
+ assertions: (expected: number) => void;
3059
+ hasAssertions: () => void;
2840
3060
  addSnapshotSerializer: (plugin: Plugin_2) => void;
2841
3061
  }
2842
3062
  interface Assertion<T> {
@@ -2894,4 +3114,4 @@ type Context = RootAndTarget & {
2894
3114
  lastActivePath?: string;
2895
3115
  };
2896
3116
 
2897
- export { type ProjectConfig as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageOptions as C, type RootAndTarget as D, type Environment as E, type FakeTimerInstallOpts as F, type Context as G, type Pool as H, type PoolOptions as I, type JSDOMOptions as J, type HappyDOMOptions as K, type BuiltinEnvironment as L, type MockFactoryWithHelper as M, type VitestEnvironment as N, type CSSModuleScopeStrategy as O, type ProvidedContext as P, type ApiConfig as Q, type ResolvedConfig as R, type EnvironmentOptions as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkerGlobalState as W, type DepsOptimizationOptions as X, type TransformModePatterns as Y, type InlineConfig as Z, type TypecheckConfig as _, type ResolvedCoverageOptions as a, type BrowserConfigOptions as a0, type UserWorkspaceConfig as a1, type RunnerRPC as a2, type ContextTestEnvironment as a3, type ResolvedTestEnvironment as a4, type ResolveIdFunction as a5, type WorkerRPC as a6, type Awaitable as a7, type Nullable as a8, type Arrayable as a9, defineConfig as aA, defineProject as aB, defineWorkspace as aC, configDefaults as aD, defaultInclude as aE, defaultExclude as aF, coverageConfigDefaults as aG, extraInlineDeps as aH, DefaultReporter as aI, BasicReporter as aJ, DotReporter as aK, JsonReporter as aL, VerboseReporter as aM, TapReporter as aN, JUnitReporter as aO, TapFlatReporter as aP, HangingProcessReporter as aQ, GithubActionsReporter as aR, BaseReporter as aS, ReportersMap as aT, type BuiltinReporters as aU, type BuiltinReporterOptions as aV, type JsonAssertionResult as aW, type JsonTestResult as aX, type JsonTestResults as aY, BenchmarkReportsMap as aZ, type BenchmarkBuiltinReporters as a_, type ArgumentsType$1 as aa, type MutableArray as ab, type Constructable as ac, type ModuleCache as ad, type EnvironmentReturn as ae, type VmEnvironmentReturn as af, type OnServerRestartHandler as ag, type ReportContext as ah, type CoverageReporter as ai, type CoverageIstanbulOptions as aj, type CoverageV8Options as ak, type CustomProviderOptions as al, type BenchmarkUserOptions as am, type Benchmark as an, type BenchmarkResult as ao, type BenchFunction as ap, type BenchmarkAPI as aq, type PendingSuiteMock as ar, type MockFactory as as, type MockMap as at, type UserConfigFnObject as au, type UserConfigFnPromise as av, type UserConfigFn as aw, type UserConfigExport as ax, type UserProjectConfigFn as ay, type UserProjectConfigExport as az, type CoverageProvider as b, type CoverageProviderModule as c, type BirpcOptions as d, type RuntimeRPC as e, type ContextRPC as f, type WorkerContext as g, type VitestOptions as h, Vitest as i, WorkspaceProject as j, type WorkspaceSpec as k, type ProcessPool as l, VitestPackageInstaller as m, type TestSequencerConstructor as n, type BrowserProviderInitializationOptions as o, type BrowserProvider as p, type BrowserProviderOptions as q, type BrowserScript as r, type RuntimeConfig as s, type UserConsoleLog as t, type ModuleGraphData as u, type Reporter as v, type RawErrsMap as w, type TscErrorInfo as x, type CollectLineNumbers as y, type CollectLines as z };
3117
+ export { type ArgumentsType as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageOptions as C, type DepsOptimizationOptions as D, type Environment as E, type FakeTimerInstallOpts as F, type ContextTestEnvironment as G, type HappyDOMOptions as H, type InlineConfig as I, type JSDOMOptions as J, type ResolvedTestEnvironment as K, Vitest as L, type MockFactoryWithHelper as M, type Reporter as N, type ResolveIdFunction as O, type ProvidedContext as P, type AfterSuiteRunMeta as Q, type ResolvedConfig as R, type SerializableSpec as S, type TscErrorInfo as T, type UserConfig as U, type VitestEnvironment as V, type WorkerGlobalState as W, type WorkerRPC as X, type Awaitable as Y, type Nullable as Z, type Arrayable as _, type ResolvedCoverageOptions as a, TapReporter as a$, type MutableArray as a0, type Constructable as a1, type ModuleCache as a2, type EnvironmentReturn as a3, type VmEnvironmentReturn as a4, type UserConsoleLog as a5, type ModuleGraphData as a6, type OnServerRestartHandler as a7, type ReportContext as a8, type CoverageReporter as a9, type BrowserCommand as aA, type BrowserCommandContext as aB, type JsonOptions$1 as aC, type JUnitOptions as aD, type HTMLOptions as aE, type PendingSuiteMock as aF, type MockFactory as aG, type MockMap as aH, type UserConfigFnObject as aI, type UserConfigFnPromise as aJ, type UserConfigFn as aK, type UserConfigExport as aL, type UserProjectConfigFn as aM, type UserProjectConfigExport as aN, defineConfig as aO, defineProject as aP, defineWorkspace as aQ, configDefaults as aR, defaultInclude as aS, defaultExclude as aT, coverageConfigDefaults as aU, extraInlineDeps as aV, DefaultReporter as aW, BasicReporter as aX, DotReporter as aY, JsonReporter as aZ, VerboseReporter as a_, type CoverageIstanbulOptions as aa, type CoverageV8Options as ab, type CustomProviderOptions as ac, type BenchmarkUserOptions as ad, type Benchmark as ae, type BenchmarkResult as af, type BenchFunction as ag, type BenchmarkAPI as ah, type TransformResultWithSource as ai, type WebSocketHandlers as aj, type WebSocketBrowserHandlers as ak, type WebSocketEvents as al, type WebSocketBrowserEvents as am, type WebSocketRPC as an, type WebSocketBrowserRPC as ao, type VitestOptions as ap, WorkspaceProject as aq, type TestSequencer as ar, type WorkspaceSpec as as, type ProcessPool as at, getFilePoolName as au, VitestPackageInstaller as av, type TestSequencerConstructor as aw, type BrowserProviderInitializationOptions as ax, type BrowserProvider as ay, type BrowserProviderOptions as az, type CoverageProvider as b, JUnitReporter as b0, TapFlatReporter as b1, HangingProcessReporter as b2, GithubActionsReporter as b3, BaseReporter as b4, ReportersMap as b5, type BuiltinReporters as b6, type BuiltinReporterOptions as b7, type JsonAssertionResult as b8, type JsonTestResult as b9, type JsonTestResults as ba, BenchmarkReportsMap as bb, type BenchmarkBuiltinReporters as bc, type CoverageProviderModule as c, type BirpcOptions as d, type RuntimeRPC as e, type ContextRPC as f, type WorkerContext as g, type RuntimeConfig as h, type RawErrsMap as i, type CollectLineNumbers as j, type CollectLines as k, type RootAndTarget as l, type Context as m, type Pool as n, type PoolOptions as o, type BuiltinEnvironment as p, type CSSModuleScopeStrategy as q, type EnvironmentOptions as r, type VitestRunMode as s, type TransformModePatterns as t, type TypecheckConfig as u, type ProjectConfig as v, type BrowserScript as w, type BrowserConfigOptions as x, type UserWorkspaceConfig as y, type RunnerRPC as z };