vitest 4.1.5 → 5.0.0-beta.2

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 (80) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/browser.d.ts +9 -9
  3. package/dist/browser.js +4 -4
  4. package/dist/chunks/{base.RR7zL1h0.js → base.Opc_YHkk.js} +10 -11
  5. package/dist/chunks/browser.d.BUhkKcDl.d.ts +899 -0
  6. package/dist/chunks/{cac.DJJmV0dT.js → cac.8N4bOkkB.js} +23 -11
  7. package/dist/chunks/{cli-api.Cjt90eJu.js → cli-api.B0RFke2g.js} +5799 -353
  8. package/dist/chunks/{config.d.A1h_Y6Jt.d.ts → config.d.D91DHYaD.d.ts} +11 -3
  9. package/dist/chunks/{console.3WNpx0tS.js → console.B3IRP8fX.js} +3 -1
  10. package/dist/chunks/{constants.CPYnjOGj.js → constants.-juJ8b_4.js} +1 -1
  11. package/dist/chunks/{coverage.d.BZtK59WP.d.ts → coverage.d.g2xbl2sP.d.ts} +4 -0
  12. package/dist/chunks/{creator.DgVhQm5q.js → creator.BqL2U_x4.js} +1 -1
  13. package/dist/chunks/{defaults.9aQKnqFk.js → defaults.szbHWQun.js} +4 -2
  14. package/dist/chunks/environment.d-DOJxxZV9.d.DOJxxZV9.d.ts +17 -0
  15. package/dist/chunks/general.d.DFAHgpC2.d.ts +247 -0
  16. package/dist/chunks/{global.d.DVsSRdQ5.d.ts → global.d.DhbKSQoV.d.ts} +4 -5
  17. package/dist/chunks/{globals.Dj1TGiMC.js → globals.EHmmu0nC.js} +15 -14
  18. package/dist/chunks/{index.DXx9Dtk7.js → index.CViWo__T.js} +5 -5
  19. package/dist/chunks/{startVitestModuleRunner.bRl2_oI_.js → index.CbgUM9E5.js} +731 -5
  20. package/dist/chunks/{test.DNmyFkvJ.js → index.D_7-4CaB.js} +2659 -14
  21. package/dist/chunks/{init-forks.UV3ZQGQH.js → init-forks.DMge3WTt.js} +1 -1
  22. package/dist/chunks/{init-threads.D3eCsY76.js → init-threads.eIoyCTon.js} +1 -1
  23. package/dist/chunks/{init.D98-gwRW.js → init.BVd7SaCA.js} +3 -5
  24. package/dist/chunks/{nativeModuleMocker.BRN2oBJd.js → nativeModuleMocker.DKpFw0pk.js} +3 -2
  25. package/dist/chunks/{index.BCY_7LL2.js → nativeModuleRunner.BOeMnHl4.js} +43 -12
  26. package/dist/chunks/node.CwFbQqI1.js +47 -0
  27. package/dist/chunks/{reporters.d.CEnv6XRv.d.ts → plugin.d.cIKZEZ16.d.ts} +306 -19
  28. package/dist/chunks/plugins.DrsmdUE2.js +37 -0
  29. package/dist/chunks/{rpc.MzXet3jl.js → rpc.DFRWVnRh.js} +16 -1
  30. package/dist/chunks/{rpc.d.B_8sPU0w.d.ts → rpc.d.7JZuxZ8u.d.ts} +19 -3
  31. package/dist/chunks/{setup-common.DYx3LtFI.js → setup-common.Hpq30zVk.js} +7 -3
  32. package/dist/chunks/{utils.BS4fH3nR.js → utils.DKODp04v.js} +3 -4
  33. package/dist/chunks/{vm.DVLYObm9.js → vm.2okbRRME.js} +6 -6
  34. package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.Bu1kXGw4.d.ts} +3 -3
  35. package/dist/cli.js +2 -2
  36. package/dist/config.cjs +4 -2
  37. package/dist/config.d.ts +21 -18
  38. package/dist/config.js +2 -2
  39. package/dist/index.d.ts +84 -22
  40. package/dist/index.js +15 -13
  41. package/dist/module-evaluator.d.ts +5 -3
  42. package/dist/module-evaluator.js +1 -1
  43. package/dist/node.d.ts +114 -19
  44. package/dist/node.js +21 -26
  45. package/dist/runtime.d.ts +40 -4
  46. package/dist/runtime.js +5 -6
  47. package/dist/{chunks/traces.DT5aQ62U.js → traces.js} +1 -1
  48. package/dist/worker.d.ts +5 -5
  49. package/dist/worker.js +21 -23
  50. package/dist/workers/forks.js +21 -23
  51. package/dist/workers/runVmTests.js +17 -16
  52. package/dist/workers/threads.js +21 -23
  53. package/dist/workers/vmForks.js +7 -9
  54. package/dist/workers/vmThreads.js +7 -9
  55. package/package.json +21 -38
  56. package/dist/chunks/benchmark.CX_oY03V.js +0 -40
  57. package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +0 -24
  58. package/dist/chunks/browser.d.BcoexmFG.d.ts +0 -62
  59. package/dist/chunks/coverage.DM_a_rWm.js +0 -1087
  60. package/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -17
  61. package/dist/chunks/index.DC7d2Pf8.js +0 -729
  62. package/dist/chunks/index.DdgEv5B1.js +0 -42
  63. package/dist/chunks/index.UpGiHP7g.js +0 -4255
  64. package/dist/chunks/nativeModuleRunner.BIakptoF.js +0 -36
  65. package/dist/chunks/node.COQbm6gK.js +0 -14
  66. package/dist/chunks/plugin.d.BM2TCi12.d.ts +0 -38
  67. package/dist/chunks/suite.d.udJtyAgw.d.ts +0 -10
  68. package/dist/chunks/traces.d.D2T_R8rx.d.ts +0 -60
  69. package/dist/coverage.d.ts +0 -123
  70. package/dist/coverage.js +0 -27
  71. package/dist/environments.d.ts +0 -22
  72. package/dist/environments.js +0 -5
  73. package/dist/reporters.d.ts +0 -27
  74. package/dist/reporters.js +0 -26
  75. package/dist/runners.d.ts +0 -70
  76. package/dist/runners.js +0 -19
  77. package/dist/snapshot.d.ts +0 -9
  78. package/dist/snapshot.js +0 -6
  79. package/dist/suite.d.ts +0 -5
  80. package/dist/suite.js +0 -8
@@ -1,22 +1,22 @@
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';
1
3
  import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks, TestTagDefinition } from '@vitest/runner';
2
4
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { a as AfterSuiteRunMeta, U as UserConsoleLog, A as AsyncLeak, P as ProvidedContext, O as OTELCarrier, L as LabelColor } from './traces.d.D2T_R8rx.js';
4
5
  import { Writable } from 'node:stream';
5
- import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
- import { b as SerializedRootConfig, B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.A1h_Y6Jt.js';
7
- import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.BcoexmFG.js';
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';
8
+ import { writeFile } from 'node:fs/promises';
9
+ import { TaskMeta as TaskMeta$1 } from '@vitest/runner/types';
8
10
  import { PrettyFormatOptions } from '@vitest/pretty-format';
9
- import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
10
11
  import { SerializedDiffOptions } from '@vitest/utils/diff';
11
- import { chai } from '@vitest/expect';
12
+ import * as chai from 'chai';
12
13
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
13
- import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.ZpHpO4yb.js';
14
- import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.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';
15
16
  import { MockedModule } from '@vitest/mocker';
16
17
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
17
18
  import { CDPSession, BrowserCommands } from 'vitest/browser';
18
- import { a as RuntimeCoverageProviderModule } from './coverage.d.BZtK59WP.js';
19
- import { SnapshotManager } from '@vitest/snapshot/manager';
19
+ import { a as RuntimeCoverageProviderModule } from './coverage.d.g2xbl2sP.js';
20
20
  import { Console } from 'node:console';
21
21
  import { Stats } from 'node:fs';
22
22
 
@@ -71,6 +71,80 @@ interface ConstructorOptionsOverride {
71
71
  resources?: "usable";
72
72
  }
73
73
 
74
+ interface Report {
75
+ /**
76
+ * The root directory for this scope.
77
+ *
78
+ * ```ts
79
+ * const report = vitest.createReport('my-json-reporter');
80
+ *
81
+ * // Is <project-root>/.vitest/my-json-reporter
82
+ * const root = report.root
83
+ * ```
84
+ */
85
+ root: string;
86
+ /**
87
+ * Clean up the report directory for this scope.
88
+ *
89
+ * By default, if `--merge-reports` is used, this method will not delete existing reports.
90
+ * To force deletion of existing reports, pass `true` as an argument.
91
+ *
92
+ * ```ts
93
+ * const report = vitest.createReport('my-json-reporter');
94
+ *
95
+ * // Removes everything inside <project-root>/.vitest/my-json-reporter/
96
+ * await report.clean()
97
+ * ```
98
+ */
99
+ clean: (force?: boolean) => Promise<void>;
100
+ /**
101
+ * Write a file to the report directory for this scope.
102
+ * By default the file will be written with UTF-8 encoding.
103
+ * The filename is relative to the scope directory.
104
+ *
105
+ * ```ts
106
+ * const report = vitest.createReport('my-json-reporter');
107
+ *
108
+ * // Writes file to .vitest/my-json-reporter/test-report.json
109
+ * await report.writeFile('test-report.json', JSON.stringify(results))
110
+ * ```
111
+ */
112
+ writeFile: (filename: string, content: Parameters<typeof writeFile>[1], encoding?: BufferEncoding) => Promise<void>;
113
+ /**
114
+ * Read a file from the report directory for this scope.
115
+ *
116
+ * ```ts
117
+ * const report = vitest.createReport('my-json-reporter');
118
+ *
119
+ * // Reads file from .vitest/my-json-reporter/test-report.json
120
+ * const content: string = await report.readFile('test-report.json')
121
+ * ```
122
+ */
123
+ readFile: (filename: string, encoding?: BufferEncoding) => Promise<string>;
124
+ /**
125
+ * Read contents of the report directory for this scope.
126
+ *
127
+ * ```ts
128
+ * const report = vitest.createReport('my-json-reporter');
129
+ *
130
+ * // Reads contents from .vitest/my-json-reporter
131
+ * const filenames: string[] = await report.readdir()
132
+ * ```
133
+ */
134
+ readdir: () => Promise<string[]>;
135
+ /**
136
+ * Delete a file from the report directory for this scope.
137
+ *
138
+ * ```ts
139
+ * const report = vitest.createReport('my-json-reporter');
140
+ *
141
+ * // Deletes file from .vitest/my-json-reporter/test-report.json
142
+ * await report.delete('test-report.json')
143
+ * ```
144
+ */
145
+ delete: (filename: string) => Promise<void>;
146
+ }
147
+
74
148
  interface TestSpecificationOptions {
75
149
  testNamePattern?: RegExp;
76
150
  testIds?: string[];
@@ -693,7 +767,7 @@ interface CoverageProviderModule extends RuntimeCoverageProviderModule {
693
767
  type CoverageReporter = keyof ReportOptions | (string & {});
694
768
  type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends keyof ReportOptions ? ReportOptions[ReporterName] extends never ? [ReporterName, object] : [ReporterName, Partial<ReportOptions[ReporterName]>] : [ReporterName, Record<string, unknown>];
695
769
  /** Fields that have default values. Internally these will always be defined. */
696
- type FieldsWithDefaultValues = "provider" | "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency" | "reporter" | "excludeAfterRemap" | "ignoreClassMethods" | "skipFull" | "watermarks";
770
+ type FieldsWithDefaultValues = "provider" | "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "exclude" | "reportOnFailure" | "allowExternal" | "processingConcurrency" | "reporter" | "excludeAfterRemap" | "ignoreClassMethods" | "skipFull" | "watermarks" | "autoAttachSubprocess";
697
771
  type ResolvedCoverageOptions = CoverageOptions & Required<Pick<CoverageOptions, FieldsWithDefaultValues>> & {
698
772
  reporter: CoverageReporterWithOptions[];
699
773
  htmlDir?: string;
@@ -820,6 +894,13 @@ interface CoverageOptions {
820
894
  */
821
895
  processingConcurrency?: number;
822
896
  /**
897
+ * Track coverage of the `node:child_process` and `node:worker_threads` spawned during test run.
898
+ * Supported only by `v8` provider.
899
+ *
900
+ * @default false
901
+ */
902
+ autoAttachSubprocess?: boolean;
903
+ /**
823
904
  * Set to array of class method names to ignore for coverage
824
905
  *
825
906
  * @default []
@@ -939,6 +1020,17 @@ interface VCSProvider {
939
1020
  findChangedFiles(options: VCSProviderOptions): Promise<string[]>;
940
1021
  }
941
1022
 
1023
+ declare class SnapshotManager {
1024
+ options: Omit<SnapshotStateOptions, "snapshotEnvironment">;
1025
+ summary: SnapshotSummary;
1026
+ extension: string;
1027
+ constructor(options: Omit<SnapshotStateOptions, "snapshotEnvironment">);
1028
+ clear(): void;
1029
+ add(result: SnapshotResult): void;
1030
+ resolvePath<T = any>(testPath: string, context?: T): string;
1031
+ resolveRawPath(testPath: string, rawPath: string): string;
1032
+ }
1033
+
942
1034
  declare class TypeCheckError extends Error {
943
1035
  message: string;
944
1036
  stacks: ParsedStack[];
@@ -946,13 +1038,17 @@ declare class TypeCheckError extends Error {
946
1038
  constructor(message: string, stacks: ParsedStack[]);
947
1039
  }
948
1040
 
1041
+ interface CapturePrintErrorResult {
1042
+ nearest: ParsedStack | undefined;
1043
+ output: string;
1044
+ }
1045
+
949
1046
  interface ErrorOptions {
950
1047
  type?: string;
951
1048
  fullStack?: boolean;
952
1049
  project?: TestProject;
953
1050
  verbose?: boolean;
954
1051
  screenshotPaths?: string[];
955
- task?: Task;
956
1052
  showCodeFrame?: boolean;
957
1053
  }
958
1054
  type Listener = () => void;
@@ -972,6 +1068,7 @@ declare class Logger {
972
1068
  clearScreen(message: string, force?: boolean): void;
973
1069
  private _clearScreen;
974
1070
  printError(err: unknown, options?: ErrorOptions): void;
1071
+ formatError(err: unknown, options?: ErrorOptions): CapturePrintErrorResult;
975
1072
  deprecate(message: string): void;
976
1073
  clearHighlightCache(filename?: string): void;
977
1074
  highlight(filename: string, source: string): string;
@@ -1116,6 +1213,7 @@ interface Reporter {
1116
1213
 
1117
1214
  interface BlobOptions {
1118
1215
  outputFile?: string;
1216
+ label?: string;
1119
1217
  }
1120
1218
  declare class BlobReporter implements Reporter {
1121
1219
  start: number;
@@ -1521,6 +1619,10 @@ declare class Vitest {
1521
1619
  * Check if the project with a given name should be included.
1522
1620
  */
1523
1621
  matchesProjectFilter(name: string): boolean;
1622
+ /**
1623
+ * Create a report that's scoped to a specific reporter directory.
1624
+ */
1625
+ createReport(scope: string): Report;
1524
1626
  }
1525
1627
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1526
1628
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
@@ -1565,6 +1667,37 @@ interface BrowserProvider {
1565
1667
  }
1566
1668
  type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
1567
1669
  interface _BrowserNames {}
1670
+ interface BrowserTraceViewOptions {
1671
+ /**
1672
+ * Enable Vitest trace view artifacts collection.
1673
+ *
1674
+ * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
1675
+ *
1676
+ * @default false
1677
+ * @experimental
1678
+ */
1679
+ enabled?: boolean;
1680
+ /**
1681
+ * Capture canvas pixels in trace view snapshots.
1682
+ *
1683
+ * This uses rrweb's canvas snapshot support and can increase trace artifact size.
1684
+ * In the trace viewer, this enables a weaker replay iframe sandbox because rrweb needs scripts to redraw canvas data.
1685
+ *
1686
+ * @default false
1687
+ * @experimental
1688
+ */
1689
+ recordCanvas?: boolean;
1690
+ /**
1691
+ * Inline loaded `<img>` element pixels in trace view snapshots.
1692
+ *
1693
+ * This uses rrweb's image inlining support. It improves offline replay for still images,
1694
+ * but can increase trace artifact size and does not preserve original image resource bytes.
1695
+ *
1696
+ * @default false
1697
+ * @experimental
1698
+ */
1699
+ inlineImages?: boolean;
1700
+ }
1568
1701
  type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
1569
1702
  interface BrowserInstanceOption extends Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
1570
1703
  /**
@@ -1696,6 +1829,16 @@ interface BrowserConfigOptions {
1696
1829
  snapshots?: boolean;
1697
1830
  };
1698
1831
  /**
1832
+ *
1833
+ * Enable Vitest trace view artifacts collection.
1834
+ *
1835
+ * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
1836
+ *
1837
+ * @default false
1838
+ * @experimental
1839
+ */
1840
+ traceView?: boolean | BrowserTraceViewOptions;
1841
+ /**
1699
1842
  * Directory where screenshots will be saved when page.screenshot() is called
1700
1843
  * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
1701
1844
  * If this is set, it will be resolved relative to the project root.
@@ -1841,6 +1984,7 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
1841
1984
  snapshots?: boolean;
1842
1985
  sources?: boolean;
1843
1986
  };
1987
+ traceView: Required<BrowserTraceViewOptions>;
1844
1988
  }
1845
1989
  type ToMatchScreenshotResolvePath = (data: {
1846
1990
  /**
@@ -1910,6 +2054,12 @@ type ToMatchScreenshotResolvePath = (data: {
1910
2054
  * if none is provided, its default value.
1911
2055
  */
1912
2056
  attachmentsDir: string;
2057
+ /**
2058
+ * The {@linkcode https://vitest.dev/api/advanced/test-project|TestProject} the test belongs to.
2059
+ *
2060
+ * @experimental
2061
+ */
2062
+ project: TestProject;
1913
2063
  }) => string;
1914
2064
  interface ToMatchScreenshotOptions {
1915
2065
  /**
@@ -1969,7 +2119,7 @@ declare class TestProject {
1969
2119
  * Creates a new test specification. Specifications describe how to run tests.
1970
2120
  * @param moduleId The file path
1971
2121
  */
1972
- createSpecification(moduleId: string, locationsOrOptions?: number[] | TestSpecificationOptions | undefined, pool?: string): TestSpecification;
2122
+ createSpecification(moduleId: string, locationsOrOptions?: number[] | TestSpecificationOptions | undefined, pool?: string, metaOverride?: TaskMeta$1): TestSpecification;
1973
2123
  toJSON(): SerializedTestProject;
1974
2124
  /**
1975
2125
  * Vite's dev server instance. Every workspace project has its own server.
@@ -2344,15 +2494,88 @@ declare class JsonReporter implements Reporter {
2344
2494
  }
2345
2495
 
2346
2496
  interface ClassnameTemplateVariables {
2497
+ /** Relative path from the root (e.g. `src/foo.test.ts`) */
2347
2498
  filename: string;
2499
+ /** Absolute file path */
2348
2500
  filepath: string;
2501
+ /** File basename without directory (e.g. `foo.test.ts`) */
2502
+ basename: string;
2503
+ /** Ancestor describe block names joined by {@link JUnitOptions.ancestorSeparator} */
2504
+ classname: string;
2505
+ /** Leaf test title (the string passed to `it`/`test`) */
2506
+ title: string;
2507
+ /** Top-level describe block name, or empty string when the test has no enclosing describe */
2508
+ suitename: string;
2509
+ /** Vitest project name */
2510
+ displayName: string;
2511
+ }
2512
+ interface SuiteNameTemplateVariables {
2513
+ /** Absolute file path */
2514
+ filepath: string;
2515
+ /** Relative path from the root (e.g. `src/foo.test.ts`) */
2516
+ filename: string;
2517
+ /** File basename without directory (e.g. `foo.test.ts`) */
2518
+ basename: string;
2519
+ /** Vitest project name */
2520
+ displayName: string;
2521
+ /**
2522
+ * The name of the first top-level `describe` block in the file.
2523
+ * Falls back to the file basename when the file has no top-level describe.
2524
+ */
2525
+ title: string;
2349
2526
  }
2350
2527
  interface JUnitOptions {
2351
2528
  outputFile?: string;
2352
2529
  /**
2353
- * Template for the classname attribute. Can be either a string or a function. The string can contain placeholders {filename} and {filepath}.
2530
+ * Template for the `classname` attribute of `<testcase>`.
2531
+ *
2532
+ * Can be a template string or a function.
2533
+ *
2534
+ * Supported placeholders:
2535
+ * - `{filename}` – relative path from root (e.g. `src/foo.test.ts`)
2536
+ * - `{filepath}` – absolute file path
2537
+ * - `{basename}` – file name without directory (e.g. `foo.test.ts`)
2538
+ * - `{classname}` – ancestor describe names joined by {@link ancestorSeparator}
2539
+ * - `{title}` – leaf test title
2540
+ * - `{suitename}` – top-level describe block name
2541
+ * - `{displayName}` – Vitest project name
2542
+ *
2543
+ * @default relative file path from root
2354
2544
  */
2355
2545
  classnameTemplate?: string | ((classnameVariables: ClassnameTemplateVariables) => string);
2546
+ /**
2547
+ * Template for the `name` attribute of `<testcase>`.
2548
+ *
2549
+ * Can be a template string or a function. Supports the same placeholders as
2550
+ * {@link classnameTemplate}.
2551
+ *
2552
+ * When not set the full test title including ancestor describe hierarchy is used
2553
+ * (current default behaviour, e.g. `outer > inner > test name`).
2554
+ */
2555
+ titleTemplate?: string | ((titleVariables: ClassnameTemplateVariables) => string);
2556
+ /**
2557
+ * Template for the `name` attribute of `<testsuite>`.
2558
+ *
2559
+ * Can be a template string or a function.
2560
+ *
2561
+ * Supported placeholders:
2562
+ * - `{title}` – first top-level describe name (falls back to file basename)
2563
+ * - `{filename}` – relative path from root
2564
+ * - `{filepath}` – absolute file path
2565
+ * - `{basename}` – file basename
2566
+ * - `{displayName}` – Vitest project name
2567
+ *
2568
+ * When not set the relative file path from root is used (current default behaviour).
2569
+ */
2570
+ suiteNameTemplate?: string | ((suiteNameVariables: SuiteNameTemplateVariables) => string);
2571
+ /**
2572
+ * Separator used to join ancestor describe block names when building the
2573
+ * `{classname}` template variable (and the default testcase name when
2574
+ * {@link titleTemplate} is not set).
2575
+ *
2576
+ * @default ' > '
2577
+ */
2578
+ ancestorSeparator?: string;
2356
2579
  suiteName?: string;
2357
2580
  /**
2358
2581
  * Write <system-out> and <system-err> for console output
@@ -2368,7 +2591,26 @@ interface JUnitOptions {
2368
2591
  * Hostname to use in the report. By default, it uses os.hostname()
2369
2592
  */
2370
2593
  hostname?: string;
2594
+ /**
2595
+ * Include stack traces in test failure reports.
2596
+ * @default true
2597
+ */
2598
+ stackTrace?: boolean;
2371
2599
  }
2600
+ /**
2601
+ * Internal task type that carries pre-computed template metadata.
2602
+ * The three underscore-prefixed fields are set by {@link flattenTasks} and
2603
+ * consumed only within the reporter. They are deliberately not part of the
2604
+ * public `Task` interface.
2605
+ */
2606
+ type TaskWithMeta = Task & {
2607
+ /** Original leaf test title before hierarchy prefix was prepended */
2608
+ _leafName?: string;
2609
+ /** Ancestor describe names joined by the active separator */
2610
+ _classname?: string;
2611
+ /** Top-level describe block name */
2612
+ _suitename?: string;
2613
+ };
2372
2614
  declare class JUnitReporter implements Reporter {
2373
2615
  private ctx;
2374
2616
  private reportFile?;
@@ -2381,7 +2623,9 @@ declare class JUnitReporter implements Reporter {
2381
2623
  onInit(ctx: Vitest): Promise<void>;
2382
2624
  writeElement(name: string, attrs: Record<string, any>, children: () => Promise<void>): Promise<void>;
2383
2625
  writeLogs(task: Task, type: "err" | "out"): Promise<void>;
2384
- writeTasks(tasks: Task[], filename: string): Promise<void>;
2626
+ private applyTemplate;
2627
+ writeTasks(tasks: TaskWithMeta[], filename: string, fileAbsPath: string): Promise<void>;
2628
+ private resolveSuiteNameTemplate;
2385
2629
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
2386
2630
  }
2387
2631
 
@@ -3208,6 +3452,14 @@ interface InlineConfig {
3208
3452
  */
3209
3453
  chaiConfig?: ChaiConfig;
3210
3454
  /**
3455
+ * Sets length limit for formatted values interpolated into generated task titles.
3456
+ *
3457
+ * This affects values inserted by APIs like `test.each` and `test.for`.
3458
+ *
3459
+ * @default 40
3460
+ */
3461
+ taskTitleValueFormatTruncate?: number;
3462
+ /**
3211
3463
  * Stop test execution when given number of tests have failed.
3212
3464
  */
3213
3465
  bail?: number;
@@ -3252,7 +3504,7 @@ interface InlineConfig {
3252
3504
  /**
3253
3505
  * Directory path for storing attachments created by `context.annotate`
3254
3506
  *
3255
- * @default '.vitest-attachments'
3507
+ * @default '.vitest/attachments'
3256
3508
  */
3257
3509
  attachmentsDir?: string;
3258
3510
  /**
@@ -3474,7 +3726,7 @@ interface UserConfig extends InlineConfig {
3474
3726
  outputJson?: string;
3475
3727
  /**
3476
3728
  * Directory of blob reports to merge
3477
- * @default '.vitest-reports'
3729
+ * @default '.vitest/blob'
3478
3730
  */
3479
3731
  mergeReports?: string;
3480
3732
  /**
@@ -3549,6 +3801,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, "project" | "config"
3549
3801
  vmMemoryLimit?: UserConfig["vmMemoryLimit"];
3550
3802
  dumpDir?: string;
3551
3803
  tagsFilter?: string[];
3804
+ mergeReportsLabel?: string;
3552
3805
  experimental: Omit<Required<UserConfig>["experimental"], "importDurations"> & {
3553
3806
  importDurations: {
3554
3807
  print: boolean | "on-warn";
@@ -3607,5 +3860,39 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3607
3860
  });
3608
3861
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3609
3862
 
3610
- export { Logger as L, MinimalReporter as M, TestProject as T, Vitest as V, CoverageMap as a$, DefaultReporter as a0, DotReporter as a2, GithubActionsReporter as a4, HangingProcessReporter as a6, JUnitReporter as a9, TestCase as aB, TestCollection as aC, TestModule as aE, TestSuite as aP, VerboseBenchmarkReporter as aU, VerboseReporter as aV, VitestPackageInstaller as aX, experimental_getRunnerTask as a_, JsonReporter as ac, ReportersMap as ar, TapFlatReporter as ay, TapReporter as az, TestSpecification as h, BaseReporter as l, BenchmarkReporter as n, BenchmarkReportsMap as o };
3611
- export type { CustomProviderOptions as $, ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserServerFactory as D, BrowserServerOptions as E, FieldsWithDefaultValues as F, BrowserServerState as G, BrowserServerStateSession as H, InlineConfig as I, BuiltinEnvironment as J, BuiltinReporterOptions as K, BuiltinReporters as N, CSSModuleScopeStrategy as O, PoolWorker as P, CoverageInstrumenter as Q, ResolvedConfig as R, CoverageIstanbulOptions as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, CoverageProvider as X, CoverageProviderModule as Y, CoverageReporter as Z, CoverageV8Options as _, TestProjectConfiguration as a, DepsOptimizationOptions as a1, EnvironmentOptions as a3, HTMLOptions as a5, InstrumenterOptions as a7, JUnitOptions as a8, TaskOptions as aA, TestDiagnostic as aD, TestModuleState as aF, TestResult as aG, TestResultFailed as aH, TestResultPassed as aI, TestResultSkipped as aJ, TestRunEndReason as aK, TestRunResult as aL, TestSequencerConstructor as aM, TestSpecificationOptions as aN, TestState as aO, TestSuiteState as aQ, ToMatchScreenshotComparators as aR, ToMatchScreenshotOptions as aS, TypecheckConfig as aT, VitestEnvironment as aW, WorkerResponse as aY, _BrowserNames as aZ, JsonAssertionResult as aa, JsonOptions as ab, JsonTestResult as ad, JsonTestResults as ae, ModuleDiagnostic as af, OnServerRestartHandler as ag, OnTestsRerunHandler as ah, ParentProjectBrowser as ai, Pool as aj, PoolRunnerInitializer as ak, PoolTask as al, ProjectBrowser as am, ProjectConfig as an, ReportContext as ao, ReportedHookContext as ap, Reporter as aq, ResolveSnapshotPathHandler as as, ResolveSnapshotPathHandlerContext as at, ResolvedBrowserOptions as au, ResolvedCoverageOptions as av, ResolvedProjectConfig as aw, SerializedTestProject as ax, UserProjectConfigFn as b, UserProjectConfigExport as c, TestProjectInlineConfiguration as d, UserConfig as e, VitestRunMode as f, VitestOptions as g, PoolOptions as i, WorkerRequest as j, TestSequencer as k, BenchmarkBuiltinReporters as m, BenchmarkUserOptions as p, BrowserBuiltinProvider as q, BrowserCommand as r, BrowserCommandContext as s, BrowserConfigOptions as t, BrowserInstanceOption as u, BrowserModuleMocker as v, BrowserOrchestrator as w, BrowserProvider as x, BrowserProviderOption as y, BrowserScript as z };
3863
+ /**
3864
+ * Generate a unique cache identifier.
3865
+ *
3866
+ * Return `false` to disable caching of the file.
3867
+ * @experimental
3868
+ */
3869
+ interface CacheKeyIdGenerator {
3870
+ (context: CacheKeyIdGeneratorContext): string | undefined | null | false;
3871
+ }
3872
+ /**
3873
+ * @experimental
3874
+ */
3875
+ interface CacheKeyIdGeneratorContext {
3876
+ environment: DevEnvironment;
3877
+ id: string;
3878
+ sourceCode: string;
3879
+ }
3880
+
3881
+ interface VitestPluginContext {
3882
+ vitest: Vitest;
3883
+ project: TestProject;
3884
+ injectTestProjects: (config: TestProjectConfiguration | TestProjectConfiguration[]) => Promise<TestProject[]>;
3885
+ /**
3886
+ * Define a generator that will be applied before hashing the cache key.
3887
+ *
3888
+ * Use this to make sure Vitest generates correct hash. It is a good idea
3889
+ * to define this function if your plugin can be registered with different options.
3890
+ *
3891
+ * This is called only if `experimental.fsModuleCache` is defined.
3892
+ * @experimental
3893
+ */
3894
+ experimental_defineCacheKeyGenerator: (callback: CacheKeyIdGenerator) => void;
3895
+ }
3896
+
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 };
@@ -0,0 +1,37 @@
1
+ import { plugins } from '@vitest/pretty-format';
2
+
3
+ const serialize = (val, config, indentation, depth, refs, printer) => {
4
+ // Serialize a non-default name, even if config.printFunctionName is false.
5
+ const name = val.getMockName();
6
+ const nameString = name === "vi.fn()" ? "" : ` ${name}`;
7
+ let callsString = "";
8
+ if (val.mock.calls.length !== 0) {
9
+ const indentationNext = indentation + config.indent;
10
+ callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ", " : ","}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? "" : ","}${config.spacingOuter}${indentation}}`;
11
+ }
12
+ return `[MockFunction${nameString}]${callsString}`;
13
+ };
14
+ const test = (val) => val && !!val._isMockFunction;
15
+ const plugin = {
16
+ serialize,
17
+ test
18
+ };
19
+
20
+ const { DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent, AsymmetricMatcher } = plugins;
21
+ let PLUGINS = [
22
+ ReactTestComponent,
23
+ ReactElement,
24
+ DOMElement,
25
+ DOMCollection,
26
+ Immutable,
27
+ AsymmetricMatcher,
28
+ plugin
29
+ ];
30
+ function addSerializer(plugin) {
31
+ PLUGINS = [plugin].concat(PLUGINS);
32
+ }
33
+ function getSerializers() {
34
+ return PLUGINS;
35
+ }
36
+
37
+ export { addSerializer as a, getSerializers as g };
@@ -1,3 +1,5 @@
1
+ import { dirname, resolve } from 'pathe';
2
+ import { EvaluatedModules } from 'vite/module-runner';
1
3
  import { getSafeTimers } from '@vitest/utils/timers';
2
4
  import { c as createBirpc } from './index.Chj8NDwU.js';
3
5
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
@@ -74,6 +76,19 @@ function resetDate() {
74
76
  globalThis.Date = RealDate;
75
77
  }
76
78
 
79
+ // TODO: this is not needed in Vite 7.2+
80
+ class VitestEvaluatedModules extends EvaluatedModules {
81
+ getModuleSourceMapById(id) {
82
+ const map = super.getModuleSourceMapById(id);
83
+ if (map != null && !("_patched" in map)) {
84
+ map._patched = true;
85
+ const dir = dirname(map.url);
86
+ map.resolvedSources = (map.map.sources || []).map((s) => resolve(dir, s || ""));
87
+ }
88
+ return map;
89
+ }
90
+ }
91
+
77
92
  const { get } = Reflect;
78
93
  function withSafeTimers(fn) {
79
94
  const { setTimeout, clearTimeout, nextTick, setImmediate, clearImmediate } = getSafeTimers();
@@ -141,4 +156,4 @@ function rpc() {
141
156
  return rpc;
142
157
  }
143
158
 
144
- export { RealDate as R, rpcDone as a, resetDate as b, createRuntimeRpc as c, mockDate as m, onCancel as o, rpc as r };
159
+ export { RealDate as R, VitestEvaluatedModules as V, rpcDone as a, resetDate as b, createRuntimeRpc as c, mockDate as m, onCancel as o, rpc as r };
@@ -1,7 +1,22 @@
1
1
  import { File, TestArtifact, TaskResultPack, TaskEventPack, CancelReason } from '@vitest/runner';
2
- import { SnapshotResult } from '@vitest/snapshot';
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
- import { O as OTELCarrier, F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AsyncLeak, a as AfterSuiteRunMeta } from './traces.d.D2T_R8rx.js';
4
+
5
+ interface OTELCarrier {
6
+ traceparent?: string;
7
+ tracestate?: string;
8
+ }
9
+ interface TracesOptions {
10
+ enabled: boolean;
11
+ watchMode?: boolean;
12
+ sdkPath?: string;
13
+ tracerName?: string;
14
+ }
15
+ declare class Traces {
16
+ #private;
17
+ constructor(options: TracesOptions);
18
+ isEnabled(): boolean;
19
+ }
5
20
 
6
21
  interface RuntimeRPC {
7
22
  fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
@@ -27,4 +42,5 @@ interface RunnerRPC {
27
42
  onCancel: (reason: CancelReason) => void;
28
43
  }
29
44
 
30
- export type { RuntimeRPC as R, RunnerRPC as a };
45
+ export { Traces as T };
46
+ export type { OTELCarrier as O, RunnerRPC as R, RuntimeRPC as a };
@@ -1,11 +1,15 @@
1
1
  import { r as resolveCoverageProviderModule } from './coverage.CTzCuANN.js';
2
- import { addSerializer } from '@vitest/snapshot';
3
2
  import { setSafeTimers } from '@vitest/utils/timers';
4
3
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
4
+ import { a as addSerializer } from './plugins.DrsmdUE2.js';
5
5
 
6
6
  async function startCoverageInsideWorker(options, loader, runtimeOptions) {
7
7
  const coverageModule = await resolveCoverageProviderModule(options, loader);
8
- if (coverageModule) return coverageModule.startCoverage?.(runtimeOptions);
8
+ if (coverageModule) return coverageModule.startCoverage?.({
9
+ ...runtimeOptions,
10
+ autoAttachSubprocess: options.autoAttachSubprocess,
11
+ reportsDirectory: options.reportsDirectory
12
+ });
9
13
  return null;
10
14
  }
11
15
  async function takeCoverageInsideWorker(options, loader) {
@@ -26,7 +30,7 @@ async function setupCommonEnv(config) {
26
30
  if (globalSetup) return;
27
31
  globalSetup = true;
28
32
  setSafeTimers();
29
- if (config.globals) (await import('./globals.Dj1TGiMC.js')).registerApiGlobally();
33
+ if (config.globals) (await import('./globals.EHmmu0nC.js')).registerApiGlobally();
30
34
  }
31
35
  function setupDefines(config) {
32
36
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,4 +1,5 @@
1
1
  import { stripVTControlCharacters } from 'node:util';
2
+ import { truncateString as truncateString$1 } from '@vitest/utils/display';
2
3
  import { slash } from '@vitest/utils/helpers';
3
4
  import { isAbsolute, relative, dirname, basename } from 'pathe';
4
5
  import c from 'tinyrainbow';
@@ -144,9 +145,7 @@ function padSummaryTitle(str) {
144
145
  return c.dim(`${str.padStart(11)} `);
145
146
  }
146
147
  function truncateString(text, maxLength) {
147
- const plainText = stripVTControlCharacters(text);
148
- if (plainText.length <= maxLength) return text;
149
- return `${plainText.slice(0, maxLength - 1)}…`;
148
+ return truncateString$1(stripVTControlCharacters(text), maxLength);
150
149
  }
151
150
  function capitalize(text) {
152
151
  return `${text[0].toUpperCase()}${text.slice(1)}`;
@@ -186,4 +185,4 @@ var utils = /*#__PURE__*/Object.freeze({
186
185
  withLabel: withLabel
187
186
  });
188
187
 
189
- export { F_POINTER as F, taskFail as a, F_CHECK as b, F_DOWN_RIGHT as c, divider as d, errorBanner as e, formatTimeString as f, formatProjectName as g, getStateSymbol as h, getStateString as i, formatTime as j, countTestErrors as k, F_TREE_NODE_END as l, F_TREE_NODE_MIDDLE as m, noun as n, F_RIGHT as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, truncateString as t, utils as u, withLabel as w };
188
+ export { F_POINTER as F, formatTimeString as a, taskFail as b, F_CHECK as c, divider as d, errorBanner as e, formatProjectName as f, F_DOWN_RIGHT as g, getStateSymbol as h, getStateString as i, formatTime as j, countTestErrors as k, F_TREE_NODE_END as l, F_TREE_NODE_MIDDLE as m, noun as n, F_RIGHT as o, padSummaryTitle as p, renderSnapshotSummary as r, separator as s, truncateString as t, utils as u, withLabel as w };