vitest 4.1.12 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE.md +192 -10
  2. package/browser/context.d.ts +7 -1
  3. package/browser/context.js +5 -5
  4. package/config.d.ts +0 -2
  5. package/dist/browser.d.ts +52 -21
  6. package/dist/browser.js +12 -13
  7. package/dist/chunks/{acorn.B2iPLyUM.js → acorn.C1kjbUFw.js} +30 -30
  8. package/dist/chunks/{base.B6Opl8PE.js → base.Cof-UHJf.js} +81 -52
  9. package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.C7tWgUvw.d.ts} +17 -14
  10. package/dist/chunks/{cac.DzDtg8hz.js → cac.BYbt0aJp.js} +143 -87
  11. package/dist/chunks/{cli-api.B0Pz1_R7.js → cli-api.COfZo8lK.js} +7160 -7189
  12. package/dist/chunks/config.d.B3YV4t0O.d.ts +3873 -0
  13. package/dist/chunks/{console.3WNpx0tS.js → console.CQZ877Hi.js} +69 -63
  14. package/dist/chunks/{constants.CPYnjOGj.js → constants.DLYM6cZY.js} +2 -2
  15. package/dist/chunks/coverage.9iqXE2gN.js +26 -0
  16. package/dist/chunks/{coverage.CTzCuANN.js → coverage.jGCktcGP.js} +7 -2
  17. package/dist/chunks/{creator.DgVhQm5q.js → creator.DHWmytIK.js} +65 -28
  18. package/dist/chunks/{defaults.9aQKnqFk.js → defaults.B1FCaFfh.js} +16 -9
  19. package/dist/chunks/display.BlTmubjj.js +194 -0
  20. package/dist/chunks/doctor.B-oPbwps.js +465 -0
  21. package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
  22. package/dist/chunks/{environment.d.CrsxCzP1.d.ts → environment.d.BFQtFKdZ.d.ts} +9 -1
  23. package/dist/chunks/globals.ZKtKSkEf.js +29 -0
  24. package/dist/chunks/index.Bi0NXYPf.js +1708 -0
  25. package/dist/chunks/{index.CMESou6r.js → index.BoyTG_B7.js} +82 -81
  26. package/dist/chunks/index.CZzC1gGg.js +8501 -0
  27. package/dist/chunks/index.D0heQG4v.js +1318 -0
  28. package/dist/chunks/index.Di8au7q4.js +15665 -0
  29. package/dist/chunks/{index.Chj8NDwU.js → index.DmDMHCg8.js} +6 -12
  30. package/dist/chunks/{index.DXx9Dtk7.js → index.w_oBZ9N8.js} +25 -12
  31. package/dist/chunks/{init-forks.H5ZuobOQ.js → init-forks.BaDXQSD8.js} +7 -10
  32. package/dist/chunks/{init-threads.6kl1khcL.js → init-threads.ZX_Vov0z.js} +1 -1
  33. package/dist/chunks/{init.k9zZ9sLh.js → init.CO4AB7HZ.js} +113 -38
  34. package/dist/chunks/module-dependencies._2Eei3FO.js +71 -0
  35. package/dist/chunks/{native.DPzPHdi5.js → native.upB-V0CK.js} +50 -37
  36. package/dist/chunks/{nativeModuleMocker.BkNfQMkH.js → nativeModuleMocker.Dh5azSB4.js} +48 -19
  37. package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.9xPIMzi7.js} +110 -42
  38. package/dist/chunks/node.B9mkVmLH.js +47 -0
  39. package/dist/chunks/offset.Dy-5Fdfn.js +24 -0
  40. package/dist/chunks/pathe.M-eThtNZ.zq3TM4NT.js +492 -0
  41. package/dist/chunks/{reporters.d.DtoKVV2s.d.ts → plugin.d.LRFSN46m.d.ts} +2573 -1453
  42. package/dist/chunks/plugins.DPQHVT0p.js +37 -0
  43. package/dist/chunks/rawSnapshot.DqSiqIEx.js +356 -0
  44. package/dist/chunks/resolver.BzpmeQeT.js +48 -0
  45. package/dist/chunks/rpc.Uhkwr2NM.js +93 -0
  46. package/dist/chunks/rpc.d.3FOhdFx8.d.ts +75 -0
  47. package/dist/chunks/run.CjdgFZiW.js +4231 -0
  48. package/dist/chunks/setup-common.CqAQCXzx.js +36 -0
  49. package/dist/chunks/source-map.DakdQc29.js +1788 -0
  50. package/dist/chunks/source-map.d.BkG8YK_3.d.ts +89 -0
  51. package/dist/chunks/spy.DDMXghXv.js +509 -0
  52. package/dist/chunks/task-utils.d.D-gFPNFi.d.ts +144 -0
  53. package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
  54. package/dist/chunks/{utils.BS4fH3nR.js → utils.BBk_icFG.js} +50 -52
  55. package/dist/chunks/{utils.BX5Fg8C4.js → utils.DYj33du9.js} +1 -17
  56. package/dist/chunks/vm.b4MbCAJQ.js +1329 -0
  57. package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.CyJRpyfZ.d.ts} +34 -19
  58. package/dist/cli.js +5 -6
  59. package/dist/config.cjs +9 -6
  60. package/dist/config.d.ts +27 -25
  61. package/dist/config.js +3 -3
  62. package/dist/index.d.ts +471 -38
  63. package/dist/index.js +18 -19
  64. package/dist/module-evaluator.d.ts +64 -5
  65. package/dist/module-evaluator.js +122 -62
  66. package/dist/node.d.ts +355 -87
  67. package/dist/node.js +49 -73
  68. package/dist/runtime.d.ts +43 -6
  69. package/dist/runtime.js +7 -9
  70. package/dist/spy.js +1 -1
  71. package/dist/task-utils.js +290 -0
  72. package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +3 -2
  73. package/dist/worker.d.ts +8 -10
  74. package/dist/worker.js +33 -43
  75. package/dist/workers/forks.js +30 -40
  76. package/dist/workers/runVmTests.js +66 -43
  77. package/dist/workers/threads.js +30 -40
  78. package/dist/workers/vmForks.js +19 -20
  79. package/dist/workers/vmThreads.js +19 -20
  80. package/globals.d.ts +19 -19
  81. package/index.cjs +3 -3
  82. package/optional-runtime-types.d.ts +1 -1
  83. package/optional-types.d.ts +1 -1
  84. package/package.json +59 -74
  85. package/suppress-warnings.cjs +1 -1
  86. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -6
  87. package/dist/chunks/benchmark.CX_oY03V.js +0 -40
  88. package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
  89. package/dist/chunks/config.d.A1h_Y6Jt.d.ts +0 -232
  90. package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
  91. package/dist/chunks/coverage.d.BZtK59WP.d.ts +0 -37
  92. package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
  93. package/dist/chunks/global.d.DVsSRdQ5.d.ts +0 -100
  94. package/dist/chunks/globals.Dj1TGiMC.js +0 -31
  95. package/dist/chunks/index.DC7d2Pf8.js +0 -729
  96. package/dist/chunks/index.DdgEv5B1.js +0 -42
  97. package/dist/chunks/index.UpGiHP7g.js +0 -4255
  98. package/dist/chunks/index.og1WyBLx.js +0 -6358
  99. package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
  100. package/dist/chunks/node.COQbm6gK.js +0 -14
  101. package/dist/chunks/plugin.d.DwFIiJ7i.d.ts +0 -38
  102. package/dist/chunks/rpc.MzXet3jl.js +0 -144
  103. package/dist/chunks/rpc.d.B_8sPU0w.d.ts +0 -30
  104. package/dist/chunks/setup-common.DYx3LtFI.js +0 -60
  105. package/dist/chunks/startVitestModuleRunner.DB-7oCpn.js +0 -740
  106. package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
  107. package/dist/chunks/test.DNmyFkvJ.js +0 -4430
  108. package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
  109. package/dist/chunks/vm.CXMd5FHa.js +0 -785
  110. package/dist/coverage.d.ts +0 -123
  111. package/dist/coverage.js +0 -27
  112. package/dist/environments.d.ts +0 -22
  113. package/dist/environments.js +0 -5
  114. package/dist/reporters.d.ts +0 -27
  115. package/dist/reporters.js +0 -26
  116. package/dist/runners.d.ts +0 -70
  117. package/dist/runners.js +0 -19
  118. package/dist/snapshot.d.ts +0 -9
  119. package/dist/snapshot.js +0 -6
  120. package/dist/suite.d.ts +0 -5
  121. package/dist/suite.js +0 -8
package/dist/node.d.ts CHANGED
@@ -1,41 +1,35 @@
1
1
  import * as vite from 'vite';
2
- import { InlineConfig, UserConfig as UserConfig$1, Plugin, ResolvedConfig as ResolvedConfig$1, ViteDevServer, LogLevel, LoggerOptions, Logger as Logger$1 } from 'vite';
2
+ import { UserConfig as UserConfig$1, ResolvedConfig as ResolvedConfig$1, TransformResult, ViteDevServer, LogLevel, LoggerOptions, Logger as Logger$1 } from 'vite';
3
3
  export { vite as Vite };
4
4
  export { esbuildVersion, isCSSRequest, isFileLoadingAllowed, parseAst, parseAstAsync, rollupVersion, version as viteVersion } from 'vite';
5
5
  import { IncomingMessage } from 'node:http';
6
- import { R as ResolvedConfig, e as UserConfig, f as VitestRunMode, g as VitestOptions, V as Vitest, A as ApiConfig, L as Logger, h as TestSpecification, T as TestProject, P as PoolWorker, i as PoolOptions, j as WorkerRequest, k as TestSequencer } from './chunks/reporters.d.DtoKVV2s.js';
7
- export { M as AgentReporter, B as BaseCoverageOptions, l as BaseReporter, m as BenchmarkBuiltinReporters, n as BenchmarkReporter, o as BenchmarkReportsMap, p as BenchmarkUserOptions, q as BrowserBuiltinProvider, r as BrowserCommand, s as BrowserCommandContext, t as BrowserConfigOptions, u as BrowserInstanceOption, v as BrowserModuleMocker, w as BrowserOrchestrator, x as BrowserProvider, y as BrowserProviderOption, z as BrowserScript, D as BrowserServerFactory, E as BrowserServerOptions, G as BrowserServerState, H as BrowserServerStateSession, J as BuiltinEnvironment, K as BuiltinReporterOptions, N as BuiltinReporters, O as CSSModuleScopeStrategy, Q as CoverageInstrumenter, S as CoverageIstanbulOptions, C as CoverageOptions, X as CoverageProvider, Y as CoverageProviderModule, Z as CoverageReporter, _ as CoverageV8Options, $ as CustomProviderOptions, a0 as DefaultReporter, a1 as DepsOptimizationOptions, a2 as DotReporter, a3 as EnvironmentOptions, a4 as GithubActionsReporter, a5 as HTMLOptions, a6 as HangingProcessReporter, I as InlineConfig, a7 as InstrumenterOptions, a8 as JUnitOptions, a9 as JUnitReporter, aa as JsonAssertionResult, ab as JsonOptions, ac as JsonReporter, ad as JsonTestResult, ae as JsonTestResults, M as MinimalReporter, af as ModuleDiagnostic, ag as OnServerRestartHandler, ah as OnTestsRerunHandler, ai as ParentProjectBrowser, aj as Pool, ak as PoolRunnerInitializer, al as PoolTask, am as ProjectBrowser, an as ProjectConfig, ao as ReportContext, ap as ReportedHookContext, aq as Reporter, ar as ReportersMap, as as ResolveSnapshotPathHandler, at as ResolveSnapshotPathHandlerContext, au as ResolvedBrowserOptions, av as ResolvedCoverageOptions, aw as ResolvedProjectConfig, ax as SerializedTestProject, ay as TapFlatReporter, az as TapReporter, aA as TaskOptions, aB as TestCase, aC as TestCollection, aD as TestDiagnostic, aE as TestModule, aF as TestModuleState, aG as TestResult, aH as TestResultFailed, aI as TestResultPassed, aJ as TestResultSkipped, aK as TestRunEndReason, aL as TestRunResult, aM as TestSequencerConstructor, aN as TestSpecificationOptions, aO as TestState, aP as TestSuite, aQ as TestSuiteState, aR as ToMatchScreenshotComparators, aS as ToMatchScreenshotOptions, aT as TypecheckConfig, U as UserWorkspaceConfig, aU as VerboseBenchmarkReporter, aV as VerboseReporter, aW as VitestEnvironment, aX as VitestPackageInstaller, W as WatcherTriggerPattern, aY as WorkerResponse, aZ as _BrowserNames, a_ as experimental_getRunnerTask } from './chunks/reporters.d.DtoKVV2s.js';
8
- export { C as CacheKeyIdGenerator, a as CacheKeyIdGeneratorContext, V as VitestPluginContext } from './chunks/plugin.d.DwFIiJ7i.js';
9
- export { BaseCoverageProvider } from './coverage.js';
10
- import { Awaitable } from '@vitest/utils';
11
- export { SerializedError } from '@vitest/utils';
12
- import { R as RuntimeRPC } from './chunks/rpc.d.B_8sPU0w.js';
6
+ import { R as ResolvedConfig, e as CliOptions, d as UserConfig, L as Logger, A as ApiConfig, P as PluginHarness, f as Vitest, g as ResolvedCoverageOptions, h as CoverageMap, i as TestSpecification, j as ReportContext, k as TestProject, l as VitestOptions, m as VitestRunMode, n as VCSProvider, o as VCSProviderOptions, p as PoolWorker, q as PoolOptions, r as WorkerRequest, s as TestSequencer } from './chunks/plugin.d.LRFSN46m.js';
7
+ export { M as AgentReporter, B as BaseCoverageOptions, t as BaseReporter, u as BenchmarkUserOptions, v as BrowserBuiltinProvider, w as BrowserCommand, x as BrowserCommandContext, y as BrowserConfigOptions, z as BrowserInstanceOption, D as BrowserModuleMocker, E as BrowserOrchestrator, G as BrowserProvider, H as BrowserProviderCloseOptions, J as BrowserProviderOption, K as BrowserScript, N as BrowserServerContribution, O as BrowserServerFactory, Q as BrowserServerState, S as BrowserServerStateSession, X as BrowserTraceViewOptions, Y as BuiltinEnvironment, Z as BuiltinReporterOptions, _ as BuiltinReporters, $ as CSSModuleScopeStrategy, a0 as CacheKeyIdGenerator, a1 as CacheKeyIdGeneratorContext, a2 as CachedTestFileResult, a3 as CoverageInstrumenter, a4 as CoverageIstanbulOptions, C as CoverageOptions, a5 as CoverageProvider, a6 as CoverageProviderModule, a7 as CoverageReporter, a8 as CoverageV8Options, a9 as CustomProviderOptions, aa as DefaultReporter, ab as DepsOptimizationOptions, ac as DotReporter, ad as EnvironmentOptions, ae as GithubActionsReporter, af as HTMLOptions, ag as HangingProcessReporter, I as InlineConfig, ah as InstrumenterOptions, ai as JUnitOptions, aj as JUnitReporter, ak as JsonAssertionResult, al as JsonOptions, am as JsonReporter, an as JsonTestResult, ao as JsonTestResults, M as MinimalReporter, ap as ModuleDependency, aq as ModuleDiagnostic, ar as ModulesResolver, as as OnServerRestartHandler, at as OnTestsRerunHandler, au as ParentProjectBrowser, av as Pool, aw as PoolRunnerInitializer, ax as PoolTask, ay as ProjectBrowser, az as ProjectConfig, aA as Report, aB as ReportedHookContext, aC as Reporter, aD as ReportersMap, aE as ResolveSnapshotPathHandler, aF as ResolveSnapshotPathHandlerContext, aG as ResolvedBrowserOptions, aH as ResolvedProjectConfig, aI as SerializedTestProject, aJ as SuiteNameTemplateVariables, aK as TapFlatReporter, aL as TapReporter, aM as TaskOptions, aN as TestAttempt, aO as TestAttemptState, aP as TestCase, aQ as TestCollection, aR as TestDiagnostic, aS as TestModule, aT as TestModuleState, aU as TestResult, aV as TestResultFailed, aW as TestResultPassed, aX as TestResultPending, aY as TestResultSkipped, aZ as TestRunEndReason, a_ as TestRunResult, a$ as TestSequencerConstructor, b0 as TestSpecificationOptions, b1 as TestState, b2 as TestSuite, b3 as TestSuiteState, b4 as ToMatchScreenshotComparators, b5 as ToMatchScreenshotOptions, b6 as TypecheckConfig, b7 as UIOptions, U as UserWorkspaceConfig, b8 as VerboseReporter, b9 as VitestEnvironment, ba as VitestPackageInstaller, V as VitestPluginContext, W as WatcherTriggerPattern, bb as WorkerResponse, bc as _BrowserNames, bd as experimental_getRunnerTask, be as startVitest } from './chunks/plugin.d.LRFSN46m.js';
8
+ import { EventEmitter } from 'events';
9
+ import { A as Awaitable } from './chunks/config.d.B3YV4t0O.js';
10
+ import { AfterSuiteRunMeta } from './index.js';
11
+ export { Y as RunnerTask, aI as RunnerTaskResult, k as RunnerTaskResultPack, n as RunnerTestCase, a as RunnerTestFile, Q as RunnerTestSuite, aK as RuntimeConfig, bh as SequenceHooks, bi as SequenceSetupFiles, aL as SerializedError, bj as disableDefaultColors } from './chunks/config.d.B3YV4t0O.js';
12
+ import { RuntimeRPC } from './index.js';
13
13
  import { Writable } from 'node:stream';
14
- import { C as ContextRPC } from './chunks/worker.d.ZpHpO4yb.js';
15
- export { T as TestExecutionType } from './chunks/worker.d.ZpHpO4yb.js';
14
+ import { ContextRPC } from './index.js';
15
+ export { T as TestExecutionType } from './chunks/worker.d.CyJRpyfZ.js';
16
16
  import { Debugger } from 'obug';
17
- import './chunks/global.d.DVsSRdQ5.js';
18
- export { Task as RunnerTask, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
19
- export { c as RuntimeConfig } from './chunks/config.d.A1h_Y6Jt.js';
20
- export { generateFileHash } from '@vitest/runner/utils';
17
+ export { g as generateFileHash } from './chunks/task-utils.d.D-gFPNFi.js';
21
18
  export { CDPSession } from 'vitest/browser';
22
- import './chunks/traces.d.D2T_R8rx.js';
23
- import './chunks/browser.d.BcoexmFG.js';
24
- import '@vitest/pretty-format';
25
- import '@vitest/snapshot';
26
- import '@vitest/utils/diff';
27
- import '@vitest/expect';
19
+ import './chunks/browser.d.C7tWgUvw.js';
20
+ import 'chai';
28
21
  import 'vitest/optional-types.js';
29
- import './chunks/benchmark.d.DAaHLpsq.js';
30
- import 'tinybench';
31
22
  import '@vitest/mocker';
32
- import '@vitest/utils/source-map';
33
- import './chunks/coverage.d.BZtK59WP.js';
34
- import '@vitest/snapshot/manager';
23
+ import './chunks/source-map.d.BkG8YK_3.js';
24
+ import 'node:path';
35
25
  import 'node:console';
36
- import 'node:fs';
26
+ import 'node:fs/promises';
27
+ import 'vitest/optional-runtime-types.js';
28
+ import 'tinybench';
37
29
  import 'vite/module-runner';
38
- import './chunks/environment.d.CrsxCzP1.js';
30
+ import './chunks/environment.d.BFQtFKdZ.js';
31
+
32
+ declare function escapeTestName(label: string, dynamic: boolean): string;
39
33
 
40
34
  type RawErrsMap = Map<string, TscErrorInfo[]>;
41
35
  interface TscErrorInfo {
@@ -50,7 +44,7 @@ interface CollectLineNumbers {
50
44
  next: number;
51
45
  prev?: number;
52
46
  }
53
- type CollectLines = { [key in keyof CollectLineNumbers] : string };
47
+ type CollectLines = { [key in keyof CollectLineNumbers]: string };
54
48
  interface RootAndTarget {
55
49
  root: string;
56
50
  targetAbsPath: string;
@@ -63,82 +57,335 @@ type Context = RootAndTarget & {
63
57
 
64
58
  declare function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean;
65
59
 
66
- declare function escapeTestName(label: string, dynamic: boolean): string;
60
+ interface OptionConfig {
61
+ default?: any;
62
+ type?: any;
63
+ }
64
+ declare class Option {
65
+ rawName: string;
66
+ description: string;
67
+ /** Option name */
68
+ name: string;
69
+ /** Option name and aliases */
70
+ names: string[];
71
+ isBoolean?: boolean;
72
+ required?: boolean;
73
+ config: OptionConfig;
74
+ negated: boolean;
75
+ constructor(rawName: string, description: string, config?: OptionConfig);
76
+ }
67
77
 
68
- interface CliOptions extends UserConfig {
69
- /**
70
- * Override the watch mode
71
- */
72
- run?: boolean;
73
- /**
74
- * Removes colors from the console output
75
- */
76
- color?: boolean;
78
+ interface CommandArg {
79
+ required: boolean;
80
+ value: string;
81
+ variadic: boolean;
82
+ }
83
+ interface HelpSection {
84
+ title?: string;
85
+ body: string;
86
+ }
87
+ interface CommandConfig {
88
+ allowUnknownOptions?: boolean;
89
+ ignoreOptionDefaultValue?: boolean;
90
+ }
91
+ declare type HelpCallback = (sections: HelpSection[]) => void | HelpSection[];
92
+ declare type CommandExample = ((bin: string) => string) | string;
93
+ declare class Command {
94
+ rawName: string;
95
+ description: string;
96
+ config: CommandConfig;
97
+ cli: CAC;
98
+ options: Option[];
99
+ aliasNames: string[];
100
+ name: string;
101
+ args: CommandArg[];
102
+ commandAction?: (...args: any[]) => any;
103
+ usageText?: string;
104
+ versionNumber?: string;
105
+ examples: CommandExample[];
106
+ helpCallback?: HelpCallback;
107
+ globalCommand?: GlobalCommand;
108
+ constructor(rawName: string, description: string, config: CommandConfig, cli: CAC);
109
+ usage(text: string): this;
110
+ allowUnknownOptions(): this;
111
+ ignoreOptionDefaultValue(): this;
112
+ version(version: string, customFlags?: string): this;
113
+ example(example: CommandExample): this;
114
+ /**
115
+ * Add a option for this command
116
+ * @param rawName Raw option name(s)
117
+ * @param description Option description
118
+ * @param config Option config
119
+ */
120
+ option(rawName: string, description: string, config?: OptionConfig): this;
121
+ alias(name: string): this;
122
+ action(callback: (...args: any[]) => any): this;
123
+ /**
124
+ * Check if a command name is matched by this command
125
+ * @param name Command name
126
+ */
127
+ isMatched(name: string): boolean;
128
+ get isDefaultCommand(): boolean;
129
+ get isGlobalCommand(): boolean;
130
+ /**
131
+ * Check if an option is registered in this command
132
+ * @param name Option name
133
+ */
134
+ hasOption(name: string): Option | undefined;
135
+ outputHelp(): void;
136
+ outputVersion(): void;
137
+ checkRequiredArgs(): void;
138
+ /**
139
+ * Check if the parsed options contain any unknown options
140
+ *
141
+ * Exit and output error when true
142
+ */
143
+ checkUnknownOptions(): void;
144
+ /**
145
+ * Check if the required string-type options exist
146
+ */
147
+ checkOptionValue(): void;
148
+ }
149
+ declare class GlobalCommand extends Command {
150
+ constructor(cli: CAC);
151
+ }
152
+
153
+ interface ParsedArgv {
154
+ args: ReadonlyArray<string>;
155
+ options: {
156
+ [k: string]: any;
157
+ };
158
+ }
159
+ declare class CAC extends EventEmitter {
160
+ /** The program name to display in help and version message */
161
+ name: string;
162
+ commands: Command[];
163
+ globalCommand: GlobalCommand;
164
+ matchedCommand?: Command;
165
+ matchedCommandName?: string;
166
+ /**
167
+ * Raw CLI arguments
168
+ */
169
+ rawArgs: string[];
170
+ /**
171
+ * Parsed CLI arguments
172
+ */
173
+ args: ParsedArgv['args'];
174
+ /**
175
+ * Parsed CLI options, camelCased
176
+ */
177
+ options: ParsedArgv['options'];
178
+ showHelpOnExit?: boolean;
179
+ showVersionOnExit?: boolean;
180
+ /**
181
+ * @param name The program name to display in help and version message
182
+ */
183
+ constructor(name?: string);
184
+ /**
185
+ * Add a global usage text.
186
+ *
187
+ * This is not used by sub-commands.
188
+ */
189
+ usage(text: string): this;
190
+ /**
191
+ * Add a sub-command
192
+ */
193
+ command(rawName: string, description?: string, config?: CommandConfig): Command;
194
+ /**
195
+ * Add a global CLI option.
196
+ *
197
+ * Which is also applied to sub-commands.
198
+ */
199
+ option(rawName: string, description: string, config?: OptionConfig): this;
200
+ /**
201
+ * Show help message when `-h, --help` flags appear.
202
+ *
203
+ */
204
+ help(callback?: HelpCallback): this;
205
+ /**
206
+ * Show version number when `-v, --version` flags appear.
207
+ *
208
+ */
209
+ version(version: string, customFlags?: string): this;
210
+ /**
211
+ * Add a global example.
212
+ *
213
+ * This example added here will not be used by sub-commands.
214
+ */
215
+ example(example: CommandExample): this;
216
+ /**
217
+ * Output the corresponding help message
218
+ * When a sub-command is matched, output the help message for the command
219
+ * Otherwise output the global one.
220
+ *
221
+ */
222
+ outputHelp(): void;
223
+ /**
224
+ * Output the version number.
225
+ *
226
+ */
227
+ outputVersion(): void;
228
+ private setParsedInfo;
229
+ unsetMatchedCommand(): void;
230
+ /**
231
+ * Parse argv
232
+ */
233
+ parse(argv?: string[], {
234
+ /** Whether to run the action for matched command */
235
+ run, }?: {
236
+ run?: boolean | undefined;
237
+ }): ParsedArgv;
238
+ private mri;
239
+ runMatchedCommand(): any;
240
+ }
241
+
242
+ interface CliParseOptions {
243
+ allowUnknownOptions?: boolean;
244
+ }
245
+ declare function createCLI(options?: CliParseOptions): CAC;
246
+ declare function parseCLI(argv: string | string[], config?: CliParseOptions): {
247
+ filter: string[];
248
+ options: CliOptions;
249
+ };
250
+
251
+ declare function resolveApiServerConfig(config: UserConfig, defaultPort: number, logger: Logger): ApiConfig;
252
+ declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1, pluginsHarness?: PluginHarness, cliFilters?: string[]): Promise<ResolvedConfig$1>;
253
+
254
+ type Threshold = "lines" | "functions" | "statements" | "branches";
255
+ interface ResolvedThreshold {
256
+ coverageMap: CoverageMap;
257
+ name: string;
258
+ thresholds: Partial<Record<Threshold, number | undefined>>;
259
+ /** When `true`, check `thresholds` against each file instead of the aggregate. */
260
+ perFile: boolean;
261
+ /** Additional per-file-only minimums (object form of `perFile`), or `null`. */
262
+ perFileThresholds: Partial<Record<Threshold, number | undefined>> | null;
263
+ }
264
+ /**
265
+ * Holds info about raw coverage results that are stored on file system:
266
+ *
267
+ * ```json
268
+ * "project-a": {
269
+ * "web": {
270
+ * "tests/math.test.ts": "coverage-1.json",
271
+ * "tests/utils.test.ts": "coverage-2.json",
272
+ * // ^^^^^^^^^^^^^^^ Raw coverage on file system
273
+ * },
274
+ * "ssr": { ... },
275
+ * "browser": { ... },
276
+ * },
277
+ * "project-b": ...
278
+ * ```
279
+ */
280
+ type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["environment"], {
281
+ [TestFilenames: string]: string;
282
+ }>>;
283
+ declare class BaseCoverageProvider {
284
+ ctx: Vitest;
285
+ readonly name: "v8" | "istanbul";
286
+ version: string;
287
+ options: ResolvedCoverageOptions;
288
+ globCache: Map<string, boolean>;
289
+ autoUpdateMarker: string;
290
+ globMatchers?: {
291
+ matchExclude: (file: string) => boolean;
292
+ matchInclude: (file: string) => boolean;
293
+ };
294
+ coverageFiles: CoverageFiles;
295
+ coverageFilesDirectory: string;
296
+ reportsDirectoryLock: ReportsDirectoryLock;
297
+ roots: string[];
298
+ changedFiles?: string[];
299
+ _initialize(ctx: Vitest): void;
77
300
  /**
78
- * Output collected tests as JSON or to a file
301
+ * Check if file matches `coverage.include` but not `coverage.exclude`
79
302
  */
80
- json?: string | boolean;
303
+ isIncluded(_filename: string, root?: string): boolean;
81
304
  /**
82
- * Output collected test files only
305
+ * Compile `coverage.include`/`coverage.exclude` into reusable matchers once.
306
+ * `picomatch.isMatch(file, patterns, options)` recompiles the patterns on
307
+ * every call, which dominates the filtering step on large test suites.
83
308
  */
84
- filesOnly?: boolean;
309
+ private getGlobMatchers;
310
+ private getUntestedFilesByRoot;
311
+ getUntestedFiles(testedFiles: string[]): Promise<string[]>;
312
+ createCoverageMap(): CoverageMap;
313
+ generateReports(_: CoverageMap, __: boolean | undefined): Promise<void>;
314
+ parseConfigModule(_: string): Promise<{
315
+ generate: () => {
316
+ code: string;
317
+ };
318
+ }>;
319
+ resolveOptions(): ResolvedCoverageOptions;
320
+ clean(clean?: boolean): Promise<void>;
321
+ onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
322
+ readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
323
+ /** Callback invoked with a single coverage result */
324
+ onFileRead: (data: CoverageType) => void;
325
+ /** Callback invoked once all results of a project for specific transform mode are read */
326
+ onFinished: (project: Vitest["projects"][number], environment: string) => Promise<void>;
327
+ onDebug: ((...logs: any[]) => void) & {
328
+ enabled: boolean;
329
+ };
330
+ }): Promise<void>;
331
+ cleanAfterRun(): Promise<void>;
332
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): Promise<void>;
333
+ onTestFailure(): Promise<void>;
334
+ reportCoverage(coverageMap: unknown, { allTestsRun }: ReportContext): Promise<void>;
335
+ reportThresholds(coverageMap: CoverageMap, allTestsRun: boolean | undefined): Promise<void>;
85
336
  /**
86
- * Parse files statically instead of running them to collect tests
87
- * @experimental
337
+ * Constructs collected coverage and users' threshold options into separate sets
338
+ * where each threshold set holds their own coverage maps. Threshold set is either
339
+ * for specific files defined by glob pattern or global for all other files.
88
340
  */
89
- staticParse?: boolean;
341
+ private resolveThresholds;
90
342
  /**
91
- * How many tests to process at the same time
92
- * @experimental
343
+ * Check collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
93
344
  */
94
- staticParseConcurrency?: number;
345
+ private checkThresholds;
346
+ private reportThresholdViolations;
95
347
  /**
96
- * Override vite config's configLoader from CLI.
97
- * Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly (default: `bundle`).
98
- * This is only available with **vite version 6.1.0** and above.
99
- * @experimental
348
+ * Check if current coverage is above configured thresholds and bump the thresholds if needed
100
349
  */
101
- configLoader?: InlineConfig extends {
102
- configLoader?: infer T;
103
- } ? T : never;
350
+ updateThresholds({ thresholds: allThresholds, onUpdate, configurationFile }: {
351
+ thresholds: ResolvedThreshold[];
352
+ configurationFile: unknown;
353
+ onUpdate: () => void;
354
+ }): Promise<void>;
355
+ mergeReports(coverageMaps: unknown[]): Promise<void>;
356
+ hasTerminalReporter(reporters: ResolvedCoverageOptions["reporter"]): boolean;
357
+ toSlices<T>(array: T[], size: number): T[][];
358
+ transformFile(url: string, project: TestProject, viteEnvironment: string, isTransformedByVite?: boolean): Promise<TransformResult | null | undefined>;
359
+ createUncoveredFileTransformer(ctx: Vitest): (filename: string) => Promise<TransformResult | null | undefined>;
104
360
  }
105
- /**
106
- * Start Vitest programmatically
107
- *
108
- * Returns a Vitest instance if initialized successfully.
109
- */
110
- declare function startVitest(mode: VitestRunMode, cliFilters?: string[], options?: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
111
-
112
- interface CliParseOptions {
113
- allowUnknownOptions?: boolean;
361
+ declare class ReportsDirectoryLock {
362
+ private readonly reportsDirectory;
363
+ readonly lockFile: string;
364
+ constructor(reportsDirectory: string);
365
+ acquire(): Promise<void>;
366
+ release(): Promise<void>;
367
+ private tryWrite;
368
+ private readOwner;
369
+ private inUseError;
114
370
  }
115
- declare function parseCLI(argv: string | string[], config?: CliParseOptions): {
116
- filter: string[];
117
- options: CliOptions;
118
- };
119
371
 
372
+ declare function createVitest(options: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
120
373
  /**
121
- * @deprecated Internal function
374
+ * @deprecated The `mode` argument is no longer used. Use `createVitest(options, viteOverrides?, vitestOptions?)` instead.
122
375
  */
123
- declare function resolveApiServerConfig<Options extends ApiConfig & Omit<UserConfig, "expect">>(options: Options, defaultPort: number, parentApi?: ApiConfig, logger?: Logger): ApiConfig | undefined;
124
-
125
376
  declare function createVitest(mode: VitestRunMode, options: CliOptions, viteOverrides?: UserConfig$1, vitestOptions?: VitestOptions): Promise<Vitest>;
126
377
 
127
378
  declare class FilesNotFoundError extends Error {
128
379
  code: string;
129
- constructor(mode: "test" | "benchmark");
380
+ constructor();
130
381
  }
131
382
  declare class GitNotFoundError extends Error {
132
383
  code: string;
133
384
  constructor();
134
385
  }
135
-
136
- declare function VitestPlugin(options?: UserConfig, vitest?: Vitest): Promise<Plugin[]>;
137
-
138
- declare function resolveConfig(options?: UserConfig, viteOverrides?: UserConfig$1): Promise<{
139
- vitestConfig: ResolvedConfig;
140
- viteConfig: ResolvedConfig$1;
141
- }>;
386
+ declare class BrowserConnectionError extends Error {
387
+ code: string;
388
+ }
142
389
 
143
390
  declare function resolveFsAllow(projectRoot: string, rootConfigFile: string | false | undefined): string[];
144
391
 
@@ -157,6 +404,24 @@ interface MethodsOptions {
157
404
  }
158
405
  declare function createMethodsRPC(project: TestProject, methodsOptions?: MethodsOptions): RuntimeRPC;
159
406
 
407
+ declare class GitVCSProvider implements VCSProvider {
408
+ private root;
409
+ private resolveFilesWithGitCommand;
410
+ findChangedFiles(options: VCSProviderOptions): Promise<string[]>;
411
+ private getFilesSince;
412
+ private getStagedFiles;
413
+ private getUnstagedFiles;
414
+ getRoot(cwd: string): Promise<string | null>;
415
+ }
416
+
417
+ /**
418
+ * Reports a dependency as changed when its modification time is newer than the run that recorded it.
419
+ * A dependency without a recorded time is always changed.
420
+ */
421
+ declare class MtimeVCSProvider implements VCSProvider {
422
+ findChangedFiles(options: VCSProviderOptions): Promise<string[]>;
423
+ }
424
+
160
425
  /** @experimental */
161
426
  declare class ForksPoolWorker implements PoolWorker {
162
427
  readonly name: string;
@@ -167,13 +432,16 @@ declare class ForksPoolWorker implements PoolWorker {
167
432
  private _fork?;
168
433
  private stdout;
169
434
  private stderr;
435
+ private _errorEmitter;
436
+ private _pipeErrorTimer;
170
437
  constructor(options: PoolOptions);
171
- on(event: string, callback: (arg: any) => void): void;
172
- off(event: string, callback: (arg: any) => void): void;
438
+ on(event: string, callback: (...args: any[]) => void): void;
439
+ off(event: string, callback: (...args: any[]) => void): void;
173
440
  send(message: WorkerRequest): void;
174
441
  start(): Promise<void>;
175
442
  stop(): Promise<void>;
176
443
  deserialize(data: unknown): unknown;
444
+ private emitError;
177
445
  private get fork();
178
446
  }
179
447
 
@@ -187,8 +455,8 @@ declare class ThreadsPoolWorker implements PoolWorker {
187
455
  private stdout;
188
456
  private stderr;
189
457
  constructor(options: PoolOptions);
190
- on(event: string, callback: (arg: any) => void): void;
191
- off(event: string, callback: (arg: any) => void): void;
458
+ on(event: string, callback: (...args: any[]) => void): void;
459
+ off(event: string, callback: (...args: any[]) => void): void;
192
460
  send(message: WorkerRequest): void;
193
461
  start(): Promise<void>;
194
462
  stop(): Promise<void>;
@@ -214,7 +482,7 @@ declare class TypecheckPoolWorker implements PoolWorker {
214
482
  /** @experimental */
215
483
  declare class VmForksPoolWorker extends ForksPoolWorker {
216
484
  readonly name = "vmForks";
217
- readonly reportMemory: true;
485
+ readonly reportMemory = true;
218
486
  protected readonly entrypoint: string;
219
487
  constructor(options: PoolOptions);
220
488
  canReuse(): boolean;
@@ -223,7 +491,7 @@ declare class VmForksPoolWorker extends ForksPoolWorker {
223
491
  /** @experimental */
224
492
  declare class VmThreadsPoolWorker extends ThreadsPoolWorker {
225
493
  readonly name = "vmThreads";
226
- readonly reportMemory: true;
494
+ readonly reportMemory = true;
227
495
  protected readonly entrypoint: string;
228
496
  constructor(options: PoolOptions);
229
497
  canReuse(): boolean;
@@ -261,5 +529,5 @@ declare const createViteServer: typeof vite.createServer;
261
529
 
262
530
  declare const rolldownVersion: string | undefined;
263
531
 
264
- export { ApiConfig, BaseSequencer, ForksPoolWorker, GitNotFoundError, PoolOptions, PoolWorker, ResolvedConfig, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, ThreadsPoolWorker, TypecheckPoolWorker, Vitest, VitestOptions, VitestPlugin, VitestRunMode, VmForksPoolWorker, VmThreadsPoolWorker, WorkerRequest, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isFileServingAllowed, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, startVitest, version };
265
- export type { CliOptions, CliParseOptions, ProcessPool, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget, WorkerContext };
532
+ export { ApiConfig, BaseCoverageProvider, BaseSequencer, BrowserConnectionError, CliOptions, ForksPoolWorker, GitNotFoundError, GitVCSProvider, Logger, MtimeVCSProvider, PluginHarness, PoolOptions, PoolWorker, ReportContext, ResolvedConfig, ResolvedCoverageOptions, TestProject, TestSequencer, TestSpecification, UserConfig as TestUserConfig, FilesNotFoundError as TestsNotFoundError, ThreadsPoolWorker, TypecheckPoolWorker, VCSProvider, VCSProviderOptions, Vitest, VitestOptions, VitestRunMode, VmForksPoolWorker, VmThreadsPoolWorker, WorkerRequest, createCLI, createDebugger, createMethodsRPC, createViteLogger, createViteServer, createVitest, distDir, escapeTestName, getFilePoolName, isFileServingAllowed, isValidApiRequest, parseCLI, registerConsoleShortcuts, resolveApiServerConfig, resolveConfig, resolveFsAllow, rolldownVersion, rootDir, version };
533
+ export type { CliParseOptions, ProcessPool, CollectLineNumbers as TypeCheckCollectLineNumbers, CollectLines as TypeCheckCollectLines, Context as TypeCheckContext, TscErrorInfo as TypeCheckErrorInfo, RawErrsMap as TypeCheckRawErrorsMap, RootAndTarget as TypeCheckRootAndTarget, WorkerContext };