vitest 2.1.4 → 2.2.0-beta.1

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 (46) hide show
  1. package/dist/browser.d.ts +11 -11
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.C3xNdjV6.js → base.BS0HhLXd.js} +1 -1
  4. package/dist/chunks/{cac.DrfPaMvZ.js → cac.Z91LBqmg.js} +56 -7
  5. package/dist/chunks/{cli-api.CKrRYkw8.js → cli-api.DVJJMJHj.js} +123 -80
  6. package/dist/chunks/{config.Crbj2GAb.d.ts → config.CPguQ7J1.d.ts} +2 -2
  7. package/dist/chunks/{environment.LoooBwUu.d.ts → environment.CT0jpO-1.d.ts} +2 -1
  8. package/dist/chunks/{globals.Bp645TTJ.js → globals.BCGEw6ON.js} +2 -2
  9. package/dist/chunks/{index.D3d79vc8.js → index.BjjsHdBb.js} +1 -1
  10. package/dist/chunks/{index.Dqe5k2Rk.js → index.DD5eTY2y.js} +2 -8
  11. package/dist/chunks/{index.Bn81VaWg.js → index.DLRzErGF.js} +240 -318
  12. package/dist/chunks/{index.BMoXz_-n.js → index.K90BXFOx.js} +1 -1
  13. package/dist/chunks/{reporters.anwo7Y6a.d.ts → reporters.B_9uUTGW.d.ts} +148 -22
  14. package/dist/chunks/{resolveConfig.DPmbhVlP.js → resolveConfig.CQIc6fe7.js} +8 -4
  15. package/dist/chunks/{runBaseTests.Dm-659zB.js → runBaseTests.B7hcVT-s.js} +4 -4
  16. package/dist/chunks/{setup-common.DDmVKp6O.js → setup-common.BfGt8K-K.js} +4 -1
  17. package/dist/chunks/{utils.BB4zjzR8.js → utils.DNoFbBUZ.js} +6 -2
  18. package/dist/chunks/{vi.JMQoNY_Z.js → vi.BlPttogV.js} +91 -4
  19. package/dist/chunks/{vite.BdBj-UWY.d.ts → vite.Bvms8Xir.d.ts} +1 -1
  20. package/dist/chunks/{vm.jpyrB0xy.js → vm.Zr4qWzDJ.js} +3 -0
  21. package/dist/chunks/{worker.BAlI9hII.d.ts → worker.9VY11NZs.d.ts} +3 -2
  22. package/dist/chunks/{worker.DHnGaO2M.d.ts → worker.Qz1UB4Fv.d.ts} +1 -1
  23. package/dist/cli.js +1 -1
  24. package/dist/config.d.ts +10 -9
  25. package/dist/coverage.d.ts +9 -112
  26. package/dist/coverage.js +1 -1
  27. package/dist/environments.d.ts +2 -2
  28. package/dist/environments.js +1 -1
  29. package/dist/execute.d.ts +4 -3
  30. package/dist/index.d.ts +39 -10
  31. package/dist/index.js +2 -2
  32. package/dist/node.d.ts +13 -11
  33. package/dist/node.js +7 -7
  34. package/dist/reporters.d.ts +10 -9
  35. package/dist/reporters.js +2 -2
  36. package/dist/runners.d.ts +3 -1
  37. package/dist/runners.js +4 -1
  38. package/dist/worker.js +6 -2
  39. package/dist/workers/forks.js +1 -1
  40. package/dist/workers/runVmTests.js +4 -4
  41. package/dist/workers/threads.js +1 -1
  42. package/dist/workers/vmForks.js +1 -1
  43. package/dist/workers/vmThreads.js +1 -1
  44. package/dist/workers.d.ts +5 -4
  45. package/dist/workers.js +4 -3
  46. package/package.json +15 -15
@@ -408,7 +408,7 @@ var happy = {
408
408
  const { keys, originals } = populateGlobal(global, win, {
409
409
  bindFunctions: true,
410
410
  // jsdom doesn't support Request and Response, but happy-dom does
411
- additionalKeys: ["Request", "Response"]
411
+ additionalKeys: ["Request", "Response", "MessagePort", "fetch"]
412
412
  });
413
413
  return {
414
414
  async teardown(global2) {
@@ -1,21 +1,22 @@
1
- import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Crbj2GAb.js';
2
- import { PrettyFormatOptions } from '@vitest/pretty-format';
3
1
  import * as _vitest_runner from '@vitest/runner';
4
2
  import { File, TaskResultPack, Task, Test, Suite, CancelReason, Custom, TaskMeta, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
- import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
3
+ import { b as Awaitable, U as UserConsoleLog, P as ProvidedContext, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, d as ArgumentsType, O as OnServerRestartHandler, h as OnTestsRerunHandler } from './environment.CT0jpO-1.js';
4
+ import { Writable } from 'node:stream';
6
5
  import * as vite from 'vite';
7
6
  import { ViteDevServer, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv } from 'vite';
7
+ import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arrayable } from '@vitest/utils';
8
+ import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.CPguQ7J1.js';
9
+ import { PrettyFormatOptions } from '@vitest/pretty-format';
10
+ import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
11
+ import { SerializedDiffOptions } from '@vitest/utils/diff';
8
12
  import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
9
13
  import * as chai from 'chai';
10
- import { b as Awaitable, U as UserConsoleLog, P as ProvidedContext, A as AfterSuiteRunMeta, c as Arrayable$1, f as EnvironmentOptions, d as ArgumentsType, O as OnServerRestartHandler } from './environment.LoooBwUu.js';
11
- import { Writable } from 'node:stream';
12
- import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arrayable } from '@vitest/utils';
13
14
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
14
15
  import { ViteNodeRunner } from 'vite-node/client';
15
16
  import { ViteNodeServer } from 'vite-node/server';
17
+ import { B as BenchmarkResult } from './benchmark.geERunq4.js';
16
18
  import { SnapshotManager } from '@vitest/snapshot/manager';
17
19
  import { Stats } from 'node:fs';
18
- import { B as BenchmarkResult } from './benchmark.geERunq4.js';
19
20
 
20
21
  type SerializedTestSpecification = [
21
22
  project: {
@@ -57,14 +58,14 @@ declare abstract class BaseReporter implements Reporter {
57
58
  ctx: Vitest;
58
59
  protected verbose: boolean;
59
60
  private _filesInWatchMode;
61
+ private _timeStart;
60
62
  private _lastRunTimeout;
61
63
  private _lastRunTimer;
62
64
  private _lastRunCount;
63
- private _timeStart;
64
- private _offUnhandledRejection?;
65
65
  constructor(options?: BaseOptions);
66
- get mode(): VitestRunMode;
67
66
  onInit(ctx: Vitest): void;
67
+ log(...messages: any): void;
68
+ error(...messages: any): void;
68
69
  relative(path: string): string;
69
70
  onFinished(files?: File[], errors?: unknown[]): void;
70
71
  onTaskUpdate(packs: TaskResultPack[]): void;
@@ -74,6 +75,7 @@ declare abstract class BaseReporter implements Reporter {
74
75
  private resetLastRunLog;
75
76
  onWatcherRerun(files: string[], trigger?: string): void;
76
77
  onUserConsoleLog(log: UserConsoleLog): void;
78
+ onTestRemoved(trigger?: string): void;
77
79
  shouldLog(log: UserConsoleLog): boolean;
78
80
  onServerRestart(reason?: string): void;
79
81
  reportSummary(files: File[], errors: unknown[]): void;
@@ -81,7 +83,6 @@ declare abstract class BaseReporter implements Reporter {
81
83
  private printErrorsSummary;
82
84
  reportBenchmarkSummary(files: File[]): void;
83
85
  private printTaskErrors;
84
- registerUnhandledRejection(): void;
85
86
  }
86
87
 
87
88
  interface ParsedFile extends File {
@@ -293,7 +294,7 @@ declare class Logger {
293
294
  log(...args: any[]): void;
294
295
  error(...args: any[]): void;
295
296
  warn(...args: any[]): void;
296
- clearFullScreen(message: string): void;
297
+ clearFullScreen(message?: string): void;
297
298
  clearScreen(message: string, force?: boolean): void;
298
299
  private _clearScreen;
299
300
  printError(err: unknown, options?: ErrorOptions): PrintErrorResult | undefined;
@@ -301,8 +302,10 @@ declare class Logger {
301
302
  highlight(filename: string, source: string): string;
302
303
  printNoTestFound(filters?: string[]): void;
303
304
  printBanner(): void;
305
+ printBrowserBanner(project: WorkspaceProject): void;
304
306
  printUnhandledErrors(errors: unknown[]): void;
305
307
  printSourceTypeErrors(errors: TypeCheckError[]): void;
308
+ private registerUnhandledRejection;
306
309
  }
307
310
 
308
311
  interface BrowserProviderInitializationOptions {
@@ -467,6 +470,7 @@ interface BrowserServerStateContext {
467
470
  interface BrowserOrchestrator {
468
471
  createTesters: (files: string[]) => Promise<void>;
469
472
  onCancel: (reason: CancelReason) => Promise<void>;
473
+ $close: () => void;
470
474
  }
471
475
  interface BrowserServerState {
472
476
  orchestrators: Map<string, BrowserOrchestrator>;
@@ -577,7 +581,7 @@ declare class WorkspaceProject {
577
581
  isTargetFile(id: string, source?: string): Promise<boolean>;
578
582
  isInSourceTestFile(code: string): boolean;
579
583
  filterFiles(testFiles: string[], filters: string[], dir: string): string[];
580
- initBrowserServer(configFile: string | undefined): Promise<void>;
584
+ initBrowserServer(): Promise<void>;
581
585
  static createBasicProject(ctx: Vitest): WorkspaceProject;
582
586
  static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
583
587
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
@@ -802,6 +806,10 @@ interface TestResultSkipped {
802
806
  * Skipped tests have no errors.
803
807
  */
804
808
  errors: undefined;
809
+ /**
810
+ * A custom note.
811
+ */
812
+ note: string | undefined;
805
813
  }
806
814
  interface TestDiagnostic {
807
815
  /**
@@ -924,6 +932,110 @@ declare class HangingProcessReporter implements Reporter {
924
932
  onProcessTimeout(): void;
925
933
  }
926
934
 
935
+ interface CoverageSummaryData {
936
+ lines: Totals;
937
+ statements: Totals;
938
+ branches: Totals;
939
+ functions: Totals;
940
+ }
941
+
942
+ declare class CoverageSummary {
943
+ constructor(data: CoverageSummary | CoverageSummaryData);
944
+ merge(obj: CoverageSummary): CoverageSummary;
945
+ toJSON(): CoverageSummaryData;
946
+ isEmpty(): boolean;
947
+ data: CoverageSummaryData;
948
+ lines: Totals;
949
+ statements: Totals;
950
+ branches: Totals;
951
+ functions: Totals;
952
+ }
953
+
954
+ interface CoverageMapData {
955
+ [key: string]: FileCoverage | FileCoverageData;
956
+ }
957
+
958
+ declare class CoverageMap {
959
+ constructor(data: CoverageMapData | CoverageMap);
960
+ addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
961
+ files(): string[];
962
+ fileCoverageFor(filename: string): FileCoverage;
963
+ filter(callback: (key: string) => boolean): void;
964
+ getCoverageSummary(): CoverageSummary;
965
+ merge(data: CoverageMapData | CoverageMap): void;
966
+ toJSON(): CoverageMapData;
967
+ data: CoverageMapData;
968
+ }
969
+
970
+ interface Location {
971
+ line: number;
972
+ column: number;
973
+ }
974
+
975
+ interface Range {
976
+ start: Location;
977
+ end: Location;
978
+ }
979
+
980
+ interface BranchMapping {
981
+ loc: Range;
982
+ type: string;
983
+ locations: Range[];
984
+ line: number;
985
+ }
986
+
987
+ interface FunctionMapping {
988
+ name: string;
989
+ decl: Range;
990
+ loc: Range;
991
+ line: number;
992
+ }
993
+
994
+ interface FileCoverageData {
995
+ path: string;
996
+ statementMap: { [key: string]: Range };
997
+ fnMap: { [key: string]: FunctionMapping };
998
+ branchMap: { [key: string]: BranchMapping };
999
+ s: { [key: string]: number };
1000
+ f: { [key: string]: number };
1001
+ b: { [key: string]: number[] };
1002
+ }
1003
+
1004
+ interface Totals {
1005
+ total: number;
1006
+ covered: number;
1007
+ skipped: number;
1008
+ pct: number;
1009
+ }
1010
+
1011
+ interface Coverage {
1012
+ covered: number;
1013
+ total: number;
1014
+ coverage: number;
1015
+ }
1016
+
1017
+ declare class FileCoverage implements FileCoverageData {
1018
+ constructor(data: string | FileCoverage | FileCoverageData);
1019
+ merge(other: FileCoverageData): void;
1020
+ getBranchCoverageByLine(): { [line: number]: Coverage };
1021
+ getLineCoverage(): { [line: number]: number };
1022
+ getUncoveredLines(): number[];
1023
+ resetHits(): void;
1024
+ computeBranchTotals(): Totals;
1025
+ computeSimpleTotals(): Totals;
1026
+ toSummary(): CoverageSummary;
1027
+ toJSON(): object;
1028
+
1029
+ data: FileCoverageData;
1030
+ path: string;
1031
+ statementMap: { [key: string]: Range };
1032
+ fnMap: { [key: string]: FunctionMapping };
1033
+ branchMap: { [key: string]: BranchMapping };
1034
+ s: { [key: string]: number };
1035
+ f: { [key: string]: number };
1036
+ b: { [key: string]: number[] };
1037
+ }
1038
+
927
1039
  type Status = 'passed' | 'failed' | 'skipped' | 'pending' | 'todo' | 'disabled';
928
1040
  type Milliseconds = number;
929
1041
  interface Callsite {
@@ -962,6 +1074,7 @@ interface JsonTestResults {
962
1074
  success: boolean;
963
1075
  testResults: Array<JsonTestResult>;
964
1076
  snapshot: SnapshotSummary;
1077
+ coverageMap?: CoverageMap | null | undefined;
965
1078
  }
966
1079
  interface JsonOptions$1 {
967
1080
  outputFile?: string;
@@ -972,8 +1085,8 @@ declare class JsonReporter implements Reporter {
972
1085
  options: JsonOptions$1;
973
1086
  constructor(options: JsonOptions$1);
974
1087
  onInit(ctx: Vitest): void;
975
- protected logTasks(files: File[]): Promise<void>;
976
- onFinished(files?: File[]): Promise<void>;
1088
+ protected logTasks(files: File[], coverageMap?: CoverageMap | null): Promise<void>;
1089
+ onFinished(files?: File[], _errors?: unknown[], coverageMap?: unknown): Promise<void>;
977
1090
  /**
978
1091
  * Writes the report to an output file if specified in the config,
979
1092
  * or logs it to the console otherwise.
@@ -1761,6 +1874,10 @@ interface DepsOptions {
1761
1874
  type InlineReporter = Reporter;
1762
1875
  type ReporterName = BuiltinReporters | 'html' | (string & {});
1763
1876
  type ReporterWithOptions<Name extends ReporterName = ReporterName> = Name extends keyof BuiltinReporterOptions ? BuiltinReporterOptions[Name] extends never ? [Name, object] : [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
1877
+ interface ResolveSnapshotPathHandlerContext {
1878
+ config: SerializedConfig;
1879
+ }
1880
+ type ResolveSnapshotPathHandler = (testPath: string, snapExtension: string, context: ResolveSnapshotPathHandlerContext) => string;
1764
1881
  interface InlineConfig {
1765
1882
  /**
1766
1883
  * Name of the project. Will be used to display in the reporter.
@@ -2046,7 +2163,7 @@ interface InlineConfig {
2046
2163
  /**
2047
2164
  * Path to a module which has a default export of diff config.
2048
2165
  */
2049
- diff?: string;
2166
+ diff?: string | SerializedDiffOptions;
2050
2167
  /**
2051
2168
  * Paths to snapshot serializer modules.
2052
2169
  */
@@ -2054,7 +2171,7 @@ interface InlineConfig {
2054
2171
  /**
2055
2172
  * Resolve custom snapshot path
2056
2173
  */
2057
- resolveSnapshotPath?: (path: string, extension: string) => string;
2174
+ resolveSnapshotPath?: ResolveSnapshotPathHandler;
2058
2175
  /**
2059
2176
  * Path to a custom snapshot environment module that has a default export of `SnapshotEnvironment` object.
2060
2177
  */
@@ -2387,7 +2504,7 @@ interface UserConfig extends InlineConfig {
2387
2504
  interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude' | 'diff' | 'setupFiles' | 'snapshotEnvironment' | 'bail'> {
2388
2505
  mode: VitestRunMode;
2389
2506
  base?: string;
2390
- diff?: string;
2507
+ diff?: string | SerializedDiffOptions;
2391
2508
  bail?: number;
2392
2509
  setupFiles: string[];
2393
2510
  snapshotEnvironment?: string;
@@ -2465,6 +2582,10 @@ declare class TestProject {
2465
2582
  * @experimental The public Vitest API is experimental and does not follow semver.
2466
2583
  */
2467
2584
  readonly workspaceProject: WorkspaceProject;
2585
+ /**
2586
+ * Vite's dev server instance. Every workspace project has its own server.
2587
+ */
2588
+ readonly vite: ViteDevServer;
2468
2589
  /**
2469
2590
  * Resolved project configuration.
2470
2591
  */
@@ -2663,10 +2784,12 @@ declare class Vitest {
2663
2784
  runner: ViteNodeRunner;
2664
2785
  packageInstaller: VitestPackageInstaller;
2665
2786
  private coreWorkspaceProject;
2666
- private resolvedProjects;
2787
+ /** @private */
2788
+ resolvedProjects: WorkspaceProject[];
2667
2789
  projects: WorkspaceProject[];
2668
2790
  distPath: string;
2669
2791
  private _cachedSpecs;
2792
+ private _workspaceConfigPath?;
2670
2793
  /** @deprecated use `_cachedSpecs` */
2671
2794
  projectTestFiles: Map<string, WorkspaceSpec[]>;
2672
2795
  /** @private */
@@ -2676,6 +2799,7 @@ declare class Vitest {
2676
2799
  private _onClose;
2677
2800
  private _onSetServer;
2678
2801
  private _onCancelListeners;
2802
+ private _onUserTestsRerun;
2679
2803
  setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
2680
2804
  provide<T extends keyof ProvidedContext & string>(key: T, value: ProvidedContext[T]): void;
2681
2805
  /**
@@ -2695,7 +2819,6 @@ declare class Vitest {
2695
2819
  private getWorkspaceConfigPath;
2696
2820
  private resolveWorkspace;
2697
2821
  private initCoverageProvider;
2698
- private initBrowserProviders;
2699
2822
  mergeReports(): Promise<void>;
2700
2823
  collect(filters?: string[]): Promise<{
2701
2824
  tests: File[];
@@ -2715,7 +2838,8 @@ declare class Vitest {
2715
2838
  runFiles(specs: TestSpecification[], allTestsRun: boolean): Promise<void>;
2716
2839
  collectFiles(specs: WorkspaceSpec[]): Promise<void>;
2717
2840
  cancelCurrentRun(reason: CancelReason): Promise<void>;
2718
- rerunFiles(files?: string[], trigger?: string): Promise<void>;
2841
+ initBrowserServers(): Promise<void>;
2842
+ rerunFiles(files?: string[], trigger?: string, allTestsRun?: boolean): Promise<void>;
2719
2843
  changeProjectName(pattern: string): Promise<void>;
2720
2844
  changeNamePattern(pattern: string, files?: string[], trigger?: string): Promise<void>;
2721
2845
  changeFilenamePattern(pattern: string, files?: string[]): Promise<void>;
@@ -2732,6 +2856,7 @@ declare class Vitest {
2732
2856
  onChange: (id: string) => void;
2733
2857
  onUnlink: (id: string) => void;
2734
2858
  onAdd: (id: string) => Promise<void>;
2859
+ checkUnhandledErrors(errors: unknown[]): void;
2735
2860
  private unregisterWatcher;
2736
2861
  private registerWatcher;
2737
2862
  /**
@@ -2757,6 +2882,7 @@ declare class Vitest {
2757
2882
  onAfterSetServer(fn: OnServerRestartHandler): void;
2758
2883
  onCancel(fn: (reason: CancelReason) => void): void;
2759
2884
  onClose(fn: () => void): void;
2885
+ onTestsRerun(fn: OnTestsRerunHandler): void;
2760
2886
  }
2761
2887
 
2762
- export { type HTMLOptions as $, type ApiConfig as A, type BaseCoverageOptions as B, type CoverageProvider as C, type DepsOptimizationOptions as D, type ResolvedConfig as E, type ProjectConfig as F, type BenchmarkUserOptions as G, type VitestOptions as H, type InlineConfig as I, WorkspaceProject as J, type TestSequencer as K, Logger as L, type WorkspaceSpec as M, TestModule as N, type ModuleDiagnostic as O, type Pool as P, VitestPackageInstaller as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TscErrorInfo as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, type ProcessPool as X, getFilePoolName as Y, TestProject as Z, type SerializedTestProject as _, type ReportContext as a, type JsonOptions$1 as a0, type JUnitOptions as a1, TestCase as a2, TestSuite as a3, type TaskOptions as a4, TestCollection as a5, type TestDiagnostic as a6, type TestResult as a7, type TestResultFailed as a8, type TestResultPassed as a9, VerboseReporter as aA, BaseReporter as aB, TestFile as aC, type FileDiagnostic as aD, ReportersMap as aE, type BuiltinReporters as aF, type BuiltinReporterOptions as aG, type JsonAssertionResult as aH, type JsonTestResult as aI, type JsonTestResults as aJ, BenchmarkReportsMap as aK, type BenchmarkBuiltinReporters as aL, type TestResultSkipped as aa, type TestSequencerConstructor as ab, TestSpecification as ac, type BrowserBuiltinProvider as ad, type BrowserCommand as ae, type BrowserCommandContext as af, type BrowserOrchestrator as ag, type BrowserProvider as ah, type BrowserProviderInitializationOptions as ai, type BrowserProviderModule as aj, type BrowserProviderOptions as ak, type BrowserServer as al, type BrowserServerState as am, type BrowserServerStateContext as an, type CDPSession as ao, type ResolvedBrowserOptions as ap, type ResolvedProjectConfig as aq, BasicReporter as ar, DefaultReporter as as, DotReporter as at, GithubActionsReporter as au, HangingProcessReporter as av, JsonReporter as aw, JUnitReporter as ax, TapFlatReporter as ay, TapReporter as az, type CoverageProviderModule as b, type CoverageV8Options as c, type UserProjectConfigFn as d, type UserProjectConfigExport as e, type VitestEnvironment as f, type RawErrsMap as g, type CollectLineNumbers as h, type CollectLines as i, type RootAndTarget as j, type Context as k, type CoverageReporter as l, type CoverageProviderName as m, type CoverageOptions as n, type CoverageIstanbulOptions as o, type CustomProviderOptions as p, type Reporter as q, type BrowserScript as r, type BrowserConfigOptions as s, type BuiltinEnvironment as t, type PoolOptions as u, type CSSModuleScopeStrategy as v, type VitestRunMode as w, type TransformModePatterns as x, type TypecheckConfig as y, type UserConfig as z };
2888
+ export { type SerializedTestProject as $, type ApiConfig as A, type BaseCoverageOptions as B, CoverageMap as C, type DepsOptimizationOptions as D, type UserConfig as E, type ResolvedConfig as F, type ProjectConfig as G, type BenchmarkUserOptions as H, type InlineConfig as I, type VitestOptions as J, WorkspaceProject as K, Logger as L, type TestSequencer as M, type WorkspaceSpec as N, TestModule as O, type Pool as P, type ModuleDiagnostic as Q, type ResolvedCoverageOptions as R, type SerializedTestSpecification as S, type TscErrorInfo as T, type UserWorkspaceConfig as U, Vitest as V, type WorkspaceProjectConfiguration as W, VitestPackageInstaller as X, type ProcessPool as Y, getFilePoolName as Z, TestProject as _, type ReportContext as a, type HTMLOptions as a0, type JsonOptions$1 as a1, type JUnitOptions as a2, TestCase as a3, TestSuite as a4, type TaskOptions as a5, TestCollection as a6, type TestDiagnostic as a7, type TestResult as a8, type TestResultFailed as a9, JUnitReporter as aA, TapFlatReporter as aB, TapReporter as aC, VerboseReporter as aD, BaseReporter as aE, TestFile as aF, type FileDiagnostic as aG, ReportersMap as aH, type BuiltinReporters as aI, type BuiltinReporterOptions as aJ, type JsonAssertionResult as aK, type JsonTestResult as aL, type JsonTestResults as aM, BenchmarkReportsMap as aN, type BenchmarkBuiltinReporters as aO, type TestResultPassed as aa, type TestResultSkipped as ab, type TestSequencerConstructor as ac, TestSpecification as ad, type BrowserBuiltinProvider as ae, type BrowserCommand as af, type BrowserCommandContext as ag, type BrowserOrchestrator as ah, type BrowserProvider as ai, type BrowserProviderInitializationOptions as aj, type BrowserProviderModule as ak, type BrowserProviderOptions as al, type BrowserServer as am, type BrowserServerState as an, type BrowserServerStateContext as ao, type CDPSession as ap, type ResolvedBrowserOptions as aq, type ResolvedProjectConfig as ar, type ResolveSnapshotPathHandler as as, type ResolveSnapshotPathHandlerContext as at, BasicReporter as au, DefaultReporter as av, DotReporter as aw, GithubActionsReporter as ax, HangingProcessReporter as ay, JsonReporter as az, type CoverageProvider as b, type CoverageProviderModule as c, type CoverageV8Options as d, type UserProjectConfigFn as e, type UserProjectConfigExport as f, type VitestEnvironment as g, type RawErrsMap as h, type CollectLineNumbers as i, type CollectLines as j, type RootAndTarget as k, type Context as l, type CoverageReporter as m, type CoverageProviderName as n, type CoverageOptions as o, type CoverageIstanbulOptions as p, type CustomProviderOptions as q, type Reporter as r, type BrowserScript as s, type BrowserConfigOptions as t, type BuiltinEnvironment as u, type PoolOptions as v, type CSSModuleScopeStrategy as w, type VitestRunMode as x, type TransformModePatterns as y, type TypecheckConfig as z };
@@ -6600,7 +6600,9 @@ function createMethodsRPC(project, options = {}) {
6600
6600
  ctx.snapshot.add(snapshot);
6601
6601
  },
6602
6602
  resolveSnapshotPath(testPath) {
6603
- return ctx.snapshot.resolvePath(testPath);
6603
+ return ctx.snapshot.resolvePath(testPath, {
6604
+ config: project.getSerializableConfig()
6605
+ });
6604
6606
  },
6605
6607
  async getSourceMap(id, force) {
6606
6608
  if (force) {
@@ -6672,7 +6674,9 @@ function createMethodsRPC(project, options = {}) {
6672
6674
  ctx.state.catchError(err, type);
6673
6675
  },
6674
6676
  onFinished(files) {
6675
- return ctx.report("onFinished", files, ctx.state.getUnhandledErrors());
6677
+ const errors = ctx.state.getUnhandledErrors();
6678
+ ctx.checkUnhandledErrors(errors);
6679
+ return ctx.report("onFinished", files, errors);
6676
6680
  },
6677
6681
  onCancel(reason) {
6678
6682
  ctx.cancelCurrentRun(reason);
@@ -6683,7 +6687,7 @@ function createMethodsRPC(project, options = {}) {
6683
6687
  };
6684
6688
  }
6685
6689
  function handleRollupError(e) {
6686
- if (e instanceof Error && "plugin" in e) {
6690
+ if (e instanceof Error && ("plugin" in e || "frame" in e || "id" in e)) {
6687
6691
  throw {
6688
6692
  name: e.name,
6689
6693
  message: e.message,
@@ -8141,7 +8145,7 @@ ${JSON.stringify({ browser: { provider: "playwright", name: "chromium" } }, null
8141
8145
  resolved.benchmark.outputJson = options.outputJson;
8142
8146
  }
8143
8147
  }
8144
- if (resolved.diff) {
8148
+ if (typeof resolved.diff === "string") {
8145
8149
  resolved.diff = resolvePath(resolved.diff, resolved.root);
8146
8150
  resolved.forceRerunTriggers.push(resolved.diff);
8147
8151
  }
@@ -1,8 +1,8 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests, collectTests } from '@vitest/runner';
3
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.D3d79vc8.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.BjjsHdBb.js';
4
4
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BoMDb1ip.js';
5
- import { a as globalExpect, v as vi } from './vi.JMQoNY_Z.js';
5
+ import { a as globalExpect, v as vi } from './vi.BlPttogV.js';
6
6
  import { c as closeInspector } from './inspector.70d6emsh.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import timers from 'node:timers';
@@ -10,8 +10,8 @@ import util from 'node:util';
10
10
  import { getSafeTimers } from '@vitest/utils';
11
11
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
12
12
  import { installSourcemapsSupport } from 'vite-node/source-map';
13
- import { V as VitestIndex } from './index.Dqe5k2Rk.js';
14
- import { s as setupCommonEnv } from './setup-common.DDmVKp6O.js';
13
+ import { V as VitestIndex } from './index.DD5eTY2y.js';
14
+ import { s as setupCommonEnv } from './setup-common.BfGt8K-K.js';
15
15
  import { g as getWorkerState, r as resetModules } from './utils.C8RiOc4B.js';
16
16
  import 'chai';
17
17
  import 'node:path';
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals) {
16
- (await import('./globals.Bp645TTJ.js')).registerApiGlobally();
16
+ (await import('./globals.BCGEw6ON.js')).registerApiGlobally();
17
17
  }
18
18
  }
19
19
  function setupDefines(defines) {
@@ -33,6 +33,9 @@ function setupEnv(env) {
33
33
  }
34
34
  }
35
35
  async function loadDiffConfig(config, executor) {
36
+ if (typeof config.diff === "object") {
37
+ return config.diff;
38
+ }
36
39
  if (typeof config.diff !== "string") {
37
40
  return;
38
41
  }
@@ -179,6 +179,9 @@ function formatProjectName(name, suffix = " ") {
179
179
  const colors = [c.blue, c.yellow, c.cyan, c.green, c.magenta];
180
180
  return colors[index % colors.length](`|${name}|`) + suffix;
181
181
  }
182
+ function withLabel(color, label, message) {
183
+ return `${c.bold(c.inverse(c[color](` ${label} `)))} ${c[color](message)}`;
184
+ }
182
185
 
183
186
  var utils = /*#__PURE__*/Object.freeze({
184
187
  __proto__: null,
@@ -202,7 +205,8 @@ var utils = /*#__PURE__*/Object.freeze({
202
205
  spinnerMap: spinnerMap,
203
206
  suiteFail: suiteFail,
204
207
  taskFail: taskFail,
205
- testPass: testPass
208
+ testPass: testPass,
209
+ withLabel: withLabel
206
210
  });
207
211
 
208
- export { F_POINTER as F, F_RIGHT as a, F_CHECK as b, getStateString as c, divider as d, formatTimeString as e, formatProjectName as f, getStateSymbol as g, countTestErrors as h, getCols as i, getHookStateSymbol as j, renderSnapshotSummary as r, taskFail as t, utils as u };
212
+ export { F_POINTER as F, formatTimeString as a, F_RIGHT as b, F_CHECK as c, divider as d, getStateString as e, formatProjectName as f, getStateSymbol as g, countTestErrors as h, getCols as i, getHookStateSymbol as j, renderSnapshotSummary as r, taskFail as t, utils as u, withLabel as w };
@@ -44,6 +44,10 @@ function createExpectPoll(expect) {
44
44
  poll: true
45
45
  });
46
46
  fn = fn.bind(assertion);
47
+ const test = chai$1.util.flag(assertion, "vitest-test");
48
+ if (!test) {
49
+ throw new Error("expect.poll() must be called inside a test");
50
+ }
47
51
  const proxy = new Proxy(assertion, {
48
52
  get(target, key, receiver) {
49
53
  const assertionFunction = Reflect.get(target, key, receiver);
@@ -60,7 +64,7 @@ function createExpectPoll(expect) {
60
64
  }
61
65
  return function(...args) {
62
66
  const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
63
- return new Promise((resolve, reject) => {
67
+ const promise = () => new Promise((resolve, reject) => {
64
68
  let intervalId;
65
69
  let lastError;
66
70
  const { setTimeout, clearTimeout } = getSafeTimers();
@@ -90,6 +94,36 @@ function createExpectPoll(expect) {
90
94
  };
91
95
  check();
92
96
  });
97
+ let awaited = false;
98
+ test.onFinished ??= [];
99
+ test.onFinished.push(() => {
100
+ if (!awaited) {
101
+ const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
102
+ const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
103
+ const assertionString = `expect.${name}.${negated}${String(key)}()`;
104
+ const error = new Error(
105
+ `${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
106
+
107
+ await ${assertionString}
108
+ `
109
+ );
110
+ throw copyStackTrace$1(error, STACK_TRACE_ERROR);
111
+ }
112
+ });
113
+ let resultPromise;
114
+ return {
115
+ then(onFulfilled, onRejected) {
116
+ awaited = true;
117
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
118
+ },
119
+ catch(onRejected) {
120
+ return (resultPromise ||= promise()).catch(onRejected);
121
+ },
122
+ finally(onFinally) {
123
+ return (resultPromise ||= promise()).finally(onFinally);
124
+ },
125
+ [Symbol.toStringTag]: "Promise"
126
+ };
93
127
  };
94
128
  }
95
129
  });
@@ -202,9 +236,20 @@ function requireChaiSubset () {
202
236
  var chaiSubsetExports = requireChaiSubset();
203
237
  var Subset = /*@__PURE__*/getDefaultExportFromCjs(chaiSubsetExports);
204
238
 
205
- function recordAsyncExpect(test, promise) {
239
+ function createAssertionMessage(util, assertion, hasArgs) {
240
+ const not = util.flag(assertion, "negate") ? "not." : "";
241
+ const name = `${util.flag(assertion, "_name")}(${"expected" })`;
242
+ const promiseName = util.flag(assertion, "promise");
243
+ const promise = promiseName ? `.${promiseName}` : "";
244
+ return `expect(actual)${promise}.${not}${name}`;
245
+ }
246
+ function recordAsyncExpect(_test, promise, assertion, error) {
247
+ const test = _test;
206
248
  if (test && promise instanceof Promise) {
207
249
  promise = promise.finally(() => {
250
+ if (!test.promises) {
251
+ return;
252
+ }
208
253
  const index = test.promises.indexOf(promise);
209
254
  if (index !== -1) {
210
255
  test.promises.splice(index, 1);
@@ -214,6 +259,33 @@ function recordAsyncExpect(test, promise) {
214
259
  test.promises = [];
215
260
  }
216
261
  test.promises.push(promise);
262
+ let resolved = false;
263
+ test.onFinished ??= [];
264
+ test.onFinished.push(() => {
265
+ if (!resolved) {
266
+ const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
267
+ const stack = processor(error.stack);
268
+ console.warn([
269
+ `Promise returned by \`${assertion}\` was not awaited. `,
270
+ "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
271
+ "Please remember to await the assertion.\n",
272
+ stack
273
+ ].join(""));
274
+ }
275
+ });
276
+ return {
277
+ then(onFullfilled, onRejected) {
278
+ resolved = true;
279
+ return promise.then(onFullfilled, onRejected);
280
+ },
281
+ catch(onRejected) {
282
+ return promise.catch(onRejected);
283
+ },
284
+ finally(onFinally) {
285
+ return promise.finally(onFinally);
286
+ },
287
+ [Symbol.toStringTag]: "Promise"
288
+ };
217
289
  }
218
290
  return promise;
219
291
  }
@@ -260,6 +332,7 @@ const SnapshotPlugin = (chai, utils) => {
260
332
  chai.Assertion.prototype,
261
333
  key,
262
334
  function(properties, message) {
335
+ utils.flag(this, "_name", key);
263
336
  const isNot = utils.flag(this, "negate");
264
337
  if (isNot) {
265
338
  throw new Error(`${key} cannot be used with "not"`);
@@ -286,10 +359,12 @@ const SnapshotPlugin = (chai, utils) => {
286
359
  chai.Assertion.prototype,
287
360
  "toMatchFileSnapshot",
288
361
  function(file, message) {
362
+ utils.flag(this, "_name", "toMatchFileSnapshot");
289
363
  const isNot = utils.flag(this, "negate");
290
364
  if (isNot) {
291
365
  throw new Error('toMatchFileSnapshot cannot be used with "not"');
292
366
  }
367
+ const error = new Error("resolves");
293
368
  const expected = utils.flag(this, "object");
294
369
  const test = utils.flag(this, "vitest-test");
295
370
  const errorMessage = utils.flag(this, "message");
@@ -303,13 +378,19 @@ const SnapshotPlugin = (chai, utils) => {
303
378
  errorMessage,
304
379
  ...getTestNames(test)
305
380
  });
306
- return recordAsyncExpect(test, promise);
381
+ return recordAsyncExpect(
382
+ test,
383
+ promise,
384
+ createAssertionMessage(utils, this),
385
+ error
386
+ );
307
387
  }
308
388
  );
309
389
  utils.addMethod(
310
390
  chai.Assertion.prototype,
311
391
  "toMatchInlineSnapshot",
312
392
  function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
393
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
313
394
  const isNot = utils.flag(this, "negate");
314
395
  if (isNot) {
315
396
  throw new Error('toMatchInlineSnapshot cannot be used with "not"');
@@ -348,6 +429,7 @@ const SnapshotPlugin = (chai, utils) => {
348
429
  chai.Assertion.prototype,
349
430
  "toThrowErrorMatchingSnapshot",
350
431
  function(message) {
432
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
351
433
  const isNot = utils.flag(this, "negate");
352
434
  if (isNot) {
353
435
  throw new Error(
@@ -488,6 +570,11 @@ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
488
570
  configurable: true
489
571
  });
490
572
 
573
+ function inject(key) {
574
+ const workerState = getWorkerState();
575
+ return workerState.providedContext[key];
576
+ }
577
+
491
578
  var fakeTimersSrc = {};
492
579
 
493
580
  var global;
@@ -3895,4 +3982,4 @@ function getImporter(name) {
3895
3982
  return stack?.file || "";
3896
3983
  }
3897
3984
 
3898
- export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, vi as v };
3985
+ export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, inject as i, vi as v };
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.anwo7Y6a.js';
1
+ import { I as InlineConfig } from './reporters.B_9uUTGW.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -116,6 +116,9 @@ class CommonjsExecutor {
116
116
  // @ts-expect-error not typed
117
117
  static globalPaths = Module.globalPaths;
118
118
  static isBuiltin = Module.isBuiltin;
119
+ static constants = Module.constants;
120
+ static enableCompileCache = Module.enableCompileCache;
121
+ static getCompileCacheDir = Module.getCompileCacheDir;
119
122
  static Module = Module$1;
120
123
  };
121
124
  this.extensions[".js"] = this.requireJs;