vitest 5.0.0-beta.2 → 5.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.Opc_YHkk.js → base.BEGVMQrS.js} +6 -6
  4. package/dist/chunks/{browser.d.BUhkKcDl.d.ts → browser.d.BGxB4Xum.d.ts} +5 -26
  5. package/dist/chunks/{cac.8N4bOkkB.js → cac.CyXAEMkE.js} +26 -33
  6. package/dist/chunks/{cli-api.B0RFke2g.js → cli-api.DJMXq34b.js} +640 -615
  7. package/dist/chunks/{config.d.D91DHYaD.d.ts → config.d.DXq1aBpy.d.ts} +93 -89
  8. package/dist/chunks/{creator.BqL2U_x4.js → creator.D66cVXYh.js} +2 -2
  9. package/dist/chunks/{defaults.szbHWQun.js → defaults.CUUnbOrq.js} +6 -4
  10. package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
  11. package/dist/chunks/global.d.BtKPuz2X.d.ts +194 -0
  12. package/dist/chunks/{globals.EHmmu0nC.js → globals.BuY-yD0m.js} +2 -1
  13. package/dist/chunks/{index.D_7-4CaB.js → index.CE58PZNH.js} +1660 -701
  14. package/dist/chunks/{index.CViWo__T.js → index.CcluKS59.js} +4 -4
  15. package/dist/chunks/{index.CbgUM9E5.js → index.nQFVd50u.js} +2 -1
  16. package/dist/chunks/{init-forks.DMge3WTt.js → init-forks.Ce3vGWgL.js} +1 -1
  17. package/dist/chunks/{init-threads.eIoyCTon.js → init-threads.8e1OLv5v.js} +1 -1
  18. package/dist/chunks/{init.BVd7SaCA.js → init.6qx-LaHs.js} +31 -3
  19. package/dist/chunks/{nativeModuleMocker.DKpFw0pk.js → nativeModuleMocker.DDZfQXLs.js} +1 -1
  20. package/dist/chunks/{plugin.d.cIKZEZ16.d.ts → plugin.d.B7MTG_Fe.d.ts} +103 -88
  21. package/dist/chunks/{rpc.d.7JZuxZ8u.d.ts → rpc.d.OQ_EZi1Z.d.ts} +18 -2
  22. package/dist/chunks/{setup-common.Hpq30zVk.js → setup-common.DdEF_hkE.js} +1 -1
  23. package/dist/chunks/{vm.2okbRRME.js → vm.Bu7mmcZq.js} +2 -2
  24. package/dist/chunks/{worker.d.Bu1kXGw4.d.ts → worker.d.yR22cs6X.d.ts} +3 -2
  25. package/dist/cli.js +2 -2
  26. package/dist/config.cjs +1 -1
  27. package/dist/config.d.ts +7 -10
  28. package/dist/config.js +2 -2
  29. package/dist/index.d.ts +24 -41
  30. package/dist/index.js +2 -1
  31. package/dist/module-evaluator.d.ts +4 -1
  32. package/dist/module-evaluator.js +15 -20
  33. package/dist/node.d.ts +20 -13
  34. package/dist/node.js +6 -6
  35. package/dist/runtime.js +2 -2
  36. package/dist/worker.d.ts +3 -3
  37. package/dist/worker.js +7 -6
  38. package/dist/workers/forks.js +8 -7
  39. package/dist/workers/runVmTests.js +4 -3
  40. package/dist/workers/threads.js +8 -7
  41. package/dist/workers/vmForks.js +4 -4
  42. package/dist/workers/vmThreads.js +4 -4
  43. package/package.json +20 -21
  44. package/dist/chunks/global.d.DhbKSQoV.d.ts +0 -99
@@ -1,9 +1,9 @@
1
1
  import * as chai from 'chai';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.Hpq30zVk.js';
3
+ import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.DdEF_hkE.js';
4
4
  import { r as rpc } from './rpc.DFRWVnRh.js';
5
5
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
6
- import { T as TestRunner, N as NodeBenchmarkRunner } from './index.D_7-4CaB.js';
6
+ import { T as TestRunner } from './index.CE58PZNH.js';
7
7
 
8
8
  function setupChaiConfig(config) {
9
9
  Object.assign(chai.config, config);
@@ -93,7 +93,7 @@ function isActiveDefault() {
93
93
  }
94
94
 
95
95
  async function getTestRunnerConstructor(config, moduleRunner) {
96
- if (!config.runner) return config.mode === "test" ? TestRunner : NodeBenchmarkRunner;
96
+ if (!config.runner) return TestRunner;
97
97
  const mod = await moduleRunner.import(config.runner);
98
98
  if (!mod.default && typeof mod.default !== "function") throw new Error(`Runner must export a default function, but got ${typeof mod.default} imported from ${config.runner}`);
99
99
  return mod.default;
@@ -110,7 +110,7 @@ async function resolveTestRunner(config, moduleRunner, traces) {
110
110
  if (!testRunner.importFile) throw new Error("Runner must implement \"importFile\" method.");
111
111
  if ("__setTraces" in testRunner) testRunner.__setTraces(traces);
112
112
  const [diffOptions] = await Promise.all([loadDiffConfig(config, moduleRunner), loadSnapshotSerializers(config, moduleRunner)]);
113
- testRunner.config.diffOptions = diffOptions;
113
+ testRunner.config._diffOptions = diffOptions;
114
114
  // patch some methods, so custom runners don't need to call RPC
115
115
  const originalOnTaskUpdate = testRunner.onTaskUpdate;
116
116
  testRunner.onTaskUpdate = async (task, events) => {
@@ -652,7 +652,8 @@ function startVitestModuleRunner(options) {
652
652
  get interopDefault() {
653
653
  return state().config.deps.interopDefault;
654
654
  },
655
- getCurrentTestFilepath: () => state().filepath
655
+ getCurrentTestFilepath: () => state().filepath,
656
+ getterTracker: state().getterTracker
656
657
  });
657
658
  const moduleRunner = new VitestModuleRunner({
658
659
  spyModule: options.spyModule,
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.BVd7SaCA.js';
1
+ import { i as init } from './init.6qx-LaHs.js';
2
2
 
3
3
  if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
4
  // Store globals in case tests overwrite them
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.BVd7SaCA.js';
2
+ import { i as init } from './init.6qx-LaHs.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {
@@ -3,7 +3,7 @@ import { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { resolve } from 'pathe';
5
5
  import { ModuleRunner, EvaluatedModules } from 'vite/module-runner';
6
- import { e as environments, b as VitestTransport } from './index.CbgUM9E5.js';
6
+ import { e as environments, b as VitestTransport } from './index.nQFVd50u.js';
7
7
  import { serializeValue } from '@vitest/utils/serialize';
8
8
  import { serializeError } from '@vitest/utils/error';
9
9
  import { disableDefaultColors } from 'tinyrainbow';
@@ -118,6 +118,33 @@ function listenForErrors(state) {
118
118
  });
119
119
  }
120
120
 
121
+ class GetterTracker {
122
+ static EXPORTS_MAX_INVOCATIONS = 1e6;
123
+ invocations = /* @__PURE__ */ new Map();
124
+ excessiveInvocations = /* @__PURE__ */ new Map();
125
+ createTracker(moduleId, defineExport) {
126
+ return (name, getter) => {
127
+ const key = `${moduleId}:${name}`;
128
+ defineExport(name, () => {
129
+ const count = (this.invocations.get(key) || 0) + 1;
130
+ this.invocations.set(key, count);
131
+ if (count > GetterTracker.EXPORTS_MAX_INVOCATIONS && !this.excessiveInvocations.has(key)) this.excessiveInvocations.set(key, {
132
+ moduleId,
133
+ exportName: name
134
+ });
135
+ return getter();
136
+ });
137
+ };
138
+ }
139
+ resetInvocations() {
140
+ this.invocations.clear();
141
+ this.excessiveInvocations.clear();
142
+ }
143
+ getExcessiveInvocations() {
144
+ return [...this.excessiveInvocations.values()];
145
+ }
146
+ }
147
+
121
148
  const resolvingModules = /* @__PURE__ */ new Set();
122
149
  async function execute(method, ctx, worker, traces) {
123
150
  const prepareStart = performance.now();
@@ -149,7 +176,8 @@ async function execute(method, ctx, worker, traces) {
149
176
  onFilterStackTrace(stack) {
150
177
  return createStackString(parseStacktrace(stack));
151
178
  },
152
- metaEnv: createImportMetaEnvProxy()
179
+ metaEnv: createImportMetaEnvProxy(),
180
+ getterTracker: ctx.config.benchmark.enabled && !ctx.config.benchmark.suppressExportGetterWarnings ? new GetterTracker() : void 0
153
181
  };
154
182
  const methodName = method === "collect" ? "collectTests" : "runTests";
155
183
  if (!worker[methodName] || typeof worker[methodName] !== "function") throw new TypeError(`Test worker should expose "runTests" method. Received "${typeof worker.runTests}".`);
@@ -214,7 +242,7 @@ function init(worker) {
214
242
  process.env.VITEST_POOL_ID = String(message.poolId);
215
243
  process.env.VITEST_WORKER_ID = String(message.workerId);
216
244
  reportMemory = message.options.reportMemory;
217
- if (message.context.config.isAgent) disableDefaultColors();
245
+ if (message.context.config.disableColors) disableDefaultColors();
218
246
  traces ??= await new Traces({
219
247
  enabled: message.traces.enabled,
220
248
  sdkPath: message.traces.sdkPath
@@ -5,7 +5,7 @@ import { cleanUrl, createDefer } from '@vitest/utils/helpers';
5
5
  import { p as parse } from './acorn.B2iPLyUM.js';
6
6
  import { isAbsolute } from 'pathe';
7
7
  import { t as toBuiltin } from './modules.BJuCwlRJ.js';
8
- import { B as BareModuleMocker, n as normalizeModuleId } from './index.CbgUM9E5.js';
8
+ import { B as BareModuleMocker, n as normalizeModuleId } from './index.nQFVd50u.js';
9
9
  import 'node:fs';
10
10
  import './utils.BX5Fg8C4.js';
11
11
  import '@vitest/utils/timers';
@@ -1,21 +1,20 @@
1
- import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
2
- import { S as SerializedTestSpecification, g as SourceModuleDiagnostic, m as BrowserTesterOptions, l as BenchmarkResult } from './browser.d.BUhkKcDl.js';
3
- import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks, TestTagDefinition } from '@vitest/runner';
1
+ import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, DepOptimizationConfig, UserConfig as UserConfig$1, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
2
+ import { S as SerializedTestSpecification, f as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.BGxB4Xum.js';
3
+ import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, TestBenchmark, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, BaselineData, SequenceHooks, SequenceSetupFiles, TestTagDefinition } from '@vitest/runner';
4
4
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
5
5
  import { Writable } from 'node:stream';
6
- import { S as SerializedRootConfig, B as BrowserTraceViewMode, a as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.D91DHYaD.js';
7
- import { A as AfterSuiteRunMeta, e as SnapshotStateOptions, f as SnapshotSummary, c as SnapshotResult, U as UserConsoleLog, j as AsyncLeak, P as ProvidedContext, L as LabelColor } from './general.d.DFAHgpC2.js';
6
+ import { S as SerializedRootConfig, B as BrowserTraceViewMode, a as SerializedConfig, C as Config } from './config.d.DXq1aBpy.js';
7
+ import { U as UserConsoleLog, A as AfterSuiteRunMeta, e as SnapshotStateOptions, f as SnapshotSummary, c as SnapshotResult, j as AsyncLeak, P as ProvidedContext, L as LabelColor } from './general.d.DFAHgpC2.js';
8
8
  import { writeFile } from 'node:fs/promises';
9
- import { TaskMeta as TaskMeta$1 } from '@vitest/runner/types';
10
9
  import { PrettyFormatOptions } from '@vitest/pretty-format';
11
10
  import { SerializedDiffOptions } from '@vitest/utils/diff';
12
11
  import * as chai from 'chai';
13
12
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
14
- import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.Bu1kXGw4.js';
15
- import { O as OTELCarrier } from './rpc.d.7JZuxZ8u.js';
13
+ import { a as ContextTestEnvironment, b as WorkerExecuteContext, c as WorkerTestEnvironment } from './worker.d.yR22cs6X.js';
14
+ import { O as OTELCarrier } from './rpc.d.OQ_EZi1Z.js';
16
15
  import { MockedModule } from '@vitest/mocker';
17
16
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
18
- import { CDPSession, BrowserCommands } from 'vitest/browser';
17
+ import { CDPSession, BrowserCommands, MarkOptions } from 'vitest/browser';
19
18
  import { a as RuntimeCoverageProviderModule } from './coverage.d.g2xbl2sP.js';
20
19
  import { Console } from 'node:console';
21
20
  import { Stats } from 'node:fs';
@@ -218,6 +217,10 @@ declare class ReportedTaskImplementation {
218
217
  * Custom metadata that was attached to the test during its execution.
219
218
  */
220
219
  meta(): TaskMeta;
220
+ /**
221
+ * Console logs recorded during the test execution.
222
+ */
223
+ logs(): ReadonlyArray<UserConsoleLog>;
221
224
  }
222
225
  declare class TestCase extends ReportedTaskImplementation {
223
226
  #private;
@@ -265,6 +268,12 @@ declare class TestCase extends ReportedTaskImplementation {
265
268
  */
266
269
  artifacts(): ReadonlyArray<TestArtifact>;
267
270
  /**
271
+ * @experimental
272
+ *
273
+ * A list of benchmarks performed during the test.
274
+ */
275
+ benchmarks(): ReadonlyArray<TestBenchmark>;
276
+ /**
268
277
  * Useful information about the test like duration, memory usage, etc.
269
278
  * Diagnostic is only available after the test has finished.
270
279
  */
@@ -1209,6 +1218,11 @@ interface Reporter {
1209
1218
  */
1210
1219
  onHookEnd?: (hook: ReportedHookContext) => Awaitable<void>;
1211
1220
  onCoverage?: (coverage: unknown) => Awaitable<void>;
1221
+ /**
1222
+ * @experimental
1223
+ * Called after the benchmark is finished.
1224
+ */
1225
+ onTestCaseBenchmark?: (testCase: TestCase, benchmark: TestBenchmark) => Awaitable<void>;
1212
1226
  }
1213
1227
 
1214
1228
  interface BlobOptions {
@@ -1318,7 +1332,6 @@ interface VitestOptions {
1318
1332
  stderr?: NodeJS.WriteStream | Writable;
1319
1333
  }
1320
1334
  declare class Vitest {
1321
- readonly mode: VitestRunMode;
1322
1335
  /**
1323
1336
  * Current Vitest version.
1324
1337
  * @example '2.0.0'
@@ -1329,7 +1342,7 @@ declare class Vitest {
1329
1342
  * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
1330
1343
  * It's possible to override stdout and stderr streams when initiating Vitest.
1331
1344
  * @example
1332
- * new Vitest('test', {
1345
+ * new Vitest({
1333
1346
  * stdout: new Writable(),
1334
1347
  * })
1335
1348
  */
@@ -1373,6 +1386,14 @@ declare class Vitest {
1373
1386
  private _cache?;
1374
1387
  private _snapshot?;
1375
1388
  private _coverageProvider?;
1389
+ /**
1390
+ * @deprecated Do not rely on this property, it's always `test`. Scheduled to be removed in the next major.
1391
+ */
1392
+ readonly mode = "test";
1393
+ constructor(cliOptions: UserConfig, options?: VitestOptions);
1394
+ /**
1395
+ * @deprecated The `mode` argument is no longer used. Use `new Vitest(cliOptions, options)` instead.
1396
+ */
1376
1397
  constructor(mode: VitestRunMode, cliOptions: UserConfig, options?: VitestOptions);
1377
1398
  private _onRestartListeners;
1378
1399
  private _onClose;
@@ -1802,6 +1823,12 @@ interface BrowserConfigOptions {
1802
1823
  * @default false
1803
1824
  */
1804
1825
  exact?: boolean;
1826
+ /**
1827
+ * Format used for locator "Cannot find element" error details.
1828
+ *
1829
+ * @default 'all'
1830
+ */
1831
+ errorFormat?: "html" | "aria" | "all";
1805
1832
  };
1806
1833
  /**
1807
1834
  * Generate traces that can be viewed on https://trace.playwright.dev/
@@ -1895,10 +1922,12 @@ interface BrowserCommandContext {
1895
1922
  provider: BrowserProvider;
1896
1923
  project: TestProject;
1897
1924
  sessionId: string;
1925
+ mark: (name: string, options?: MarkOptions) => Promise<void>;
1898
1926
  triggerCommand: <K extends keyof BrowserCommands>(name: K, ...args: Parameters<BrowserCommands[K]>) => ReturnType<BrowserCommands[K]>;
1899
1927
  }
1900
1928
  interface BrowserServerStateSession {
1901
1929
  project: TestProject;
1930
+ otelCarrier?: OTELCarrier;
1902
1931
  connected: () => void;
1903
1932
  fail: (v: Error) => void;
1904
1933
  }
@@ -1976,6 +2005,7 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
1976
2005
  locators: {
1977
2006
  testIdAttribute: string;
1978
2007
  exact: boolean;
2008
+ errorFormat: "html" | "aria" | "all";
1979
2009
  };
1980
2010
  trace: {
1981
2011
  mode: BrowserTraceViewMode;
@@ -2077,6 +2107,14 @@ interface ToMatchScreenshotOptions {
2077
2107
  }
2078
2108
  interface ToMatchScreenshotComparators {}
2079
2109
 
2110
+ declare class BenchmarkManager {
2111
+ private project;
2112
+ constructor(project: TestProject);
2113
+ resolve(relativePath: string): string;
2114
+ readResult(relativePath: string): Promise<BaselineData | null>;
2115
+ writeResult(relativePath: string, data: BaselineData): Promise<void>;
2116
+ }
2117
+
2080
2118
  declare class TestProject {
2081
2119
  options?: InitializeProjectOptions | undefined;
2082
2120
  /**
@@ -2095,6 +2133,7 @@ declare class TestProject {
2095
2133
  * Temporary directory for the project. This is unique for each project. Vitest stores transformed content here.
2096
2134
  */
2097
2135
  readonly tmpDir: string;
2136
+ readonly benchmark: BenchmarkManager;
2098
2137
  private runner;
2099
2138
  private closingPromise;
2100
2139
  private typecheckFilesList;
@@ -2119,7 +2158,7 @@ declare class TestProject {
2119
2158
  * Creates a new test specification. Specifications describe how to run tests.
2120
2159
  * @param moduleId The file path
2121
2160
  */
2122
- createSpecification(moduleId: string, locationsOrOptions?: number[] | TestSpecificationOptions | undefined, pool?: string, metaOverride?: TaskMeta$1): TestSpecification;
2161
+ createSpecification(moduleId: string, locationsOrOptions?: number[] | TestSpecificationOptions | undefined, pool?: string, taskIdOverride?: string): TestSpecification;
2123
2162
  toJSON(): SerializedTestProject;
2124
2163
  /**
2125
2164
  * Vite's dev server instance. Every workspace project has its own server.
@@ -2303,6 +2342,7 @@ declare abstract class BaseReporter implements Reporter {
2303
2342
  protected silent?: boolean | "passed-only";
2304
2343
  private _filesInWatchMode;
2305
2344
  private _timeStart;
2345
+ private _perProjectBenchmarks;
2306
2346
  constructor(options?: BaseOptions);
2307
2347
  onInit(ctx: Vitest): void;
2308
2348
  log(...messages: any): void;
@@ -2311,6 +2351,7 @@ declare abstract class BaseReporter implements Reporter {
2311
2351
  onTestRunStart(_specifications: ReadonlyArray<TestSpecification>): void;
2312
2352
  onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, _reason: TestRunEndReason): void;
2313
2353
  onTestCaseResult(testCase: TestCase): void;
2354
+ onTestCaseBenchmark(testCase: TestCase, benchmark: TestBenchmark): void;
2314
2355
  onTestSuiteResult(testSuite: TestSuite): void;
2315
2356
  onTestModuleEnd(testModule: TestModule): void;
2316
2357
  protected logFailedTask(task: Task): void;
@@ -2339,7 +2380,8 @@ declare abstract class BaseReporter implements Reporter {
2339
2380
  private ellipsisPath;
2340
2381
  private printErrorsSummary;
2341
2382
  private printLeaksSummary;
2342
- reportBenchmarkSummary(files: File[]): void;
2383
+ protected printPerProjectBenchmarks(): void;
2384
+ protected printBenchmarkTable(benchmarks: readonly TestBenchmark[], basePadding: string, columnName?: string): void;
2343
2385
  private printTaskErrors;
2344
2386
  }
2345
2387
 
@@ -2427,7 +2469,18 @@ declare class GithubActionsReporter implements Reporter {
2427
2469
  }
2428
2470
 
2429
2471
  interface HTMLOptions {
2472
+ /**
2473
+ * Path to the generated HTML report.
2474
+ *
2475
+ * @default 'html/index.html'
2476
+ */
2430
2477
  outputFile?: string;
2478
+ /**
2479
+ * Inline report assets, metadata, and attachments into the generated HTML file.
2480
+ *
2481
+ * @default false
2482
+ */
2483
+ singleFile?: boolean;
2431
2484
  }
2432
2485
 
2433
2486
  type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled";
@@ -2446,6 +2499,7 @@ interface JsonAssertionResult {
2446
2499
  failureMessages: Array<string> | null;
2447
2500
  location?: Callsite | null;
2448
2501
  tags: string[];
2502
+ benchmarks: TestBenchmark[];
2449
2503
  }
2450
2504
  interface JsonTestResult {
2451
2505
  message: string;
@@ -2611,6 +2665,14 @@ type TaskWithMeta = Task & {
2611
2665
  /** Top-level describe block name */
2612
2666
  _suitename?: string;
2613
2667
  };
2668
+ /**
2669
+ * Runtime additions on top of {@link SerializedError}: `type` is set by
2670
+ * {@link state.catchError}, `VITEST_TEST_PATH` by the runtime error catcher.
2671
+ */
2672
+ type UnhandledError = SerializedError & {
2673
+ type?: string;
2674
+ VITEST_TEST_PATH?: string;
2675
+ };
2614
2676
  declare class JUnitReporter implements Reporter {
2615
2677
  private ctx;
2616
2678
  private reportFile?;
@@ -2623,10 +2685,13 @@ declare class JUnitReporter implements Reporter {
2623
2685
  onInit(ctx: Vitest): Promise<void>;
2624
2686
  writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
2625
2687
  writeLogs(task: Task, type: "err" | "out"): Promise<void>;
2688
+ writeSystemOut(task: Task): Promise<void>;
2626
2689
  private applyTemplate;
2627
2690
  writeTasks(tasks: TaskWithMeta[], filename: string, fileAbsPath: string): Promise<void>;
2628
2691
  private resolveSuiteNameTemplate;
2629
- onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
2692
+ private writeErrorElement;
2693
+ private writeUnhandledErrorsTestsuite;
2694
+ onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors?: ReadonlyArray<UnhandledError>): Promise<void>;
2630
2695
  }
2631
2696
 
2632
2697
  declare class DotReporter extends BaseReporter {
@@ -2686,40 +2751,6 @@ declare class VerboseReporter extends DefaultReporter {
2686
2751
  onTestCaseResult(test: TestCase): void;
2687
2752
  }
2688
2753
 
2689
- type FormattedBenchmarkResult = BenchmarkResult & {
2690
- id: string;
2691
- };
2692
-
2693
- declare function renderTable(options: {
2694
- tasks: Task[];
2695
- level: number;
2696
- shallow?: boolean;
2697
- showHeap: boolean;
2698
- columns: number;
2699
- slowTestThreshold: number;
2700
- compare?: Record<Task["id"], FormattedBenchmarkResult>;
2701
- }): string;
2702
-
2703
- declare class BenchmarkReporter extends DefaultReporter {
2704
- compare?: Parameters<typeof renderTable>[0]["compare"];
2705
- onInit(ctx: Vitest): Promise<void>;
2706
- onTaskUpdate(packs: TaskResultPack[]): void;
2707
- onTestSuiteResult(testSuite: TestSuite): void;
2708
- protected printTestModule(testModule: TestModule): void;
2709
- private printSuiteTable;
2710
- onTestRunEnd(testModules: ReadonlyArray<TestModule>, unhandledErrors: ReadonlyArray<SerializedError>, reason: TestRunEndReason): Promise<void>;
2711
- }
2712
-
2713
- declare class VerboseBenchmarkReporter extends BenchmarkReporter {
2714
- protected verbose: boolean;
2715
- }
2716
-
2717
- declare const BenchmarkReportsMap: {
2718
- default: typeof BenchmarkReporter;
2719
- verbose: typeof VerboseBenchmarkReporter;
2720
- };
2721
- type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
2722
-
2723
2754
  declare const ReportersMap: {
2724
2755
  default: typeof DefaultReporter;
2725
2756
  agent: typeof MinimalReporter;
@@ -2766,6 +2797,7 @@ interface TestSequencerConstructor {
2766
2797
  }
2767
2798
 
2768
2799
  interface BenchmarkUserOptions {
2800
+ enabled?: boolean;
2769
2801
  /**
2770
2802
  * Include globs for benchmark test files
2771
2803
  *
@@ -2774,7 +2806,7 @@ interface BenchmarkUserOptions {
2774
2806
  include?: string[];
2775
2807
  /**
2776
2808
  * Exclude globs for benchmark test files
2777
- * @default ['**\/node_modules/**', '**\/dist/**', '**\/cypress/**', '**\/.{idea,git,cache,output,temp}/**', '**\/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*']
2809
+ * @default []
2778
2810
  */
2779
2811
  exclude?: string[];
2780
2812
  /**
@@ -2784,30 +2816,16 @@ interface BenchmarkUserOptions {
2784
2816
  */
2785
2817
  includeSource?: string[];
2786
2818
  /**
2787
- * Custom reporters to use for output. Can contain one or more built-in reporter names, reporter instances,
2788
- * and/or paths to custom reporter files to import.
2789
- *
2790
- * @default ['default']
2791
- */
2792
- reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter | (string & {})>;
2793
- /**
2794
- * @deprecated Use `benchmark.outputJson` instead
2795
- */
2796
- outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
2797
- /**
2798
- * benchmark output file to compare against
2799
- */
2800
- compare?: string;
2801
- /**
2802
- * benchmark output file
2803
- */
2804
- outputJson?: string;
2805
- /**
2806
2819
  * Include `samples` array of benchmark results for API or custom reporter usages.
2807
2820
  * This is disabled by default to reduce memory usage.
2808
2821
  * @default false
2809
2822
  */
2810
- includeSamples?: boolean;
2823
+ retainSamples?: boolean;
2824
+ /**
2825
+ * Disable warnings when a benchmark accesses module export getters too many times.
2826
+ * @default false
2827
+ */
2828
+ suppressExportGetterWarnings?: boolean;
2811
2829
  }
2812
2830
 
2813
2831
  type BuiltinEnvironment = "node" | "jsdom" | "happy-dom" | "edge-runtime";
@@ -2838,7 +2856,10 @@ interface EnvironmentOptions {
2838
2856
  [x: string]: unknown;
2839
2857
  }
2840
2858
 
2841
- type VitestRunMode = "test" | "benchmark";
2859
+ /**
2860
+ * @deprecated
2861
+ */
2862
+ type VitestRunMode = "test";
2842
2863
  interface ProjectName {
2843
2864
  label: string;
2844
2865
  color?: LabelColor;
@@ -3290,7 +3311,7 @@ interface InlineConfig {
3290
3311
  /**
3291
3312
  * Options for @sinon/fake-timers
3292
3313
  */
3293
- fakeTimers?: FakeTimerInstallOpts;
3314
+ fakeTimers?: Config;
3294
3315
  /**
3295
3316
  * Custom handler for console.log in tests.
3296
3317
  *
@@ -3480,11 +3501,10 @@ interface InlineConfig {
3480
3501
  */
3481
3502
  expandSnapshotDiff?: boolean;
3482
3503
  /**
3483
- * By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc...
3484
- * This is also required for console log preview on Vitest UI.
3485
- * However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.
3486
- *
3487
- * This option has no effect on browser pool since Vitest preserves original logging on browser devtools.
3504
+ * By default, Vitest intercepts console output during tests to add context such as the test file and test title.
3505
+ * In browser mode, this interception is required to forward logs from the browser DevTools to the terminal.
3506
+ * It is also required for console log previews in the Vitest UI.
3507
+ * Disabling console interception can be useful when you want to debug code with normal synchronous terminal logging.
3488
3508
  *
3489
3509
  * @default false
3490
3510
  */
@@ -3652,6 +3672,10 @@ interface TypecheckConfig {
3652
3672
  */
3653
3673
  ignoreSourceErrors?: boolean;
3654
3674
  /**
3675
+ * Use TypeScript build mode.
3676
+ */
3677
+ build?: boolean;
3678
+ /**
3655
3679
  * Path to tsconfig, relative to the project root.
3656
3680
  */
3657
3681
  tsconfig?: string;
@@ -3717,14 +3741,6 @@ interface UserConfig extends InlineConfig {
3717
3741
  */
3718
3742
  clearScreen?: boolean;
3719
3743
  /**
3720
- * benchmark.compare option exposed at the top level for cli
3721
- */
3722
- compare?: string;
3723
- /**
3724
- * benchmark.outputJson option exposed at the top level for cli
3725
- */
3726
- outputJson?: string;
3727
- /**
3728
3744
  * Directory of blob reports to merge
3729
3745
  * @default '.vitest/blob'
3730
3746
  */
@@ -3748,7 +3764,6 @@ type OnUnhandledErrorCallback = (error: (TestError | Error) & {
3748
3764
  type: string;
3749
3765
  }) => boolean | void;
3750
3766
  interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "pool" | "cliExclude" | "diff" | "setupFiles" | "snapshotEnvironment" | "bail" | "name" | "vmMemoryLimit" | "fileParallelism" | "tagsFilter"> {
3751
- mode: VitestRunMode;
3752
3767
  name: ProjectName["label"];
3753
3768
  color?: ProjectName["color"];
3754
3769
  base?: string;
@@ -3773,7 +3788,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3773
3788
  };
3774
3789
  cliExclude?: string[];
3775
3790
  project: string[];
3776
- benchmark?: Required<Omit<BenchmarkUserOptions, "outputFile" | "compare" | "outputJson">> & Pick<BenchmarkUserOptions, "outputFile" | "compare" | "outputJson">;
3791
+ benchmark: Required<BenchmarkUserOptions>;
3777
3792
  shard?: {
3778
3793
  index: number;
3779
3794
  count: number;
@@ -3894,5 +3909,5 @@ interface VitestPluginContext {
3894
3909
  experimental_defineCacheKeyGenerator: (callback: CacheKeyIdGenerator) => void;
3895
3910
  }
3896
3911
 
3897
- export { DotReporter as $, CoverageMap as C, Logger as L, MinimalReporter as M, TestProject as T, DefaultReporter as Z, GithubActionsReporter as a1, HangingProcessReporter as a3, JUnitReporter as a7, TestModule as aB, TestSuite as aM, VerboseBenchmarkReporter as aS, VerboseReporter as aT, VitestPackageInstaller as aV, experimental_getRunnerTask as a_, JsonReporter as aa, ReportersMap as ap, TapFlatReporter as av, TapReporter as aw, TestCase as ay, TestCollection as az, Vitest as b, TestSpecification as e, BaseReporter as h, BenchmarkReporter as j, BenchmarkReportsMap as k };
3898
- export type { ApiConfig as A, BaseCoverageOptions as B, BuiltinEnvironment as D, BuiltinReporterOptions as E, BuiltinReporters as F, CSSModuleScopeStrategy as G, CacheKeyIdGenerator as H, CacheKeyIdGeneratorContext as I, CoverageInstrumenter as J, CoverageIstanbulOptions as K, CoverageOptions as N, CoverageProvider as O, PoolWorker as P, CoverageProviderModule as Q, ResolvedConfig as R, CoverageReporter as S, UserConfig as U, VitestRunMode as V, WorkerRequest as W, CoverageV8Options as X, CustomProviderOptions as Y, DepsOptimizationOptions as _, VitestOptions as a, FieldsWithDefaultValues as a$, EnvironmentOptions as a0, HTMLOptions as a2, InlineConfig as a4, InstrumenterOptions as a5, JUnitOptions as a6, JsonAssertionResult as a8, JsonOptions as a9, TestDiagnostic as aA, TestModuleState as aC, TestResult as aD, TestResultFailed as aE, TestResultPassed as aF, TestResultSkipped as aG, TestRunEndReason as aH, TestRunResult as aI, TestSequencerConstructor as aJ, TestSpecificationOptions as aK, TestState as aL, TestSuiteState as aN, ToMatchScreenshotComparators as aO, ToMatchScreenshotOptions as aP, TypecheckConfig as aQ, UserWorkspaceConfig as aR, VitestEnvironment as aU, VitestPluginContext as aW, WatcherTriggerPattern as aX, WorkerResponse as aY, _BrowserNames as aZ, JsonTestResult as ab, JsonTestResults as ac, ModuleDiagnostic as ad, OnServerRestartHandler as ae, OnTestsRerunHandler as af, ParentProjectBrowser as ag, Pool as ah, PoolRunnerInitializer as ai, PoolTask as aj, ProjectBrowser as ak, ProjectConfig as al, Report as am, ReportedHookContext as an, Reporter as ao, ResolveSnapshotPathHandler as aq, ResolveSnapshotPathHandlerContext as ar, ResolvedBrowserOptions as as, ResolvedProjectConfig as at, SerializedTestProject as au, TaskOptions as ax, UserProjectConfigFn as b0, UserProjectConfigExport as b1, TestProjectConfiguration as b2, TestProjectInlineConfiguration as b3, ResolvedCoverageOptions as c, ReportContext as d, PoolOptions as f, TestSequencer as g, BenchmarkBuiltinReporters as i, BenchmarkUserOptions as l, BrowserBuiltinProvider as m, BrowserCommand as n, BrowserCommandContext as o, BrowserConfigOptions as p, BrowserInstanceOption as q, BrowserModuleMocker as r, BrowserOrchestrator as s, BrowserProvider as t, BrowserProviderOption as u, BrowserScript as v, BrowserServerFactory as w, BrowserServerOptions as x, BrowserServerState as y, BrowserServerStateSession as z };
3912
+ export { CoverageMap as C, Logger as L, MinimalReporter as M, DefaultReporter as S, TestProject as T, DotReporter as Y, GithubActionsReporter as _, Vitest as a, HangingProcessReporter as a0, JUnitReporter as a4, JsonReporter as a7, TestSuite as aJ, VerboseReporter as aP, VitestPackageInstaller as aR, experimental_getRunnerTask as aW, ReportersMap as am, TapFlatReporter as as, TapReporter as at, TestCase as av, TestCollection as aw, TestModule as ay, TestSpecification as e, BaseReporter as h };
3913
+ export type { HTMLOptions as $, ApiConfig as A, BaseCoverageOptions as B, CSSModuleScopeStrategy as D, CacheKeyIdGenerator as E, CacheKeyIdGeneratorContext as F, CoverageInstrumenter as G, CoverageIstanbulOptions as H, CoverageOptions as I, CoverageProvider as J, CoverageProviderModule as K, CoverageReporter as N, CoverageV8Options as O, PoolWorker as P, CustomProviderOptions as Q, ResolvedConfig as R, UserConfig as U, VitestOptions as V, WorkerRequest as W, DepsOptimizationOptions as X, EnvironmentOptions as Z, TestProjectInlineConfiguration as a$, InlineConfig as a1, InstrumenterOptions as a2, JUnitOptions as a3, JsonAssertionResult as a5, JsonOptions as a6, JsonTestResult as a8, JsonTestResults as a9, TestResult as aA, TestResultFailed as aB, TestResultPassed as aC, TestResultSkipped as aD, TestRunEndReason as aE, TestRunResult as aF, TestSequencerConstructor as aG, TestSpecificationOptions as aH, TestState as aI, TestSuiteState as aK, ToMatchScreenshotComparators as aL, ToMatchScreenshotOptions as aM, TypecheckConfig as aN, UserWorkspaceConfig as aO, VitestEnvironment as aQ, VitestPluginContext as aS, WatcherTriggerPattern as aT, WorkerResponse as aU, _BrowserNames as aV, FieldsWithDefaultValues as aX, UserProjectConfigFn as aY, UserProjectConfigExport as aZ, TestProjectConfiguration as a_, ModuleDiagnostic as aa, OnServerRestartHandler as ab, OnTestsRerunHandler as ac, ParentProjectBrowser as ad, Pool as ae, PoolRunnerInitializer as af, PoolTask as ag, ProjectBrowser as ah, ProjectConfig as ai, Report as aj, ReportedHookContext as ak, Reporter as al, ResolveSnapshotPathHandler as an, ResolveSnapshotPathHandlerContext as ao, ResolvedBrowserOptions as ap, ResolvedProjectConfig as aq, SerializedTestProject as ar, TaskOptions as au, TestDiagnostic as ax, TestModuleState as az, VitestRunMode as b, ResolvedCoverageOptions as c, ReportContext as d, PoolOptions as f, TestSequencer as g, BenchmarkUserOptions as i, BrowserBuiltinProvider as j, BrowserCommand as k, BrowserCommandContext as l, BrowserConfigOptions as m, BrowserInstanceOption as n, BrowserModuleMocker as o, BrowserOrchestrator as p, BrowserProvider as q, BrowserProviderOption as r, BrowserScript as s, BrowserServerFactory as t, BrowserServerOptions as u, BrowserServerState as v, BrowserServerStateSession as w, BuiltinEnvironment as x, BuiltinReporterOptions as y, BuiltinReporters as z };
@@ -1,4 +1,4 @@
1
- import { File, TestArtifact, TaskResultPack, TaskEventPack, CancelReason } from '@vitest/runner';
1
+ import { File, TestBenchmark, TestArtifact, TaskResultPack, TaskEventPack, CancelReason, BaselineData } from '@vitest/runner';
2
2
  import { F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, j as AsyncLeak, A as AfterSuiteRunMeta, c as SnapshotResult } from './general.d.DFAHgpC2.js';
3
3
  import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
4
4
 
@@ -18,6 +18,19 @@ declare class Traces {
18
18
  isEnabled(): boolean;
19
19
  }
20
20
 
21
+ declare class GetterTracker {
22
+ static EXPORTS_MAX_INVOCATIONS: number;
23
+ private invocations;
24
+ private excessiveInvocations;
25
+ createTracker(moduleId: string, defineExport: (name: string, getter: () => unknown) => void): (name: string, getter: () => unknown) => void;
26
+ resetInvocations(): void;
27
+ getExcessiveInvocations(): GetterTrackerExport[];
28
+ }
29
+ interface GetterTrackerExport {
30
+ moduleId: string;
31
+ exportName: string;
32
+ }
33
+
21
34
  interface RuntimeRPC {
22
35
  fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
23
36
  resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
@@ -30,17 +43,20 @@ interface RuntimeRPC {
30
43
  onQueued: (file: File) => void;
31
44
  onCollected: (files: File[]) => Promise<void>;
32
45
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
46
+ onTestBenchmark: (testId: string, bench: TestBenchmark) => void;
33
47
  onTaskArtifactRecord: <Artifact extends TestArtifact>(testId: string, artifact: Artifact) => Promise<Artifact>;
34
48
  onTaskUpdate: (pack: TaskResultPack[], events: TaskEventPack[]) => Promise<void>;
35
49
  onCancel: (reason: CancelReason) => void;
36
50
  getCountOfFailedTests: () => number;
37
51
  snapshotSaved: (snapshot: SnapshotResult) => void;
38
52
  resolveSnapshotPath: (testPath: string) => string;
53
+ readBenchmarkResult: (relativePath: string) => Promise<BaselineData | null>;
54
+ writeBenchmarkResult: (relativePath: string, data: BaselineData) => Promise<void>;
39
55
  ensureModuleGraphEntry: (id: string, importer: string) => void;
40
56
  }
41
57
  interface RunnerRPC {
42
58
  onCancel: (reason: CancelReason) => void;
43
59
  }
44
60
 
45
- export { Traces as T };
61
+ export { GetterTracker as G, Traces as T };
46
62
  export type { OTELCarrier as O, RunnerRPC as R, RuntimeRPC as a };
@@ -30,7 +30,7 @@ async function setupCommonEnv(config) {
30
30
  if (globalSetup) return;
31
31
  globalSetup = true;
32
32
  setSafeTimers();
33
- if (config.globals) (await import('./globals.EHmmu0nC.js')).registerApiGlobally();
33
+ if (config.globals) (await import('./globals.BuY-yD0m.js')).registerApiGlobally();
34
34
  }
35
35
  function setupDefines(config) {
36
36
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext, runInContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, resolve } from 'pathe';
4
- import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.BVd7SaCA.js';
4
+ import { l as loadEnvironment, a as listenForErrors, e as emitModuleRunner } from './init.6qx-LaHs.js';
5
5
  import { distDir } from '../path.js';
6
6
  import { createCustomConsole } from './console.B3IRP8fX.js';
7
7
  import fs__default from 'node:fs';
@@ -11,7 +11,7 @@ import { findNearestPackageData } from '@vitest/utils/resolver';
11
11
  import { dirname as dirname$1 } from 'node:path';
12
12
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from '@vitest/utils/constants';
13
13
  import { getDefaultRequestStubs } from '../module-evaluator.js';
14
- import { s as startVitestModuleRunner, V as VITEST_VM_CONTEXT_SYMBOL, c as createNodeImportMeta } from './index.CbgUM9E5.js';
14
+ import { s as startVitestModuleRunner, V as VITEST_VM_CONTEXT_SYMBOL, c as createNodeImportMeta } from './index.nQFVd50u.js';
15
15
  import { p as provideWorkerState } from './utils.BX5Fg8C4.js';
16
16
 
17
17
  function interopCommonJsModule(interopDefault, mod) {
@@ -1,8 +1,8 @@
1
1
  import { FileSpecification, Task, CancelReason } from '@vitest/runner';
2
2
  import { EvaluatedModules } from 'vite/module-runner';
3
- import { a as SerializedConfig } from './config.d.D91DHYaD.js';
3
+ import { a as SerializedConfig } from './config.d.DXq1aBpy.js';
4
+ import { a as RuntimeRPC, R as RunnerRPC, G as GetterTracker } from './rpc.d.OQ_EZi1Z.js';
4
5
  import { E as Environment } from './environment.d.CrsxCzP1.js';
5
- import { a as RuntimeRPC, R as RunnerRPC } from './rpc.d.7JZuxZ8u.js';
6
6
 
7
7
  //#region src/messages.d.ts
8
8
  declare const TYPE_REQUEST: "q";
@@ -242,6 +242,7 @@ interface WorkerGlobalState {
242
242
  evaluatedModules: EvaluatedModules;
243
243
  resolvingModules: Set<string>;
244
244
  moduleExecutionInfo: Map<string, any>;
245
+ getterTracker?: GetterTracker;
245
246
  onCancel: (listener: (reason: CancelReason) => unknown) => void;
246
247
  onCleanup: (listener: () => unknown) => void;
247
248
  providedContext: Record<string, any>;