vitest 4.1.4 → 5.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/browser.d.ts +4 -4
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{base.Cv_yNPUJ.js → base.CgusHodA.js} +8 -8
  4. package/dist/chunks/{browser.d.C0zGu1u9.d.ts → browser.d.Bn-qMB1Y.d.ts} +2 -2
  5. package/dist/chunks/{cac.wyYWMVI-.js → cac.DSVGM2li.js} +18 -7
  6. package/dist/chunks/{cli-api.lDy4N9kC.js → cli-api.MLtHkHGf.js} +88 -23
  7. package/dist/chunks/{config.d.ChUh6-ad.d.ts → config.d.BgVe1oN5.d.ts} +12 -1
  8. package/dist/chunks/{coverage.Da5gzbsu.js → coverage.nIKqs-BM.js} +38 -8
  9. package/dist/chunks/{defaults.9aQKnqFk.js → defaults.pr789SUS.js} +1 -0
  10. package/dist/chunks/{global.d.D74z04P1.d.ts → global.d.DVsSRdQ5.d.ts} +1 -1
  11. package/dist/chunks/{globals.BVDtJR67.js → globals.BYX6Co2c.js} +2 -2
  12. package/dist/chunks/{index.C3MK_gXn.js → index.BSgubW8K.js} +2 -2
  13. package/dist/chunks/{index.C-zNJvRx.js → index.BcGySndd.js} +1 -1
  14. package/dist/chunks/{index.BCY_7LL2.js → index.CesbTg1C.js} +9 -9
  15. package/dist/chunks/{index.BMXTnDNz.js → index.yJ2D83a4.js} +32 -30
  16. package/dist/chunks/{init-forks.UV3ZQGQH.js → init-forks.DuteEWBS.js} +1 -1
  17. package/dist/chunks/{init-threads.D3eCsY76.js → init-threads.BSdvBCTO.js} +1 -1
  18. package/dist/chunks/{init.D98-gwRW.js → init.Dc7N0jh0.js} +1 -1
  19. package/dist/chunks/{nativeModuleMocker.BRN2oBJd.js → nativeModuleMocker.BKN7j4tC.js} +1 -1
  20. package/dist/chunks/{nativeModuleRunner.BIakptoF.js → nativeModuleRunner.WlMdOB52.js} +1 -1
  21. package/dist/chunks/{plugin.d.CEihBODF.d.ts → plugin.d.BkNgFMgP.d.ts} +1 -1
  22. package/dist/chunks/{reporters.d.BwkR0iL5.d.ts → reporters.d.GtfMm3Oa.d.ts} +206 -20
  23. package/dist/chunks/{rpc.d.BFMWpdph.d.ts → rpc.d.B_8sPU0w.d.ts} +2 -44
  24. package/dist/chunks/{setup-common.BDwxwUWG.js → setup-common.CYy2gJEr.js} +1 -1
  25. package/dist/chunks/{startVitestModuleRunner.bRl2_oI_.js → startVitestModuleRunner.vRT958-n.js} +2 -2
  26. package/dist/chunks/{test.D1JkM1w4.js → test.C8WyxAQk.js} +3 -2
  27. package/dist/chunks/traces.d.D2T_R8rx.d.ts +60 -0
  28. package/dist/chunks/{utils.BS4fH3nR.js → utils.DzYdXqCH.js} +2 -3
  29. package/dist/chunks/{vm.DVLYObm9.js → vm.CPtbsAeh.js} +5 -5
  30. package/dist/chunks/{worker.d.CckNUvI5.d.ts → worker.d.irleQtmS.d.ts} +2 -2
  31. package/dist/cli.js +1 -1
  32. package/dist/config.cjs +1 -0
  33. package/dist/config.d.ts +12 -10
  34. package/dist/config.js +1 -1
  35. package/dist/coverage.d.ts +9 -7
  36. package/dist/coverage.js +5 -4
  37. package/dist/index.d.ts +15 -12
  38. package/dist/index.js +2 -2
  39. package/dist/module-evaluator.d.ts +2 -2
  40. package/dist/node.d.ts +11 -10
  41. package/dist/node.js +11 -11
  42. package/dist/reporters.d.ts +9 -8
  43. package/dist/reporters.js +4 -4
  44. package/dist/runners.d.ts +2 -2
  45. package/dist/runners.js +1 -1
  46. package/dist/runtime.js +1 -1
  47. package/dist/worker.d.ts +4 -4
  48. package/dist/worker.js +9 -9
  49. package/dist/workers/forks.js +10 -10
  50. package/dist/workers/runVmTests.js +4 -4
  51. package/dist/workers/threads.js +10 -10
  52. package/dist/workers/vmForks.js +4 -4
  53. package/dist/workers/vmThreads.js +4 -4
  54. package/package.json +14 -14
  55. package/dist/chunks/traces.d.402V_yFI.d.ts +0 -18
@@ -1,8 +1,8 @@
1
- import fs, { statSync, realpathSync } from 'node:fs';
1
+ import fs__default, { statSync, realpathSync } from 'node:fs';
2
2
  import { builtinModules, createRequire } from 'node:module';
3
3
  import path, { win32, dirname, join } from 'node:path';
4
4
  import process$1 from 'node:process';
5
- import fs$1 from 'node:fs/promises';
5
+ import fs from 'node:fs/promises';
6
6
  import { fileURLToPath as fileURLToPath$1, pathToFileURL as pathToFileURL$1, URL as URL$1 } from 'node:url';
7
7
  import { isAbsolute } from 'pathe';
8
8
  import assert from 'node:assert';
@@ -561,7 +561,7 @@ function read(jsonPath, {base, specifier}) {
561
561
  let string;
562
562
 
563
563
  try {
564
- string = fs.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
564
+ string = fs__default.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
565
565
  } catch (error) {
566
566
  const exception = /** @type {ErrnoException} */ (error);
567
567
 
@@ -2194,7 +2194,7 @@ async function findUp$1(name, {
2194
2194
  while (directory) {
2195
2195
  const filePath = isAbsoluteName ? name : path.join(directory, name);
2196
2196
  try {
2197
- const stats = await fs$1.stat(filePath); // eslint-disable-line no-await-in-loop
2197
+ const stats = await fs.stat(filePath); // eslint-disable-line no-await-in-loop
2198
2198
  if ((type === 'file' && stats.isFile()) || (type === 'directory' && stats.isDirectory())) {
2199
2199
  return filePath;
2200
2200
  }
@@ -2222,7 +2222,7 @@ function findUpSync(name, {
2222
2222
  const filePath = isAbsoluteName ? name : path.join(directory, name);
2223
2223
 
2224
2224
  try {
2225
- const stats = fs.statSync(filePath, {throwIfNoEntry: false});
2225
+ const stats = fs__default.statSync(filePath, {throwIfNoEntry: false});
2226
2226
  if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
2227
2227
  return filePath;
2228
2228
  }
@@ -2273,8 +2273,8 @@ function getPackageJsonPath(name, options = {}) {
2273
2273
  return searchPackageJSON(entry);
2274
2274
  }
2275
2275
  const readFile = quansync({
2276
- async: (id) => fs.promises.readFile(id, "utf8"),
2277
- sync: (id) => fs.readFileSync(id, "utf8")
2276
+ async: (id) => fs__default.promises.readFile(id, "utf8"),
2277
+ sync: (id) => fs__default.readFileSync(id, "utf8")
2278
2278
  });
2279
2279
  const getPackageInfo = quansync(function* (name, options = {}) {
2280
2280
  const packageJsonPath = getPackageJsonPath(name, options);
@@ -2313,7 +2313,7 @@ function searchPackageJSON(dir) {
2313
2313
  return;
2314
2314
  dir = newDir;
2315
2315
  packageJsonPath = join(dir, "package.json");
2316
- if (fs.existsSync(packageJsonPath))
2316
+ if (fs__default.existsSync(packageJsonPath))
2317
2317
  break;
2318
2318
  }
2319
2319
  return packageJsonPath;
@@ -2324,7 +2324,7 @@ const findUp = quansync({
2324
2324
  });
2325
2325
  const loadPackageJSON = quansync(function* (cwd = process$1.cwd()) {
2326
2326
  const path = yield findUp("package.json", { cwd });
2327
- if (!path || !fs.existsSync(path))
2327
+ if (!path || !fs__default.existsSync(path))
2328
2328
  return null;
2329
2329
  return JSON.parse(yield readFile(path));
2330
2330
  });
@@ -1,11 +1,12 @@
1
- import fs, { existsSync, readFileSync, writeFileSync, promises } from 'node:fs';
1
+ import fs__default, { existsSync, readFileSync, writeFileSync, promises } from 'node:fs';
2
2
  import { getTests, generateHash, createTaskName, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTestName, hasFailed, getSuites, getTasks, getFullName } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import { relative, basename, resolve as resolve$1, join, normalize, dirname } from 'pathe';
5
5
  import c from 'tinyrainbow';
6
- import { t as truncateString, e as errorBanner, F as F_POINTER, d as divider, f as formatTimeString, a as taskFail, s as separator, b as F_CHECK, c as F_DOWN_RIGHT, g as formatProjectName, h as getStateSymbol, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, i as getStateString$1, j as formatTime, k as countTestErrors, l as F_TREE_NODE_END, m as F_TREE_NODE_MIDDLE, n as noun, o as F_RIGHT } from './utils.BS4fH3nR.js';
6
+ import { t as truncateString, e as errorBanner, F as F_POINTER, d as divider, f as formatTimeString, a as taskFail, s as separator, b as F_CHECK, c as F_DOWN_RIGHT, g as formatProjectName, h as getStateSymbol, w as withLabel, r as renderSnapshotSummary, p as padSummaryTitle, i as getStateString$1, j as formatTime, k as countTestErrors, l as F_TREE_NODE_END, m as F_TREE_NODE_MIDDLE, n as noun, o as F_RIGHT } from './utils.DzYdXqCH.js';
7
7
  import { stripVTControlCharacters } from 'node:util';
8
8
  import { isPrimitive, toArray, deepMerge, notNullish } from '@vitest/utils/helpers';
9
+ import { readdir, stat, readFile, mkdir, writeFile } from 'node:fs/promises';
9
10
  import { performance as performance$1 } from 'node:perf_hooks';
10
11
  import { defaultStackIgnorePatterns, parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
11
12
  import { i as isTTY } from './env.D4Lgay0q.js';
@@ -17,7 +18,6 @@ import { x } from 'tinyexec';
17
18
  import { distDir } from '../path.js';
18
19
  import { parseAstAsync } from 'vite';
19
20
  import { positionToOffset, lineSplitRE } from '@vitest/utils/offset';
20
- import { readdir, stat, readFile, mkdir, writeFile } from 'node:fs/promises';
21
21
  import { createRequire } from 'node:module';
22
22
 
23
23
  function groupBy(collection, iteratee) {
@@ -1837,6 +1837,7 @@ const skipErrorProperties = new Set([
1837
1837
  "VITEST_TEST_PATH",
1838
1838
  "__vitest_rollup_error__",
1839
1839
  "__vitest_error_context__",
1840
+ "__vitest_test_syntax_error__",
1840
1841
  ...Object.getOwnPropertyNames(Error.prototype),
1841
1842
  ...Object.getOwnPropertyNames(Object.prototype)
1842
1843
  ]);
@@ -3135,28 +3136,6 @@ class DefaultReporter extends BaseReporter {
3135
3136
  }
3136
3137
  }
3137
3138
 
3138
- class AgentReporter extends DefaultReporter {
3139
- renderSucceed = false;
3140
- constructor(options = {}) {
3141
- super({
3142
- silent: "passed-only",
3143
- ...options,
3144
- summary: false
3145
- });
3146
- }
3147
- onTestRunStart(specifications) {
3148
- super.onTestRunStart(specifications);
3149
- this.renderSucceed = false;
3150
- }
3151
- printTestModule(testModule) {
3152
- if (testModule.state() !== "failed") return;
3153
- super.printTestModule(testModule);
3154
- }
3155
- printTestCase(moduleState, test) {
3156
- if (test.result().state === "failed") super.printTestCase(moduleState, test);
3157
- }
3158
- }
3159
-
3160
3139
  class DotReporter extends BaseReporter {
3161
3140
  renderer;
3162
3141
  tests = /* @__PURE__ */ new Map();
@@ -3886,6 +3865,28 @@ class JUnitReporter {
3886
3865
  }
3887
3866
  }
3888
3867
 
3868
+ class MinimalReporter extends DefaultReporter {
3869
+ renderSucceed = false;
3870
+ constructor(options = {}) {
3871
+ super({
3872
+ silent: "passed-only",
3873
+ ...options,
3874
+ summary: false
3875
+ });
3876
+ }
3877
+ onTestRunStart(specifications) {
3878
+ super.onTestRunStart(specifications);
3879
+ this.renderSucceed = false;
3880
+ }
3881
+ printTestModule(testModule) {
3882
+ if (testModule.state() !== "failed") return;
3883
+ super.printTestModule(testModule);
3884
+ }
3885
+ printTestCase(moduleState, test) {
3886
+ if (test.result().state === "failed") super.printTestCase(moduleState, test);
3887
+ }
3888
+ }
3889
+
3889
3890
  function yamlString(str) {
3890
3891
  if (!str) return "";
3891
3892
  return `"${str.replace(/"/g, "\\\"")}"`;
@@ -4172,7 +4173,7 @@ class BenchmarkReporter extends DefaultReporter {
4172
4173
  if (this.ctx.config.benchmark?.compare) {
4173
4174
  const compareFile = pathe.resolve(this.ctx.config.root, this.ctx.config.benchmark?.compare);
4174
4175
  try {
4175
- this.compare = flattenFormattedBenchmarkReport(JSON.parse(await fs.promises.readFile(compareFile, "utf-8")));
4176
+ this.compare = flattenFormattedBenchmarkReport(JSON.parse(await fs__default.promises.readFile(compareFile, "utf-8")));
4176
4177
  } catch (e) {
4177
4178
  this.error(`Failed to read '${compareFile}'`, e);
4178
4179
  }
@@ -4219,9 +4220,9 @@ class BenchmarkReporter extends DefaultReporter {
4219
4220
  if (outputFile) {
4220
4221
  outputFile = pathe.resolve(this.ctx.config.root, outputFile);
4221
4222
  const outputDirectory = pathe.dirname(outputFile);
4222
- if (!fs.existsSync(outputDirectory)) await fs.promises.mkdir(outputDirectory, { recursive: true });
4223
+ if (!fs__default.existsSync(outputDirectory)) await fs__default.promises.mkdir(outputDirectory, { recursive: true });
4223
4224
  const output = createBenchmarkJsonReport(testModules.map((t) => t.task.file));
4224
- await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
4225
+ await fs__default.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
4225
4226
  this.log(`Benchmark report written to ${outputFile}`);
4226
4227
  }
4227
4228
  }
@@ -4238,7 +4239,8 @@ const BenchmarkReportsMap = {
4238
4239
 
4239
4240
  const ReportersMap = {
4240
4241
  "default": DefaultReporter,
4241
- "agent": AgentReporter,
4242
+ "agent": MinimalReporter,
4243
+ "minimal": MinimalReporter,
4242
4244
  "blob": BlobReporter,
4243
4245
  "verbose": VerboseReporter,
4244
4246
  "dot": DotReporter,
@@ -4251,4 +4253,4 @@ const ReportersMap = {
4251
4253
  "github-actions": GithubActionsReporter
4252
4254
  };
4253
4255
 
4254
- export { AgentReporter as A, BenchmarkReporter as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JUnitReporter as J, ReportersMap as R, TapFlatReporter as T, VerboseBenchmarkReporter as V, BenchmarkReportsMap as a, DotReporter as b, JsonReporter as c, TapReporter as d, VerboseReporter as e, createIndexLocationsMap as f, TraceMap as g, ancestor as h, printError as i, Typechecker as j, generateCodeFrame as k, escapeRegExp as l, createDefinesScript as m, groupBy as n, originalPositionFor as o, parse as p, BlobReporter as q, readBlobs as r, stringify as s, convertTasksToEvents as t, stdout as u, wildcardPatternToRegExp as w };
4256
+ export { BenchmarkReporter as B, DefaultReporter as D, GithubActionsReporter as G, HangingProcessReporter as H, JUnitReporter as J, MinimalReporter as M, ReportersMap as R, TapFlatReporter as T, VerboseBenchmarkReporter as V, BenchmarkReportsMap as a, DotReporter as b, JsonReporter as c, TapReporter as d, VerboseReporter as e, createIndexLocationsMap as f, TraceMap as g, ancestor as h, printError as i, Typechecker as j, generateCodeFrame as k, escapeRegExp as l, createDefinesScript as m, groupBy as n, originalPositionFor as o, parse as p, BlobReporter as q, readBlobs as r, stringify as s, convertTasksToEvents as t, stdout as u, wildcardPatternToRegExp as w };
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.D98-gwRW.js';
1
+ import { i as init } from './init.Dc7N0jh0.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.D98-gwRW.js';
2
+ import { i as init } from './init.Dc7N0jh0.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 { b as VitestTransport } from './startVitestModuleRunner.bRl2_oI_.js';
6
+ import { b as VitestTransport } from './startVitestModuleRunner.vRT958-n.js';
7
7
  import { e as environments } from './index.DC7d2Pf8.js';
8
8
  import { serializeValue } from '@vitest/utils/serialize';
9
9
  import { serializeError } from '@vitest/utils/error';
@@ -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 './startVitestModuleRunner.bRl2_oI_.js';
8
+ import { B as BareModuleMocker, n as normalizeModuleId } from './startVitestModuleRunner.vRT958-n.js';
9
9
  import 'node:fs';
10
10
  import './utils.BX5Fg8C4.js';
11
11
  import '@vitest/utils/timers';
@@ -1,5 +1,5 @@
1
1
  import { pathToFileURL } from 'node:url';
2
- import { r as resolveModule } from './index.BCY_7LL2.js';
2
+ import { r as resolveModule } from './index.CesbTg1C.js';
3
3
  import { resolve } from 'pathe';
4
4
  import { ModuleRunner } from 'vite/module-runner';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { DevEnvironment } from 'vite';
2
- import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.BwkR0iL5.js';
2
+ import { V as Vitest, T as TestProject, a as TestProjectConfiguration } from './reporters.d.GtfMm3Oa.js';
3
3
 
4
4
  /**
5
5
  * Generate a unique cache identifier.
@@ -1,17 +1,17 @@
1
1
  import { TaskMeta, Suite, File, SerializableRetry, TestAnnotation, TestArtifact, ImportDuration, Test, Task, TaskResultPack, FileSpecification, CancelReason, SequenceSetupFiles, SequenceHooks, TestTagDefinition } from '@vitest/runner';
2
2
  import { TestError, SerializedError, Arrayable, ParsedStack, Awaitable } from '@vitest/utils';
3
- import { A as AfterSuiteRunMeta, U as UserConsoleLog, b as AsyncLeak, P as ProvidedContext, L as LabelColor } from './rpc.d.BFMWpdph.js';
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
4
  import { Writable } from 'node:stream';
5
5
  import { DevEnvironment, TransformResult as TransformResult$1, ViteDevServer, Plugin, UserConfig as UserConfig$1, DepOptimizationConfig, ServerOptions, ConfigEnv, AliasOptions } from 'vite';
6
- import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.C0zGu1u9.js';
7
- import { B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.ChUh6-ad.js';
6
+ import { b as SerializedRootConfig, B as BrowserTraceViewMode, S as SerializedConfig, F as FakeTimerInstallOpts } from './config.d.BgVe1oN5.js';
7
+ import { S as SerializedTestSpecification, c as SourceModuleDiagnostic, B as BrowserTesterOptions } from './browser.d.Bn-qMB1Y.js';
8
+ import { writeFile } from 'node:fs/promises';
8
9
  import { PrettyFormatOptions } from '@vitest/pretty-format';
9
10
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
10
11
  import { SerializedDiffOptions } from '@vitest/utils/diff';
11
12
  import { chai } from '@vitest/expect';
12
13
  import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
13
- import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.CckNUvI5.js';
14
- import { O as OTELCarrier } from './traces.d.402V_yFI.js';
14
+ import { c as ContextTestEnvironment, d as WorkerExecuteContext, e as WorkerTestEnvironment } from './worker.d.irleQtmS.js';
15
15
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
16
16
  import { MockedModule } from '@vitest/mocker';
17
17
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
@@ -72,6 +72,80 @@ interface ConstructorOptionsOverride {
72
72
  resources?: "usable";
73
73
  }
74
74
 
75
+ interface Report {
76
+ /**
77
+ * The root directory for this scope.
78
+ *
79
+ * ```ts
80
+ * const report = vitest.createReport('my-json-reporter');
81
+ *
82
+ * // Is <project-root>/.vitest/my-json-reporter
83
+ * const root = report.root
84
+ * ```
85
+ */
86
+ root: string;
87
+ /**
88
+ * Clean up the report directory for this scope.
89
+ *
90
+ * By default, if `--merge-reports` is used, this method will not delete existing reports.
91
+ * To force deletion of existing reports, pass `true` as an argument.
92
+ *
93
+ * ```ts
94
+ * const report = vitest.createReport('my-json-reporter');
95
+ *
96
+ * // Removes everything inside <project-root>/.vitest/my-json-reporter/
97
+ * await report.clean()
98
+ * ```
99
+ */
100
+ clean: (force?: boolean) => Promise<void>;
101
+ /**
102
+ * Write a file to the report directory for this scope.
103
+ * By default the file will be written with UTF-8 encoding.
104
+ * The filename is relative to the scope directory.
105
+ *
106
+ * ```ts
107
+ * const report = vitest.createReport('my-json-reporter');
108
+ *
109
+ * // Writes file to .vitest/my-json-reporter/test-report.json
110
+ * await report.writeFile('test-report.json', JSON.stringify(results))
111
+ * ```
112
+ */
113
+ writeFile: (filename: string, content: Parameters<typeof writeFile>[1], encoding?: BufferEncoding) => Promise<void>;
114
+ /**
115
+ * Read a file from the report directory for this scope.
116
+ *
117
+ * ```ts
118
+ * const report = vitest.createReport('my-json-reporter');
119
+ *
120
+ * // Reads file from .vitest/my-json-reporter/test-report.json
121
+ * const content: string = await report.readFile('test-report.json')
122
+ * ```
123
+ */
124
+ readFile: (filename: string, encoding?: BufferEncoding) => Promise<string>;
125
+ /**
126
+ * Read contents of the report directory for this scope.
127
+ *
128
+ * ```ts
129
+ * const report = vitest.createReport('my-json-reporter');
130
+ *
131
+ * // Reads contents from .vitest/my-json-reporter
132
+ * const filenames: string[] = await report.readdir()
133
+ * ```
134
+ */
135
+ readdir: () => Promise<string[]>;
136
+ /**
137
+ * Delete a file from the report directory for this scope.
138
+ *
139
+ * ```ts
140
+ * const report = vitest.createReport('my-json-reporter');
141
+ *
142
+ * // Deletes file from .vitest/my-json-reporter/test-report.json
143
+ * await report.delete('test-report.json')
144
+ * ```
145
+ */
146
+ delete: (filename: string) => Promise<void>;
147
+ }
148
+
75
149
  interface TestSpecificationOptions {
76
150
  testNamePattern?: RegExp;
77
151
  testIds?: string[];
@@ -98,19 +172,19 @@ declare class TestSpecification {
98
172
  /**
99
173
  * Line numbers of the test locations to run.
100
174
  */
101
- readonly testLines: number[] | undefined;
175
+ testLines: number[] | undefined;
102
176
  /**
103
177
  * Regular expression pattern to filter test names.
104
178
  */
105
- readonly testNamePattern: RegExp | undefined;
179
+ testNamePattern: RegExp | undefined;
106
180
  /**
107
181
  * The ids of tasks inside of this specification to run.
108
182
  */
109
- readonly testIds: string[] | undefined;
183
+ testIds: string[] | undefined;
110
184
  /**
111
185
  * The tags of tests to run.
112
186
  */
113
- readonly testTagsFilter: string[] | undefined;
187
+ testTagsFilter: string[] | undefined;
114
188
  /**
115
189
  * Test module associated with the specification. This will be `undefined` if tests have not been run yet.
116
190
  */
@@ -827,6 +901,33 @@ interface CoverageOptions {
827
901
  */
828
902
  ignoreClassMethods?: string[];
829
903
  /**
904
+ * Custom instrumenter factory to use instead of the default `istanbul-lib-instrument`.
905
+ *
906
+ * The factory receives the same runtime coverage options Vitest passes to its
907
+ * built-in Istanbul instrumenter and must return an object implementing the
908
+ * `CoverageInstrumenter` interface.
909
+ *
910
+ * This allows using faster instrumenters (e.g., oxc-coverage-instrument, SWC) while
911
+ * keeping the Istanbul coverage pipeline for collection, merging, and reporting.
912
+ *
913
+ * @example
914
+ * ```ts
915
+ * import { defineConfig } from 'vitest/config'
916
+ * import { createOxcInstrumenter } from 'oxc-coverage-instrument/vitest'
917
+ *
918
+ * export default defineConfig({
919
+ * test: {
920
+ * coverage: {
921
+ * provider: 'istanbul',
922
+ * instrumenter: options => createOxcInstrumenter(options),
923
+ * }
924
+ * }
925
+ * })
926
+ *
927
+ * @experimental
928
+ */
929
+ instrumenter?: (options: InstrumenterOptions) => CoverageInstrumenter;
930
+ /**
830
931
  * Directory of HTML coverage output to be served in UI mode and HTML reporter.
831
932
  * This is automatically configured for builtin reporter with html output (`html`, `html-spa`, and `lcov` reporters).
832
933
  * Use this option to override with custom coverage reporting location.
@@ -863,6 +964,34 @@ interface Thresholds {
863
964
  /** Thresholds for lines */
864
965
  lines?: number;
865
966
  }
967
+ /**
968
+ * Options passed to the custom instrumenter factory.
969
+ */
970
+ interface InstrumenterOptions {
971
+ /** Global variable name that Vitest uses to store coverage data at runtime. */
972
+ coverageVariable: string;
973
+ /** Global scope where the coverage variable is attached at runtime. */
974
+ coverageGlobalScope: string;
975
+ /** Whether the coverage global scope should be resolved through an evaluated function. */
976
+ coverageGlobalScopeFunc: boolean;
977
+ /** Class method names to exclude from function coverage. */
978
+ ignoreClassMethods: string[];
979
+ }
980
+ /**
981
+ * Interface for custom coverage instrumenters.
982
+ *
983
+ * Matches the subset of istanbul-lib-instrument's `Instrumenter` that Vitest
984
+ * actually uses. Implement this to plug in a faster instrumenter while keeping
985
+ * the Istanbul coverage pipeline for collection, merging, and reporting.
986
+ */
987
+ interface CoverageInstrumenter {
988
+ /** Instrument source code synchronously. Returns the instrumented code string. */
989
+ instrumentSync: (code: string, filename: string, inputSourceMap?: any) => string;
990
+ /** Get the source map of the last instrumented file. */
991
+ lastSourceMap: () => any;
992
+ /** Get the Istanbul-compatible file coverage object of the last instrumented file. */
993
+ lastFileCoverage: () => any;
994
+ }
866
995
  /** @deprecated Use `CoverageOptions` instead */
867
996
  interface CoverageV8Options extends CoverageOptions {}
868
997
  /** @deprecated Use `CoverageOptions` instead */
@@ -1272,6 +1401,7 @@ declare class Vitest {
1272
1401
  * Return project that has the root (or "global") config.
1273
1402
  */
1274
1403
  getRootProject(): TestProject;
1404
+ get serializedRootConfig(): SerializedRootConfig;
1275
1405
  getProjectByName(name: string): TestProject;
1276
1406
  /**
1277
1407
  * Import a file using Vite module runner. The file will be transformed by Vite and executed in a separate context.
@@ -1466,6 +1596,10 @@ declare class Vitest {
1466
1596
  * Check if the project with a given name should be included.
1467
1597
  */
1468
1598
  matchesProjectFilter(name: string): boolean;
1599
+ /**
1600
+ * Create a report that's scoped to a specific reporter directory.
1601
+ */
1602
+ createReport(scope: string): Report;
1469
1603
  }
1470
1604
  type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
1471
1605
  type OnTestsRerunHandler = (testFiles: TestSpecification[]) => Promise<void> | void;
@@ -1510,6 +1644,37 @@ interface BrowserProvider {
1510
1644
  }
1511
1645
  type BrowserBuiltinProvider = "webdriverio" | "playwright" | "preview";
1512
1646
  interface _BrowserNames {}
1647
+ interface BrowserTraceViewOptions {
1648
+ /**
1649
+ * Enable Vitest trace view artifacts collection.
1650
+ *
1651
+ * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
1652
+ *
1653
+ * @default false
1654
+ * @experimental
1655
+ */
1656
+ enabled?: boolean;
1657
+ /**
1658
+ * Capture canvas pixels in trace view snapshots.
1659
+ *
1660
+ * This uses rrweb's canvas snapshot support and can increase trace artifact size.
1661
+ * In the trace viewer, this enables a weaker replay iframe sandbox because rrweb needs scripts to redraw canvas data.
1662
+ *
1663
+ * @default false
1664
+ * @experimental
1665
+ */
1666
+ recordCanvas?: boolean;
1667
+ /**
1668
+ * Inline loaded `<img>` element pixels in trace view snapshots.
1669
+ *
1670
+ * This uses rrweb's image inlining support. It improves offline replay for still images,
1671
+ * but can increase trace artifact size and does not preserve original image resource bytes.
1672
+ *
1673
+ * @default false
1674
+ * @experimental
1675
+ */
1676
+ inlineImages?: boolean;
1677
+ }
1513
1678
  type UnsupportedProperties = "browser" | "typecheck" | "alias" | "sequence" | "root" | "pool" | "runner" | "api" | "deps" | "environment" | "environmentOptions" | "server" | "benchmark" | "name";
1514
1679
  interface BrowserInstanceOption extends Omit<ProjectConfig, UnsupportedProperties>, Pick<BrowserConfigOptions, "headless" | "locators" | "viewport" | "testerHtmlPath" | "screenshotDirectory" | "screenshotFailures"> {
1515
1680
  /**
@@ -1641,6 +1806,16 @@ interface BrowserConfigOptions {
1641
1806
  snapshots?: boolean;
1642
1807
  };
1643
1808
  /**
1809
+ *
1810
+ * Enable Vitest trace view artifacts collection.
1811
+ *
1812
+ * This option controls Vitest's own trace-view pipeline, independently from provider-specific trace retention.
1813
+ *
1814
+ * @default false
1815
+ * @experimental
1816
+ */
1817
+ traceView?: boolean | BrowserTraceViewOptions;
1818
+ /**
1644
1819
  * Directory where screenshots will be saved when page.screenshot() is called
1645
1820
  * If not set, all screenshots are saved to __screenshots__ directory in the same folder as the test file.
1646
1821
  * If this is set, it will be resolved relative to the project root.
@@ -1786,6 +1961,7 @@ interface ResolvedBrowserOptions extends BrowserConfigOptions {
1786
1961
  snapshots?: boolean;
1787
1962
  sources?: boolean;
1788
1963
  };
1964
+ traceView: Required<BrowserTraceViewOptions>;
1789
1965
  }
1790
1966
  type ToMatchScreenshotResolvePath = (data: {
1791
1967
  /**
@@ -2330,14 +2506,6 @@ declare class JUnitReporter implements Reporter {
2330
2506
  onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void>;
2331
2507
  }
2332
2508
 
2333
- declare class AgentReporter extends DefaultReporter {
2334
- renderSucceed: boolean;
2335
- constructor(options?: DefaultReporterOptions);
2336
- onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
2337
- protected printTestModule(testModule: TestModule): void;
2338
- protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
2339
- }
2340
-
2341
2509
  declare class DotReporter extends BaseReporter {
2342
2510
  private renderer?;
2343
2511
  private tests;
@@ -2360,6 +2528,14 @@ declare class HangingProcessReporter implements Reporter {
2360
2528
  onProcessTimeout(): void;
2361
2529
  }
2362
2530
 
2531
+ declare class MinimalReporter extends DefaultReporter {
2532
+ renderSucceed: boolean;
2533
+ constructor(options?: DefaultReporterOptions);
2534
+ onTestRunStart(specifications: ReadonlyArray<TestSpecification>): void;
2535
+ protected printTestModule(testModule: TestModule): void;
2536
+ protected printTestCase(moduleState: TestModuleState, test: TestCase): void;
2537
+ }
2538
+
2363
2539
  declare class TapReporter implements Reporter {
2364
2540
  protected ctx: Vitest;
2365
2541
  private logger;
@@ -2423,7 +2599,8 @@ type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap;
2423
2599
 
2424
2600
  declare const ReportersMap: {
2425
2601
  default: typeof DefaultReporter;
2426
- agent: typeof AgentReporter;
2602
+ agent: typeof MinimalReporter;
2603
+ minimal: typeof MinimalReporter;
2427
2604
  blob: typeof BlobReporter;
2428
2605
  verbose: typeof VerboseReporter;
2429
2606
  dot: typeof DotReporter;
@@ -2438,6 +2615,7 @@ declare const ReportersMap: {
2438
2615
  type BuiltinReporters = keyof typeof ReportersMap;
2439
2616
  interface BuiltinReporterOptions {
2440
2617
  "default": DefaultReporterOptions;
2618
+ "minimal": DefaultReporterOptions;
2441
2619
  "agent": DefaultReporterOptions;
2442
2620
  "verbose": DefaultReporterOptions;
2443
2621
  "dot": BaseOptions;
@@ -3151,6 +3329,14 @@ interface InlineConfig {
3151
3329
  */
3152
3330
  chaiConfig?: ChaiConfig;
3153
3331
  /**
3332
+ * Sets length limit for formatted values interpolated into generated task titles.
3333
+ *
3334
+ * This affects values inserted by APIs like `test.each` and `test.for`.
3335
+ *
3336
+ * @default 40
3337
+ */
3338
+ taskTitleValueFormatTruncate?: number;
3339
+ /**
3154
3340
  * Stop test execution when given number of tests have failed.
3155
3341
  */
3156
3342
  bail?: number;
@@ -3550,5 +3736,5 @@ type TestProjectInlineConfiguration = (UserWorkspaceConfig & {
3550
3736
  });
3551
3737
  type TestProjectConfiguration = string | TestProjectInlineConfiguration | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
3552
3738
 
3553
- export { DefaultReporter as $, Logger as L, TestProject as T, Vitest as V, DotReporter as a1, GithubActionsReporter as a3, HangingProcessReporter as a5, JUnitReporter as a7, TestCollection as aA, TestModule as aC, TestSuite as aN, VerboseBenchmarkReporter as aS, VerboseReporter as aT, VitestPackageInstaller as aV, experimental_getRunnerTask as aY, CoverageMap as aZ, JsonReporter as aa, ReportersMap as ap, TapFlatReporter as aw, TapReporter as ax, TestCase as az, TestSpecification as h, AgentReporter as l, BaseReporter as m, BenchmarkReporter as o, BenchmarkReportsMap as p };
3554
- export type { ApiConfig as A, BaseCoverageOptions as B, CoverageOptions as C, BrowserScript as D, BrowserServerFactory as E, FieldsWithDefaultValues as F, BrowserServerOptions as G, BrowserServerState as H, InlineConfig as I, BrowserServerStateSession as J, BuiltinEnvironment as K, BuiltinReporterOptions as M, BuiltinReporters as N, CSSModuleScopeStrategy as O, PoolWorker as P, CoverageIstanbulOptions as Q, ResolvedConfig as R, CoverageProvider as S, UserWorkspaceConfig as U, WatcherTriggerPattern as W, CoverageProviderModule as X, CoverageReporter as Y, CoverageV8Options as Z, CustomProviderOptions as _, TestProjectConfiguration as a, DepsOptimizationOptions as a0, EnvironmentOptions as a2, HTMLOptions as a4, JUnitOptions as a6, JsonAssertionResult as a8, JsonOptions as a9, TestDiagnostic as aB, TestModuleState as aD, TestResult as aE, TestResultFailed as aF, TestResultPassed as aG, TestResultSkipped as aH, TestRunEndReason as aI, TestRunResult as aJ, TestSequencerConstructor as aK, TestSpecificationOptions as aL, TestState as aM, TestSuiteState as aO, ToMatchScreenshotComparators as aP, ToMatchScreenshotOptions as aQ, TypecheckConfig as aR, VitestEnvironment as aU, WorkerResponse as aW, _BrowserNames as aX, 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, ReportContext as am, ReportedHookContext as an, Reporter as ao, ResolveSnapshotPathHandler as aq, ResolveSnapshotPathHandlerContext as ar, ResolvedBrowserOptions as as, ResolvedCoverageOptions as at, ResolvedProjectConfig as au, SerializedTestProject as av, TaskOptions as ay, 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 n, BenchmarkUserOptions as q, BrowserBuiltinProvider as r, BrowserCommand as s, BrowserCommandContext as t, BrowserConfigOptions as u, BrowserInstanceOption as v, BrowserModuleMocker as w, BrowserOrchestrator as x, BrowserProvider as y, BrowserProviderOption as z };
3739
+ export { Logger as L, MinimalReporter as M, TestProject as T, Vitest as V, experimental_getRunnerTask as a$, DefaultReporter as a0, DotReporter as a2, GithubActionsReporter as a4, HangingProcessReporter as a6, JUnitReporter as a9, TapReporter as aA, TestCase as aC, TestCollection as aD, TestModule as aF, TestSuite as aQ, VerboseBenchmarkReporter as aV, VerboseReporter as aW, VitestPackageInstaller as aY, JsonReporter as ac, ReportersMap as as, TapFlatReporter as az, CoverageMap as b0, TestSpecification as h, BaseReporter as l, BenchmarkReporter as n, BenchmarkReportsMap as o };
3740
+ 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 aB, TestDiagnostic as aE, TestModuleState as aG, TestResult as aH, TestResultFailed as aI, TestResultPassed as aJ, TestResultSkipped as aK, TestRunEndReason as aL, TestRunResult as aM, TestSequencerConstructor as aN, TestSpecificationOptions as aO, TestState as aP, TestSuiteState as aR, ToMatchScreenshotComparators as aS, ToMatchScreenshotOptions as aT, TypecheckConfig as aU, VitestEnvironment as aX, WorkerResponse as aZ, _BrowserNames as a_, 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, Report as ao, ReportContext as ap, ReportedHookContext as aq, Reporter as ar, ResolveSnapshotPathHandler as at, ResolveSnapshotPathHandlerContext as au, ResolvedBrowserOptions as av, ResolvedCoverageOptions as aw, ResolvedProjectConfig as ax, SerializedTestProject as ay, 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 };
@@ -1,49 +1,7 @@
1
1
  import { File, TestArtifact, TaskResultPack, TaskEventPack, CancelReason } from '@vitest/runner';
2
2
  import { SnapshotResult } from '@vitest/snapshot';
3
3
  import { FetchFunctionOptions, FetchResult } from 'vite/module-runner';
4
- import { O as OTELCarrier } from './traces.d.402V_yFI.js';
5
-
6
- interface AfterSuiteRunMeta {
7
- coverage?: unknown;
8
- testFiles: string[];
9
- environment: string;
10
- projectName?: string;
11
- }
12
- interface UserConsoleLog {
13
- content: string;
14
- origin?: string;
15
- browser?: boolean;
16
- type: "stdout" | "stderr";
17
- taskId?: string;
18
- time: number;
19
- size: number;
20
- }
21
- interface ModuleGraphData {
22
- graph: Record<string, string[]>;
23
- externalized: string[];
24
- inlined: string[];
25
- }
26
- interface ProvidedContext {}
27
- interface ResolveFunctionResult {
28
- id: string;
29
- file: string;
30
- url: string;
31
- }
32
- interface FetchCachedFileSystemResult {
33
- cached: true;
34
- tmp: string;
35
- id: string;
36
- file: string | null;
37
- url: string;
38
- invalidate: boolean;
39
- }
40
- type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
41
- interface AsyncLeak {
42
- filename: string;
43
- projectName: string;
44
- stack: string;
45
- type: string;
46
- }
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';
47
5
 
48
6
  interface RuntimeRPC {
49
7
  fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions, otelCarrier?: OTELCarrier) => Promise<FetchResult | FetchCachedFileSystemResult>;
@@ -69,4 +27,4 @@ interface RunnerRPC {
69
27
  onCancel: (reason: CancelReason) => void;
70
28
  }
71
29
 
72
- export type { AfterSuiteRunMeta as A, LabelColor as L, ModuleGraphData as M, ProvidedContext as P, RuntimeRPC as R, UserConsoleLog as U, RunnerRPC as a, AsyncLeak as b };
30
+ export type { RuntimeRPC as R, RunnerRPC as a };
@@ -26,7 +26,7 @@ async function setupCommonEnv(config) {
26
26
  if (globalSetup) return;
27
27
  globalSetup = true;
28
28
  setSafeTimers();
29
- if (config.globals) (await import('./globals.BVDtJR67.js')).registerApiGlobally();
29
+ if (config.globals) (await import('./globals.BYX6Co2c.js')).registerApiGlobally();
30
30
  }
31
31
  function setupDefines(config) {
32
32
  for (const key in config.defines) globalThis[key] = config.defines[key];