vitest 2.0.0-beta.3 → 2.0.0-beta.6

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 (44) hide show
  1. package/dist/browser.d.ts +5 -1
  2. package/dist/browser.js +18 -2
  3. package/dist/chunks/{integrations-globals.D0I8wu4f.js → integrations-globals.BK0Cn4q1.js} +3 -4
  4. package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.DiVMr5d4.js} +54 -24
  5. package/dist/chunks/{runtime-runBaseTests.CsxVA4nP.js → runtime-runBaseTests.C-Bkopka.js} +5 -6
  6. package/dist/cli.js +2 -2
  7. package/dist/config.d.ts +1 -1
  8. package/dist/coverage.d.ts +1 -1
  9. package/dist/environments.d.ts +1 -1
  10. package/dist/execute.d.ts +2 -2
  11. package/dist/execute.js +1 -1
  12. package/dist/index-Bp1kcIfF.d.ts +1571 -0
  13. package/dist/index.d.ts +6 -1448
  14. package/dist/index.js +3 -4
  15. package/dist/node.d.ts +2 -6
  16. package/dist/node.js +6 -6
  17. package/dist/{reporters-C-3dxOaA.d.ts → reporters-qky6mwBH.d.ts} +237 -91
  18. package/dist/reporters.d.ts +1 -1
  19. package/dist/reporters.js +4 -4
  20. package/dist/runners.d.ts +2 -1
  21. package/dist/runners.js +6 -1
  22. package/dist/{suite-V5kCKZme.d.ts → suite-B5_jYIf8.d.ts} +1 -1
  23. package/dist/suite.d.ts +2 -2
  24. package/dist/vendor/{base.CfOCwoIE.js → base.D4XK-wRp.js} +2 -2
  25. package/dist/vendor/{cac.f5m2SesE.js → cac.DDQuPgBf.js} +47 -16
  26. package/dist/vendor/{cli-api.pZNNj7LX.js → cli-api.C0OPqjkb.js} +372 -200
  27. package/dist/vendor/{constants.XmjJgDXx.js → constants.TCjCaw2D.js} +2 -1
  28. package/dist/vendor/{execute.Bwzklsfj.js → execute.BHj6OMh4.js} +2 -2
  29. package/dist/vendor/{index.DOAUPIJU.js → index.CyGfDRbW.js} +34 -14
  30. package/dist/vendor/{index.BHPXakMe.js → index.DHRpy7zp.js} +1 -1
  31. package/dist/vendor/{index.BkeKAX-R.js → index.DwR86H5i.js} +26 -3
  32. package/dist/vendor/{setup-common.6St9QHh1.js → setup-common.BhJvzjns.js} +2 -2
  33. package/dist/vendor/{utils.D5gGkwyH.js → utils.YuQ3LT2a.js} +1 -1
  34. package/dist/vendor/{vi.B31D70yH.js → vi.C6AfDXK6.js} +23 -11
  35. package/dist/vendor/{vm.rKHnSoLJ.js → vm.Ow-X2mkS.js} +2 -2
  36. package/dist/workers/forks.js +2 -2
  37. package/dist/workers/runVmTests.js +4 -5
  38. package/dist/workers/threads.js +2 -2
  39. package/dist/workers/vmForks.js +3 -3
  40. package/dist/workers/vmThreads.js +3 -3
  41. package/dist/workers.d.ts +1 -1
  42. package/dist/workers.js +4 -4
  43. package/package.json +9 -9
  44. package/dist/vendor/run-once.DLomgGUH.js +0 -27
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
2
  export { b as bench } from './vendor/benchmark.BNLebNi5.js';
3
- export { i as isFirstRun, a as runOnce } from './vendor/run-once.DLomgGUH.js';
4
- export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.B31D70yH.js';
5
- import { d as dist } from './vendor/index.BkeKAX-R.js';
6
- export { b as assertType, g as getRunningMode, i as inject, a as isWatchMode } from './vendor/index.BkeKAX-R.js';
3
+ import { d as dist } from './vendor/index.DwR86H5i.js';
4
+ export { e as assertType, g as getRunningMode, b as inject, i as isFirstRun, c as isWatchMode, a as runOnce } from './vendor/index.DwR86H5i.js';
5
+ export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.C6AfDXK6.js';
7
6
  import * as chai from 'chai';
8
7
  export { chai };
9
8
  export { assert, should } from 'chai';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VitestRunMode, U as UserConfig, h as VitestOptions, i as Vitest, R as ResolvedConfig, P as ProvidedContext, j as WorkspaceProject, e as RuntimeRPC, T as TestSequencer, k as WorkspaceSpec } from './reporters-C-3dxOaA.js';
2
- export { s as BrowserCommand, p as BrowserProvider, o as BrowserProviderInitializationOptions, q as BrowserProviderOptions, r as BrowserScript, H as HTMLOptions, t as JUnitOptions, J as JsonOptions, l as ProcessPool, n as TestSequencerConstructor, m as VitestPackageInstaller } from './reporters-C-3dxOaA.js';
1
+ import { V as VitestRunMode, U as UserConfig, h as VitestOptions, i as Vitest, R as ResolvedConfig, P as ProvidedContext, j as WorkspaceProject, e as RuntimeRPC, T as TestSequencer, k as WorkspaceSpec } from './reporters-qky6mwBH.js';
2
+ export { s as BrowserCommand, p as BrowserProvider, o as BrowserProviderInitializationOptions, q as BrowserProviderOptions, r as BrowserScript, H as HTMLOptions, t as JUnitOptions, J as JsonOptions, l as ProcessPool, n as TestSequencerConstructor, m as VitestPackageInstaller } from './reporters-qky6mwBH.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  export { isFileServingAllowed } from 'vite';
5
5
  import { Writable } from 'node:stream';
@@ -26,10 +26,6 @@ interface CliOptions extends UserConfig {
26
26
  * Override the watch mode
27
27
  */
28
28
  run?: boolean;
29
- /**
30
- * Retry the test suite if it crashes due to a segfault (default: true)
31
- */
32
- segfaultRetry?: number;
33
29
  /**
34
30
  * Removes colors from the console output
35
31
  */
package/dist/node.js CHANGED
@@ -1,9 +1,9 @@
1
- export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.pZNNj7LX.js';
2
- export { p as parseCLI } from './vendor/cac.f5m2SesE.js';
3
- export { B as BaseSequencer } from './vendor/index.DOAUPIJU.js';
1
+ export { b as VitestPackageInstaller, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/cli-api.C0OPqjkb.js';
2
+ export { p as parseCLI } from './vendor/cac.DDQuPgBf.js';
3
+ export { B as BaseSequencer } from './vendor/index.CyGfDRbW.js';
4
4
  export { isFileServingAllowed } from 'vite';
5
5
  import 'pathe';
6
- import './vendor/constants.XmjJgDXx.js';
6
+ import './vendor/constants.TCjCaw2D.js';
7
7
  import './vendor/coverage.ChSqD-qS.js';
8
8
  import './vendor/index.DeR1hhfY.js';
9
9
  import 'node:console';
@@ -52,14 +52,14 @@ import 'node:util';
52
52
  import 'vite-node/utils';
53
53
  import 'magic-string';
54
54
  import '@vitest/utils/ast';
55
- import './vendor/utils.D5gGkwyH.js';
56
55
  import './vendor/index._7XLd8Kd.js';
57
56
  import './vendor/global.7bFbnyXl.js';
58
57
  import 'node:readline';
59
58
  import 'readline';
59
+ import './vendor/utils.YuQ3LT2a.js';
60
60
  import './vendor/tasks.WC7M-K-v.js';
61
61
  import 'node:perf_hooks';
62
- import './chunks/runtime-console.CUES-L8X.js';
62
+ import './chunks/runtime-console.DiVMr5d4.js';
63
63
  import 'node:stream';
64
64
  import './vendor/date.BKM1wewY.js';
65
65
  import 'execa';
@@ -1,9 +1,9 @@
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 { SnapshotSummary, SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
4
+ import { File, Test as Test$1, Suite, TaskResultPack, CancelReason, Task, 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
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';
@@ -694,14 +694,6 @@ interface BrowserConfigOptions {
694
694
  * The default port is 63315.
695
695
  */
696
696
  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
697
  /**
706
698
  * Isolate test environment after each test
707
699
  *
@@ -709,11 +701,26 @@ interface BrowserConfigOptions {
709
701
  */
710
702
  isolate?: boolean;
711
703
  /**
712
- * Run test files in parallel. Fallbacks to `test.fileParallelism`.
704
+ * Show Vitest UI
713
705
  *
714
- * @default test.fileParallelism
706
+ * @default !process.env.CI
715
707
  */
716
- fileParallelism?: boolean;
708
+ ui?: boolean;
709
+ /**
710
+ * Default viewport size
711
+ */
712
+ viewport?: {
713
+ /**
714
+ * Width of the viewport
715
+ * @default 414
716
+ */
717
+ width: number;
718
+ /**
719
+ * Height of the viewport
720
+ * @default 896
721
+ */
722
+ height: number;
723
+ };
717
724
  /**
718
725
  * Scripts injected into the tester iframe.
719
726
  */
@@ -770,7 +777,162 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
770
777
  headless: boolean;
771
778
  isolate: boolean;
772
779
  api: ApiConfig;
780
+ ui: boolean;
781
+ viewport: {
782
+ width: number;
783
+ height: number;
784
+ };
785
+ }
786
+
787
+ declare class VitestBrowserServerMocker {
788
+ #private;
789
+ mocks: Map<string, {
790
+ sessionId: string;
791
+ mock: string | null | undefined;
792
+ }>;
793
+ constructor(project: WorkspaceProject);
794
+ mock(sessionId: string, rawId: string, importer: string, hasFactory: boolean): Promise<string>;
795
+ unmock(rawId: string, importer: string): Promise<string>;
796
+ resolveMock(rawId: string, importer: string, hasFactory: boolean): Promise<{
797
+ type: "factory";
798
+ resolvedId: string;
799
+ mockPath?: undefined;
800
+ } | {
801
+ type: "redirect" | "automock";
802
+ mockPath: string | null;
803
+ resolvedId: string;
804
+ }>;
805
+ invalidateModuleById(id: string): void;
806
+ private resolveId;
807
+ resolveMockPath(mockPath: string, external: string | null): string | null;
808
+ }
809
+
810
+ type ArgumentsType$1<T> = T extends (...args: infer A) => any ? A : never;
811
+ type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
812
+ type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType$1<T>) => Promise<Awaited<ReturnType$1<T>>>;
813
+ type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
814
+ interface ChannelOptions {
815
+ /**
816
+ * Function to post raw message
817
+ */
818
+ post: (data: any, ...extras: any[]) => any | Promise<any>;
819
+ /**
820
+ * Listener to receive raw message
821
+ */
822
+ on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
823
+ /**
824
+ * Custom function to serialize data
825
+ *
826
+ * by default it passes the data as-is
827
+ */
828
+ serialize?: (data: any) => any;
829
+ /**
830
+ * Custom function to deserialize data
831
+ *
832
+ * by default it passes the data as-is
833
+ */
834
+ deserialize?: (data: any) => any;
835
+ }
836
+ interface EventOptions<Remote> {
837
+ /**
838
+ * Names of remote functions that do not need response.
839
+ */
840
+ eventNames?: (keyof Remote)[];
841
+ /**
842
+ * Maximum timeout for waiting for response, in milliseconds.
843
+ *
844
+ * @default 60_000
845
+ */
846
+ timeout?: number;
847
+ /**
848
+ * Custom resolver to resolve function to be called
849
+ *
850
+ * For advanced use cases only
851
+ */
852
+ resolver?: BirpcResolver;
853
+ /**
854
+ * Custom error handler
855
+ */
856
+ onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
857
+ /**
858
+ * Custom error handler for timeouts
859
+ */
860
+ onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
861
+ }
862
+ type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
863
+ type BirpcFn<T> = PromisifyFn<T> & {
864
+ /**
865
+ * Send event without asking for response
866
+ */
867
+ asEvent: (...args: ArgumentsType$1<T>) => void;
868
+ };
869
+ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
870
+ [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
871
+ } & {
872
+ $functions: LocalFunctions;
873
+ };
874
+
875
+ interface TransformResultWithSource extends TransformResult$1 {
876
+ source?: string;
877
+ }
878
+ interface WebSocketHandlers {
879
+ onCollected: (files?: File[]) => Promise<void>;
880
+ onTaskUpdate: (packs: TaskResultPack[]) => void;
881
+ getFiles: () => File[];
882
+ getTestFiles: () => Promise<[{
883
+ name: string;
884
+ root: string;
885
+ }, file: string][]>;
886
+ getPaths: () => string[];
887
+ getConfig: () => ResolvedConfig;
888
+ getModuleGraph: (projectName: string, id: string, browser?: boolean) => Promise<ModuleGraphData>;
889
+ getTransformResult: (id: string) => Promise<TransformResultWithSource | undefined>;
890
+ readTestFile: (id: string) => Promise<string | null>;
891
+ saveTestFile: (id: string, content: string) => Promise<void>;
892
+ rerun: (files: string[]) => Promise<void>;
893
+ updateSnapshot: (file?: File) => Promise<void>;
894
+ getUnhandledErrors: () => unknown[];
895
+ }
896
+ interface WebSocketBrowserHandlers {
897
+ resolveSnapshotPath: (testPath: string) => string;
898
+ resolveSnapshotRawPath: (testPath: string, rawPath: string) => string;
899
+ onUnhandledError: (error: unknown, type: string) => Promise<void>;
900
+ onCollected: (files?: File[]) => Promise<void>;
901
+ onTaskUpdate: (packs: TaskResultPack[]) => void;
902
+ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
903
+ onCancel: (reason: CancelReason) => void;
904
+ getCountOfFailedTests: () => number;
905
+ readSnapshotFile: (id: string) => Promise<string | null>;
906
+ saveSnapshotFile: (id: string, content: string) => Promise<void>;
907
+ removeSnapshotFile: (id: string) => Promise<void>;
908
+ sendLog: (log: UserConsoleLog) => void;
909
+ finishBrowserTests: () => void;
910
+ snapshotSaved: (snapshot: SnapshotResult) => void;
911
+ getBrowserFiles: () => string[];
912
+ debug: (...args: string[]) => void;
913
+ resolveId: (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
914
+ triggerCommand: (command: string, testPath: string | undefined, payload: unknown[]) => Promise<void>;
915
+ queueMock: (id: string, importer: string, hasFactory: boolean) => Promise<string>;
916
+ queueUnmock: (id: string, importer: string) => Promise<string>;
917
+ resolveMock: (id: string, importer: string) => Promise<{
918
+ type: 'factory' | 'redirect' | 'automock';
919
+ mockPath?: string | null;
920
+ resolvedId: string;
921
+ }>;
922
+ invalidateMocks: () => void;
923
+ getBrowserFileSourceMap: (id: string) => Promise<TransformResult$1['map'] | undefined>;
924
+ getProvidedContext: () => ProvidedContext;
925
+ }
926
+ interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog' | 'onPathsCollected' | 'onSpecsCollected'> {
927
+ onFinishedReportCoverage: () => void;
773
928
  }
929
+ interface WebSocketBrowserEvents {
930
+ onCancel: (reason: CancelReason) => void;
931
+ startMocking: (id: string) => Promise<string[]>;
932
+ createTesters: (files: string[]) => Promise<void>;
933
+ }
934
+ type WebSocketRPC = BirpcReturn<WebSocketEvents, WebSocketHandlers>;
935
+ type WebSocketBrowserRPC = BirpcReturn<WebSocketBrowserEvents, WebSocketBrowserHandlers>;
774
936
 
775
937
  interface InitializeProjectOptions extends UserWorkspaceConfig {
776
938
  workspaceConfigPath: string;
@@ -789,6 +951,11 @@ declare class WorkspaceProject {
789
951
  typechecker?: Typechecker;
790
952
  closingPromise: Promise<unknown> | undefined;
791
953
  browserProvider: BrowserProvider | undefined;
954
+ browserMocker: VitestBrowserServerMocker;
955
+ browserRpc: {
956
+ orchestrators: Map<string, WebSocketBrowserRPC>;
957
+ testers: Map<string, WebSocketBrowserRPC>;
958
+ };
792
959
  browserState: {
793
960
  files: string[];
794
961
  resolve: () => void;
@@ -841,7 +1008,7 @@ interface ProcessPool {
841
1008
  type Awaitable<T> = T | PromiseLike<T>;
842
1009
  type Nullable<T> = T | null | undefined;
843
1010
  type Arrayable<T> = T | Array<T>;
844
- type ArgumentsType$1<T> = T extends (...args: infer U) => any ? U : never;
1011
+ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
845
1012
  type MutableArray<T extends readonly any[]> = {
846
1013
  -readonly [k in keyof T]: T[k];
847
1014
  };
@@ -870,6 +1037,8 @@ interface Environment {
870
1037
  }
871
1038
  interface UserConsoleLog {
872
1039
  content: string;
1040
+ origin?: string;
1041
+ browser?: boolean;
873
1042
  type: 'stdout' | 'stderr';
874
1043
  taskId?: string;
875
1044
  time: number;
@@ -904,7 +1073,7 @@ declare class StateManager {
904
1073
  collectFiles(files?: File[]): void;
905
1074
  clearFiles(_project: {
906
1075
  config: {
907
- name: string;
1076
+ name: string | undefined;
908
1077
  root: string;
909
1078
  };
910
1079
  }, paths?: string[]): void;
@@ -1004,7 +1173,7 @@ declare class Vitest {
1004
1173
  private createCoreProject;
1005
1174
  getCoreWorkspaceProject(): WorkspaceProject;
1006
1175
  getProjectByTaskId(taskId: string): WorkspaceProject;
1007
- getProjectByName(name: string): WorkspaceProject;
1176
+ getProjectByName(name?: string): WorkspaceProject;
1008
1177
  private getWorkspaceConfigPath;
1009
1178
  private resolveWorkspace;
1010
1179
  private initCoverageProvider;
@@ -1044,7 +1213,7 @@ declare class Vitest {
1044
1213
  * Close the thread pool and exit the process
1045
1214
  */
1046
1215
  exit(force?: boolean): Promise<void>;
1047
- report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
1216
+ report<T extends keyof Reporter>(name: T, ...args: ArgumentsType<Reporter[T]>): Promise<void>;
1048
1217
  getTestFilepaths(): Promise<string[]>;
1049
1218
  globTestFiles(filters?: string[]): Promise<WorkspaceSpec[]>;
1050
1219
  shouldKeepServer(): boolean;
@@ -1128,7 +1297,7 @@ interface Reporter {
1128
1297
  onPathsCollected?: (paths?: string[]) => Awaitable<void>;
1129
1298
  onSpecsCollected?: (specs?: SerializableSpec[]) => Awaitable<void>;
1130
1299
  onCollected?: (files?: File[]) => Awaitable<void>;
1131
- onFinished?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
1300
+ onFinished?: (files?: File[], errors?: unknown[], coverage?: unknown) => Awaitable<void>;
1132
1301
  onTaskUpdate?: (packs: TaskResultPack[]) => Awaitable<void>;
1133
1302
  onTestRemoved?: (trigger?: string) => Awaitable<void>;
1134
1303
  onWatcherStart?: (files?: File[], errors?: unknown[]) => Awaitable<void>;
@@ -1139,7 +1308,7 @@ interface Reporter {
1139
1308
  }
1140
1309
 
1141
1310
  type SerializableSpec = [project: {
1142
- name: string;
1311
+ name: string | undefined;
1143
1312
  root: string;
1144
1313
  }, file: string];
1145
1314
 
@@ -1306,7 +1475,7 @@ declare class BlobReporter implements Reporter {
1306
1475
  options: BlobOptions;
1307
1476
  constructor(options: BlobOptions);
1308
1477
  onInit(ctx: Vitest): void;
1309
- onFinished(files?: File[], errors?: unknown[]): Promise<void>;
1478
+ onFinished(files: File[] | undefined, errors: unknown[] | undefined, coverage: unknown): Promise<void>;
1310
1479
  }
1311
1480
 
1312
1481
  interface TableRendererOptions {
@@ -1341,6 +1510,7 @@ interface FlatBenchmarkReport {
1341
1510
  type FormattedBenchmarkResult = Omit<BenchmarkResult, 'samples'> & {
1342
1511
  id: string;
1343
1512
  sampleCount: number;
1513
+ median: number;
1344
1514
  };
1345
1515
 
1346
1516
  declare const BenchmarkReportsMap: {
@@ -1454,71 +1624,6 @@ interface LinkMapper {
1454
1624
  assetPath(node: Node, name: string): string;
1455
1625
  }
1456
1626
 
1457
- type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
1458
- type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
1459
- type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
1460
- type BirpcResolver = (name: string, resolved: (...args: unknown[]) => unknown) => ((...args: unknown[]) => unknown) | undefined;
1461
- interface ChannelOptions {
1462
- /**
1463
- * Function to post raw message
1464
- */
1465
- post: (data: any, ...extras: any[]) => any | Promise<any>;
1466
- /**
1467
- * Listener to receive raw message
1468
- */
1469
- on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
1470
- /**
1471
- * Custom function to serialize data
1472
- *
1473
- * by default it passes the data as-is
1474
- */
1475
- serialize?: (data: any) => any;
1476
- /**
1477
- * Custom function to deserialize data
1478
- *
1479
- * by default it passes the data as-is
1480
- */
1481
- deserialize?: (data: any) => any;
1482
- }
1483
- interface EventOptions<Remote> {
1484
- /**
1485
- * Names of remote functions that do not need response.
1486
- */
1487
- eventNames?: (keyof Remote)[];
1488
- /**
1489
- * Maximum timeout for waiting for response, in milliseconds.
1490
- *
1491
- * @default 60_000
1492
- */
1493
- timeout?: number;
1494
- /**
1495
- * Custom resolver to resolve function to be called
1496
- *
1497
- * For advanced use cases only
1498
- */
1499
- resolver?: BirpcResolver;
1500
- /**
1501
- * Custom error handler
1502
- */
1503
- onError?: (error: Error, functionName: string, args: any[]) => boolean | void;
1504
- /**
1505
- * Custom error handler for timeouts
1506
- */
1507
- onTimeoutError?: (functionName: string, args: any[]) => boolean | void;
1508
- }
1509
- type BirpcOptions<Remote> = EventOptions<Remote> & ChannelOptions;
1510
- type BirpcFn<T> = PromisifyFn<T> & {
1511
- /**
1512
- * Send event without asking for response
1513
- */
1514
- asEvent: (...args: ArgumentsType<T>) => void;
1515
- };
1516
- type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
1517
- [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
1518
- } & {
1519
- $functions: LocalFunctions;
1520
- };
1521
-
1522
1627
  type MockFactoryWithHelper<M = unknown> = (importOriginal: <T extends M>() => Promise<T>) => any;
1523
1628
  type MockFactory = () => any;
1524
1629
  type MockMap = Map<string, Record<string, string | null | MockFactory>>;
@@ -1604,13 +1709,24 @@ interface WorkerGlobalState {
1604
1709
  }
1605
1710
 
1606
1711
  type TransformResult = string | Partial<TransformResult$1> | undefined | null | void;
1712
+ type CoverageResults = unknown;
1607
1713
  interface CoverageProvider {
1608
1714
  name: string;
1715
+ /** Called when provider is being initialized before tests run */
1609
1716
  initialize: (ctx: Vitest) => Promise<void> | void;
1717
+ /** Called when setting coverage options for Vitest context (`ctx.config.coverage`) */
1610
1718
  resolveOptions: () => ResolvedCoverageOptions;
1719
+ /** Callback to clean previous reports */
1611
1720
  clean: (clean?: boolean) => void | Promise<void>;
1721
+ /** Called with coverage results after a single test file has been run */
1612
1722
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
1613
- reportCoverage: (reportContext?: ReportContext) => void | Promise<void>;
1723
+ /** Callback to generate final coverage results */
1724
+ generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
1725
+ /** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
1726
+ reportCoverage: (coverage: CoverageResults, reportContext: ReportContext) => void | Promise<void>;
1727
+ /** Callback for `--merge-reports` options. Called with multiple coverage results generated by `generateCoverage`. */
1728
+ mergeReports?: (coverages: CoverageResults[]) => void | Promise<void>;
1729
+ /** Callback called for instrumenting files with coverage counters. */
1614
1730
  onFileTransform?: (sourceCode: string, id: string, pluginCtx: any) => TransformResult | Promise<TransformResult>;
1615
1731
  }
1616
1732
  interface ReportContext {
@@ -2528,7 +2644,7 @@ interface InlineConfig {
2528
2644
  /**
2529
2645
  * Custom environment variables assigned to `process.env` before running tests.
2530
2646
  */
2531
- env?: Record<string, string>;
2647
+ env?: Partial<NodeJS.ProcessEnv>;
2532
2648
  /**
2533
2649
  * Options for @sinon/fake-timers
2534
2650
  */
@@ -2640,6 +2756,30 @@ interface InlineConfig {
2640
2756
  */
2641
2757
  waitForDebugger?: boolean;
2642
2758
  };
2759
+ /**
2760
+ * Configuration options for expect() matches.
2761
+ */
2762
+ expect?: {
2763
+ /**
2764
+ * Throw an error if tests don't have any expect() assertions.
2765
+ */
2766
+ requireAssertions?: boolean;
2767
+ /**
2768
+ * Default options for expect.poll()
2769
+ */
2770
+ poll?: {
2771
+ /**
2772
+ * Timeout in milliseconds
2773
+ * @default 1000
2774
+ */
2775
+ timeout?: number;
2776
+ /**
2777
+ * Polling interval in milliseconds
2778
+ * @default 50
2779
+ */
2780
+ interval?: number;
2781
+ };
2782
+ };
2643
2783
  /**
2644
2784
  * Modify default Chai config. Vitest uses Chai for `expect` and `assert` matches.
2645
2785
  * https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js
@@ -2669,6 +2809,12 @@ interface InlineConfig {
2669
2809
  * @default false
2670
2810
  */
2671
2811
  disableConsoleIntercept?: boolean;
2812
+ /**
2813
+ * Always print console stack traces.
2814
+ *
2815
+ * @default false
2816
+ */
2817
+ printConsoleTrace?: boolean;
2672
2818
  /**
2673
2819
  * Include "location" property inside the test definition
2674
2820
  *
@@ -2835,7 +2981,7 @@ type ProjectConfig = Omit<UserConfig, 'sequencer' | 'shard' | 'watch' | 'run' |
2835
2981
  forks?: Pick<NonNullable<PoolOptions['forks']>, 'singleFork' | 'isolate'>;
2836
2982
  };
2837
2983
  };
2838
- type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency'> & {
2984
+ type RuntimeConfig = Pick<UserConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
2839
2985
  sequence?: {
2840
2986
  concurrent?: boolean;
2841
2987
  hooks?: SequenceHooks;
@@ -2948,4 +3094,4 @@ type Context = RootAndTarget & {
2948
3094
  lastActivePath?: string;
2949
3095
  };
2950
3096
 
2951
- export { type DepsOptimizationOptions as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageOptions as C, type CollectLineNumbers as D, type Environment as E, type FakeTimerInstallOpts as F, type CollectLines as G, type HTMLOptions as H, type RootAndTarget as I, type JsonOptions$1 as J, type Context as K, type Pool as L, type MockFactoryWithHelper as M, type PoolOptions as N, type JSDOMOptions as O, type ProvidedContext as P, type HappyDOMOptions as Q, type ResolvedConfig as R, type BuiltinEnvironment as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkerGlobalState as W, type VitestEnvironment as X, type CSSModuleScopeStrategy as Y, type ApiConfig as Z, type EnvironmentOptions as _, type ResolvedCoverageOptions as a, type JsonAssertionResult as a$, type TransformModePatterns as a0, type InlineConfig as a1, type TypecheckConfig as a2, type ProjectConfig as a3, type BrowserConfigOptions as a4, type UserWorkspaceConfig as a5, type RunnerRPC as a6, type ContextTestEnvironment as a7, type ResolvedTestEnvironment as a8, type SerializableSpec as a9, type UserConfigFnPromise as aA, type UserConfigFn as aB, type UserConfigExport as aC, type UserProjectConfigFn as aD, type UserProjectConfigExport as aE, defineConfig as aF, defineProject as aG, defineWorkspace as aH, configDefaults as aI, defaultInclude as aJ, defaultExclude as aK, coverageConfigDefaults as aL, extraInlineDeps as aM, DefaultReporter as aN, BasicReporter as aO, DotReporter as aP, JsonReporter as aQ, VerboseReporter as aR, TapReporter as aS, JUnitReporter as aT, TapFlatReporter as aU, HangingProcessReporter as aV, GithubActionsReporter as aW, BaseReporter as aX, ReportersMap as aY, type BuiltinReporters as aZ, type BuiltinReporterOptions as a_, type ResolveIdFunction as aa, type WorkerRPC as ab, type Awaitable as ac, type Nullable as ad, type Arrayable as ae, type ArgumentsType$1 as af, type MutableArray as ag, type Constructable as ah, type ModuleCache as ai, type EnvironmentReturn as aj, type VmEnvironmentReturn as ak, type OnServerRestartHandler as al, type ReportContext as am, type CoverageReporter as an, type CoverageIstanbulOptions as ao, type CoverageV8Options as ap, type CustomProviderOptions as aq, type BenchmarkUserOptions as ar, type Benchmark as as, type BenchmarkResult as at, type BenchFunction as au, type BenchmarkAPI as av, type PendingSuiteMock as aw, type MockFactory as ax, type MockMap as ay, type UserConfigFnObject as az, type CoverageProvider as b, type JsonTestResult as b0, type JsonTestResults as b1, BenchmarkReportsMap as b2, type BenchmarkBuiltinReporters as b3, 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 BrowserCommand as s, type JUnitOptions as t, type RuntimeConfig as u, type UserConsoleLog as v, type ModuleGraphData as w, type Reporter as x, type RawErrsMap as y, type TscErrorInfo as z };
3097
+ export { type CoverageReporter as $, type AfterSuiteRunMeta as A, type BaseCoverageOptions as B, type CoverageOptions as C, type Benchmark as D, type Environment as E, type FakeTimerInstallOpts as F, type BenchmarkAPI as G, type HTMLOptions as H, type BenchmarkResult as I, type JsonOptions$1 as J, type BenchmarkUserOptions as K, type BrowserConfigOptions as L, type MockFactoryWithHelper as M, type BuiltinEnvironment as N, type CSSModuleScopeStrategy as O, type ProvidedContext as P, type CollectLineNumbers as Q, type ResolvedConfig as R, type CollectLines as S, type TestSequencer as T, type UserConfig as U, type VitestRunMode as V, type WorkerGlobalState as W, type Constructable as X, type Context as Y, type ContextTestEnvironment as Z, type CoverageIstanbulOptions as _, type ResolvedCoverageOptions as a, TapFlatReporter as a$, type CoverageV8Options as a0, type CustomProviderOptions as a1, type DepsOptimizationOptions as a2, type EnvironmentOptions as a3, type EnvironmentReturn as a4, type HappyDOMOptions as a5, type InlineConfig as a6, type JSDOMOptions as a7, type ModuleCache as a8, type ModuleGraphData as a9, type WebSocketHandlers as aA, type WebSocketRPC as aB, type WorkerRPC as aC, type PendingSuiteMock as aD, type MockFactory as aE, type MockMap as aF, type UserConfigFnObject as aG, type UserConfigFnPromise as aH, type UserConfigFn as aI, type UserConfigExport as aJ, type UserProjectConfigFn as aK, type UserProjectConfigExport as aL, defineConfig as aM, defineProject as aN, defineWorkspace as aO, configDefaults as aP, defaultInclude as aQ, defaultExclude as aR, coverageConfigDefaults as aS, extraInlineDeps as aT, DefaultReporter as aU, BasicReporter as aV, DotReporter as aW, JsonReporter as aX, VerboseReporter as aY, TapReporter as aZ, JUnitReporter as a_, type MutableArray as aa, type Nullable as ab, type OnServerRestartHandler as ac, type Pool as ad, type PoolOptions as ae, type ProjectConfig as af, type RawErrsMap as ag, type ReportContext as ah, type Reporter as ai, type ResolveIdFunction as aj, type ResolvedTestEnvironment as ak, type RootAndTarget as al, type RunnerRPC as am, type SerializableSpec as an, type TransformModePatterns as ao, type TransformResultWithSource as ap, type TscErrorInfo as aq, type TypecheckConfig as ar, type UserConsoleLog as as, type UserWorkspaceConfig as at, type VitestEnvironment as au, type VmEnvironmentReturn as av, type WebSocketBrowserEvents as aw, type WebSocketBrowserHandlers as ax, type WebSocketBrowserRPC as ay, type WebSocketEvents as az, type CoverageProvider as b, HangingProcessReporter as b0, GithubActionsReporter as b1, BaseReporter as b2, ReportersMap as b3, type BuiltinReporters as b4, type BuiltinReporterOptions as b5, type JsonAssertionResult as b6, type JsonTestResult as b7, type JsonTestResults as b8, BenchmarkReportsMap as b9, type BenchmarkBuiltinReporters as ba, 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 BrowserCommand as s, type JUnitOptions as t, type RuntimeConfig as u, type ApiConfig as v, type ArgumentsType as w, type Arrayable as x, type Awaitable as y, type BenchFunction as z };
@@ -1,4 +1,4 @@
1
- export { aX as BaseReporter, aO as BasicReporter, b3 as BenchmarkBuiltinReporters, b2 as BenchmarkReportsMap, a_ as BuiltinReporterOptions, aZ as BuiltinReporters, aN as DefaultReporter, aP as DotReporter, aW as GithubActionsReporter, aV as HangingProcessReporter, aT as JUnitReporter, a$ as JsonAssertionResult, aQ as JsonReporter, b0 as JsonTestResult, b1 as JsonTestResults, x as Reporter, aY as ReportersMap, aU as TapFlatReporter, aS as TapReporter, aR as VerboseReporter } from './reporters-C-3dxOaA.js';
1
+ export { b2 as BaseReporter, aV as BasicReporter, ba as BenchmarkBuiltinReporters, b9 as BenchmarkReportsMap, b5 as BuiltinReporterOptions, b4 as BuiltinReporters, aU as DefaultReporter, aW as DotReporter, b1 as GithubActionsReporter, b0 as HangingProcessReporter, a_ as JUnitReporter, b6 as JsonAssertionResult, aX as JsonReporter, b7 as JsonTestResult, b8 as JsonTestResults, ai as Reporter, b3 as ReportersMap, a$ as TapFlatReporter, aZ as TapReporter, aY as VerboseReporter } from './reporters-qky6mwBH.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/reporters.js CHANGED
@@ -1,4 +1,4 @@
1
- export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.DOAUPIJU.js';
1
+ export { a as BasicReporter, e as BenchmarkReportsMap, D as DefaultReporter, b as DotReporter, G as GithubActionsReporter, H as HangingProcessReporter, c as JUnitReporter, J as JsonReporter, R as ReportersMap, d as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/index.CyGfDRbW.js';
2
2
  import 'node:fs';
3
3
  import 'picocolors';
4
4
  import 'pathe';
@@ -7,17 +7,17 @@ import '@vitest/runner/utils';
7
7
  import '@vitest/utils';
8
8
  import './vendor/env.bmJgw1qP.js';
9
9
  import 'std-env';
10
- import './vendor/utils.D5gGkwyH.js';
10
+ import './vendor/utils.YuQ3LT2a.js';
11
11
  import './vendor/base._gnK9Slw.js';
12
12
  import 'node:perf_hooks';
13
+ import '@vitest/utils/source-map';
13
14
  import './vendor/index._7XLd8Kd.js';
14
15
  import './vendor/global.7bFbnyXl.js';
15
- import './chunks/runtime-console.CUES-L8X.js';
16
+ import './chunks/runtime-console.DiVMr5d4.js';
16
17
  import 'node:stream';
17
18
  import 'node:console';
18
19
  import 'node:path';
19
20
  import './vendor/date.BKM1wewY.js';
20
- import '@vitest/utils/source-map';
21
21
  import 'node:os';
22
22
  import 'node:fs/promises';
23
23
  import 'execa';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, File, Suite, Task, CancelReason, Test, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-C-3dxOaA.js';
2
+ import { R as ResolvedConfig } from './reporters-qky6mwBH.js';
3
3
  import * as tinybench from 'tinybench';
4
4
  import 'vite';
5
5
  import 'vite-node';
@@ -21,6 +21,7 @@ declare class VitestTestRunner implements VitestRunner {
21
21
  private workerState;
22
22
  private __vitest_executor;
23
23
  private cancelRun;
24
+ private assertionsErrors;
24
25
  constructor(config: ResolvedConfig);
25
26
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
26
27
  onCollectStart(file: File): void;
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.B31D70yH.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.C6AfDXK6.js';
3
3
  import 'pathe';
4
4
  import { g as getTestName } from './vendor/tasks.WC7M-K-v.js';
5
5
  import { createDefer, getSafeTimers } from '@vitest/utils';
@@ -29,6 +29,7 @@ class VitestTestRunner {
29
29
  workerState = getWorkerState();
30
30
  __vitest_executor;
31
31
  cancelRun = false;
32
+ assertionsErrors = /* @__PURE__ */ new WeakMap();
32
33
  importFile(filepath, source) {
33
34
  if (source === "setup")
34
35
  this.workerState.moduleCache.delete(filepath);
@@ -109,8 +110,12 @@ class VitestTestRunner {
109
110
  throw expectedAssertionsNumberErrorGen();
110
111
  if (isExpectingAssertions === true && assertionCalls === 0)
111
112
  throw isExpectingAssertionsError;
113
+ if (this.config.expect.requireAssertions && assertionCalls === 0)
114
+ throw this.assertionsErrors.get(test);
112
115
  }
113
116
  extendTaskContext(context) {
117
+ if (this.config.expect.requireAssertions)
118
+ this.assertionsErrors.set(context.task, new Error("expected any number of assertion, but got none"));
114
119
  let _expect;
115
120
  Object.defineProperty(context, "expect", {
116
121
  get() {
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { au as BenchFunction, av as BenchmarkAPI } from './reporters-C-3dxOaA.js';
3
+ import { z as BenchFunction, G as BenchmarkAPI } from './reporters-qky6mwBH.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createTaskCollector, getCurrentSuite, getCurrentTest, getFn, getHooks, setFn, setHooks } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './suite-V5kCKZme.js';
4
- import './reporters-C-3dxOaA.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-B5_jYIf8.js';
4
+ import './reporters-qky6mwBH.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';