vitest 4.1.5 → 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 (50) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{base.RR7zL1h0.js → base.CgusHodA.js} +8 -8
  4. package/dist/chunks/{browser.d.BcoexmFG.d.ts → browser.d.Bn-qMB1Y.d.ts} +1 -1
  5. package/dist/chunks/{cac.DJJmV0dT.js → cac.DSVGM2li.js} +17 -6
  6. package/dist/chunks/{cli-api.Cjt90eJu.js → cli-api.MLtHkHGf.js} +66 -18
  7. package/dist/chunks/{config.d.A1h_Y6Jt.d.ts → config.d.BgVe1oN5.d.ts} +6 -0
  8. package/dist/chunks/{coverage.DM_a_rWm.js → coverage.nIKqs-BM.js} +28 -6
  9. package/dist/chunks/{defaults.9aQKnqFk.js → defaults.pr789SUS.js} +1 -0
  10. package/dist/chunks/{globals.Dj1TGiMC.js → globals.BYX6Co2c.js} +2 -2
  11. package/dist/chunks/{index.DXx9Dtk7.js → index.BSgubW8K.js} +2 -2
  12. package/dist/chunks/{index.DdgEv5B1.js → index.BcGySndd.js} +1 -1
  13. package/dist/chunks/{index.BCY_7LL2.js → index.CesbTg1C.js} +9 -9
  14. package/dist/chunks/{index.UpGiHP7g.js → index.yJ2D83a4.js} +6 -5
  15. package/dist/chunks/{init-forks.UV3ZQGQH.js → init-forks.DuteEWBS.js} +1 -1
  16. package/dist/chunks/{init-threads.D3eCsY76.js → init-threads.BSdvBCTO.js} +1 -1
  17. package/dist/chunks/{init.D98-gwRW.js → init.Dc7N0jh0.js} +1 -1
  18. package/dist/chunks/{nativeModuleMocker.BRN2oBJd.js → nativeModuleMocker.BKN7j4tC.js} +1 -1
  19. package/dist/chunks/{nativeModuleRunner.BIakptoF.js → nativeModuleRunner.WlMdOB52.js} +1 -1
  20. package/dist/chunks/{plugin.d.BM2TCi12.d.ts → plugin.d.BkNgFMgP.d.ts} +1 -1
  21. package/dist/chunks/{reporters.d.CEnv6XRv.d.ts → reporters.d.GtfMm3Oa.d.ts} +134 -5
  22. package/dist/chunks/{setup-common.DYx3LtFI.js → setup-common.CYy2gJEr.js} +1 -1
  23. package/dist/chunks/{startVitestModuleRunner.bRl2_oI_.js → startVitestModuleRunner.vRT958-n.js} +2 -2
  24. package/dist/chunks/{test.DNmyFkvJ.js → test.C8WyxAQk.js} +2 -1
  25. package/dist/chunks/{utils.BS4fH3nR.js → utils.DzYdXqCH.js} +2 -3
  26. package/dist/chunks/{vm.DVLYObm9.js → vm.CPtbsAeh.js} +5 -5
  27. package/dist/chunks/{worker.d.ZpHpO4yb.d.ts → worker.d.irleQtmS.d.ts} +1 -1
  28. package/dist/cli.js +1 -1
  29. package/dist/config.cjs +1 -0
  30. package/dist/config.d.ts +8 -6
  31. package/dist/config.js +1 -1
  32. package/dist/coverage.d.ts +5 -4
  33. package/dist/coverage.js +5 -4
  34. package/dist/index.d.ts +6 -6
  35. package/dist/index.js +2 -2
  36. package/dist/node.d.ts +8 -7
  37. package/dist/node.js +11 -11
  38. package/dist/reporters.d.ts +5 -4
  39. package/dist/reporters.js +3 -3
  40. package/dist/runners.d.ts +1 -1
  41. package/dist/runners.js +1 -1
  42. package/dist/runtime.js +1 -1
  43. package/dist/worker.d.ts +2 -2
  44. package/dist/worker.js +9 -9
  45. package/dist/workers/forks.js +10 -10
  46. package/dist/workers/runVmTests.js +4 -4
  47. package/dist/workers/threads.js +10 -10
  48. package/dist/workers/vmForks.js +4 -4
  49. package/dist/workers/vmThreads.js +4 -4
  50. package/package.json +14 -14
package/dist/browser.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.A1h_Y6Jt.js';
1
+ import { a as SerializedCoverageConfig, S as SerializedConfig } from './chunks/config.d.BgVe1oN5.js';
2
2
  import { R as RuntimeCoverageModuleLoader } from './chunks/coverage.d.BZtK59WP.js';
3
3
  import { SerializedDiffOptions } from '@vitest/utils/diff';
4
4
  export { O as OTELCarrier, T as Traces } from './chunks/traces.d.D2T_R8rx.js';
5
5
  export { collectTests, startTests } from '@vitest/runner';
6
6
  import * as _vitest_spy from '@vitest/spy';
7
7
  export { _vitest_spy as SpyModule };
8
- export { LoupeOptions, ParsedStack, StringifyOptions } from '@vitest/utils';
9
- export { browserFormat, format, inspect, stringify } from '@vitest/utils/display';
8
+ export { ParsedStack, StringifyOptions } from '@vitest/utils';
9
+ export { format, inspect, stringify } from '@vitest/utils/display';
10
10
  export { processError } from '@vitest/utils/error';
11
11
  export { getType } from '@vitest/utils/helpers';
12
12
  export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
package/dist/browser.js CHANGED
@@ -1,9 +1,9 @@
1
- export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.DYx3LtFI.js';
1
+ export { l as loadDiffConfig, a as loadSnapshotSerializers, s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './chunks/setup-common.CYy2gJEr.js';
2
2
  export { T as Traces } from './chunks/traces.DT5aQ62U.js';
3
3
  export { collectTests, startTests } from '@vitest/runner';
4
4
  import * as spyModule from '@vitest/spy';
5
5
  export { spyModule as SpyModule };
6
- export { browserFormat, format, inspect, stringify } from '@vitest/utils/display';
6
+ export { format, inspect, stringify } from '@vitest/utils/display';
7
7
  export { processError } from '@vitest/utils/error';
8
8
  export { getType } from '@vitest/utils/helpers';
9
9
  export { DecodedMap, getOriginalPosition } from '@vitest/utils/source-map';
@@ -1,22 +1,22 @@
1
1
  import { runInThisContext } from 'node:vm';
2
2
  import * as spyModule from '@vitest/spy';
3
- import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.DXx9Dtk7.js';
4
- import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.D98-gwRW.js';
5
- import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
3
+ import { r as resolveTestRunner, a as resolveSnapshotEnvironment, d as detectAsyncLeaks, s as setupChaiConfig } from './index.BSgubW8K.js';
4
+ import { l as loadEnvironment, e as emitModuleRunner, a as listenForErrors } from './init.Dc7N0jh0.js';
5
+ import { N as NativeModuleRunner } from './nativeModuleRunner.WlMdOB52.js';
6
6
  import { T as Traces } from './traces.DT5aQ62U.js';
7
7
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
8
- import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.bRl2_oI_.js';
8
+ import { s as startVitestModuleRunner, c as createNodeImportMeta } from './startVitestModuleRunner.vRT958-n.js';
9
9
  import { performance as performance$1 } from 'node:perf_hooks';
10
10
  import { startTests, collectTests } from '@vitest/runner';
11
- import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.DYx3LtFI.js';
12
- import { g as globalExpect, v as vi } from './test.DNmyFkvJ.js';
11
+ import { s as setupCommonEnv, b as startCoverageInsideWorker, c as stopCoverageInsideWorker } from './setup-common.CYy2gJEr.js';
12
+ import { g as globalExpect, v as vi } from './test.C8WyxAQk.js';
13
13
  import { c as closeInspector } from './inspector.CvyFGlXm.js';
14
14
  import { createRequire } from 'node:module';
15
15
  import timers from 'node:timers';
16
16
  import timersPromises from 'node:timers/promises';
17
17
  import util from 'node:util';
18
18
  import { KNOWN_ASSET_TYPES } from '@vitest/utils/constants';
19
- import { i as index } from './index.DdgEv5B1.js';
19
+ import { i as index } from './index.BcGySndd.js';
20
20
  import { g as getWorkerState, r as resetModules, p as provideWorkerState, a as getSafeWorkerState } from './utils.BX5Fg8C4.js';
21
21
 
22
22
  // this should only be used in Node
@@ -115,7 +115,7 @@ async function startModuleRunner(options) {
115
115
  let mocker;
116
116
  if (options.state.config.experimental.nodeLoader !== false) {
117
117
  // this additionally imports acorn/magic-string
118
- const { NativeModuleMocker } = await import('./nativeModuleMocker.BRN2oBJd.js');
118
+ const { NativeModuleMocker } = await import('./nativeModuleMocker.BKN7j4tC.js');
119
119
  mocker = new NativeModuleMocker({
120
120
  async resolveId(id, importer) {
121
121
  // TODO: use import.meta.resolve instead
@@ -1,6 +1,6 @@
1
1
  import { FileSpecification } from '@vitest/runner';
2
2
  import { O as OTELCarrier } from './traces.d.D2T_R8rx.js';
3
- import { T as TestExecutionMethod } from './worker.d.ZpHpO4yb.js';
3
+ import { T as TestExecutionMethod } from './worker.d.irleQtmS.js';
4
4
 
5
5
  type SerializedTestSpecification = [project: {
6
6
  name: string | undefined;
@@ -621,7 +621,7 @@ class CAC extends EventEmitter {
621
621
 
622
622
  const cac = (name = "") => new CAC(name);
623
623
 
624
- var version = "4.1.5";
624
+ var version = "5.0.0-beta.1";
625
625
 
626
626
  const apiConfig = (port) => ({
627
627
  port: {
@@ -886,6 +886,16 @@ const cliOptionsConfig = {
886
886
  return { mode: value };
887
887
  }
888
888
  },
889
+ traceView: {
890
+ description: "Enable Vitest trace-view collection for browser tests (default: `false`)",
891
+ argument: "",
892
+ transform: transformNestedBoolean,
893
+ subcommands: {
894
+ enabled: { description: "Enable Vitest trace-view collection for browser tests (default: `false`)" },
895
+ recordCanvas: { description: "Capture canvas pixels in trace-view snapshots (default: `false`)" },
896
+ inlineImages: { description: "Inline loaded image pixels in trace-view snapshots (default: `false`)" }
897
+ }
898
+ },
889
899
  orchestratorScripts: null,
890
900
  commands: null,
891
901
  viewport: null,
@@ -1294,7 +1304,8 @@ const cliOptionsConfig = {
1294
1304
  staticParseConcurrency: null,
1295
1305
  projects: null,
1296
1306
  watchTriggerPatterns: null,
1297
- tags: null
1307
+ tags: null,
1308
+ taskTitleValueFormatTruncate: null
1298
1309
  };
1299
1310
  const benchCliOptionsConfig = {
1300
1311
  compare: {
@@ -2336,11 +2347,11 @@ function normalizeCliOptions(cliFilters, argv) {
2336
2347
  }
2337
2348
  async function start(mode, cliFilters, options) {
2338
2349
  try {
2339
- const { startVitest } = await import('./cli-api.Cjt90eJu.js').then(function (n) { return n.q; });
2350
+ const { startVitest } = await import('./cli-api.MLtHkHGf.js').then(function (n) { return n.q; });
2340
2351
  const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(cliFilters, options));
2341
2352
  if (!ctx.shouldKeepServer()) await ctx.exit();
2342
2353
  } catch (e) {
2343
- const { errorBanner } = await import('./utils.BS4fH3nR.js').then(function (n) { return n.u; });
2354
+ const { errorBanner } = await import('./utils.DzYdXqCH.js').then(function (n) { return n.u; });
2344
2355
  console.error(`\n${errorBanner("Startup Error")}`);
2345
2356
  console.error(e);
2346
2357
  console.error("\n\n");
@@ -2358,7 +2369,7 @@ async function init(project) {
2358
2369
  }
2359
2370
  async function collect(mode, cliFilters, options) {
2360
2371
  try {
2361
- const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.Cjt90eJu.js').then(function (n) { return n.q; });
2372
+ const { prepareVitest, processCollected, outputFileList } = await import('./cli-api.MLtHkHGf.js').then(function (n) { return n.q; });
2362
2373
  const ctx = await prepareVitest(mode, {
2363
2374
  ...normalizeCliOptions(cliFilters, options),
2364
2375
  watch: false,
@@ -2380,7 +2391,7 @@ async function collect(mode, cliFilters, options) {
2380
2391
  } else outputFileList(await ctx.getRelevantTestSpecifications(cliFilters.map(normalize)), options);
2381
2392
  await ctx.close();
2382
2393
  } catch (e) {
2383
- const { errorBanner } = await import('./utils.BS4fH3nR.js').then(function (n) { return n.u; });
2394
+ const { errorBanner } = await import('./utils.DzYdXqCH.js').then(function (n) { return n.u; });
2384
2395
  console.error(`\n${errorBanner("Collect Error")}`);
2385
2396
  console.error(e);
2386
2397
  console.error("\n\n");
@@ -1,10 +1,11 @@
1
- import fs, { promises, existsSync, mkdirSync, readFileSync, statSync, readdirSync, writeFileSync } from 'node:fs';
1
+ import * as fs from 'node:fs';
2
+ import fs__default, { promises, existsSync, mkdirSync, readFileSync, statSync, readdirSync, writeFileSync } from 'node:fs';
2
3
  import { relative, resolve, dirname, join, extname, normalize, basename, isAbsolute } from 'pathe';
3
4
  import { C as CoverageProviderMap } from './coverage.CTzCuANN.js';
4
5
  import path, { resolve as resolve$1 } from 'node:path';
5
6
  import { unique, createDefer, slash, withTrailingSlash, cleanUrl, wrapId, isExternalUrl, unwrapId, toArray, noop, deepMerge, nanoid, deepClone, isPrimitive, notNullish } from '@vitest/utils/helpers';
6
7
  import { a as any, p as prompt } from './index.og1WyBLx.js';
7
- import { i as isPackageExists, r as resolveModule } from './index.BCY_7LL2.js';
8
+ import { i as isPackageExists, r as resolveModule } from './index.CesbTg1C.js';
8
9
  import * as vite from 'vite';
9
10
  import { parseAst, searchForWorkspaceRoot, fetchModule, version, createServer, isFileLoadingAllowed, normalizePath, isRunnableDevEnvironment, mergeConfig } from 'vite';
10
11
  import { A as API_PATH, c as configFiles, d as defaultBrowserPort, b as defaultPort } from './constants.CPYnjOGj.js';
@@ -13,20 +14,20 @@ import nodeos__default, { tmpdir } from 'node:os';
13
14
  import { generateHash as generateHash$1, createTaskName, validateTags, calculateSuiteHash, hasFailed, generateFileHash, limitConcurrency, createFileTask as createFileTask$1, createTagsFilter, someTasksAreOnly, interpretTaskModes, getTasks, isTestCase } from '@vitest/runner/utils';
14
15
  import { SnapshotManager } from '@vitest/snapshot/manager';
15
16
  import { serializeValue } from '@vitest/utils/serialize';
16
- import { v as version$1 } from './cac.DJJmV0dT.js';
17
+ import { v as version$1 } from './cac.DSVGM2li.js';
17
18
  import { rootDir, distDir } from '../path.js';
18
- import { f as createIndexLocationsMap, g as TraceMap, o as originalPositionFor, h as ancestor, s as stringify, p as parse, i as printError, j as Typechecker, k as generateCodeFrame, l as escapeRegExp, m as createDefinesScript, a as BenchmarkReportsMap, R as ReportersMap, n as groupBy, q as BlobReporter, r as readBlobs, t as convertTasksToEvents, H as HangingProcessReporter, w as wildcardPatternToRegExp, u as stdout } from './index.UpGiHP7g.js';
19
- import { N as NativeModuleRunner } from './nativeModuleRunner.BIakptoF.js';
19
+ import { f as createIndexLocationsMap, g as TraceMap, o as originalPositionFor, h as ancestor, s as stringify, p as parse, i as printError, j as Typechecker, k as generateCodeFrame, l as escapeRegExp, m as createDefinesScript, a as BenchmarkReportsMap, R as ReportersMap, n as groupBy, q as BlobReporter, r as readBlobs, t as convertTasksToEvents, H as HangingProcessReporter, w as wildcardPatternToRegExp, u as stdout } from './index.yJ2D83a4.js';
20
+ import { N as NativeModuleRunner } from './nativeModuleRunner.WlMdOB52.js';
20
21
  import { T as Traces } from './traces.DT5aQ62U.js';
21
22
  import { createDebug } from 'obug';
22
- import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.DM_a_rWm.js';
23
- import { rm, readFile, writeFile, rename, stat, unlink, mkdir, copyFile } from 'node:fs/promises';
23
+ import { h as hash, R as RandomSequencer, i as isBrowserEnabled, r as resolveConfig, g as getCoverageProvider, b as resolveApiServerConfig } from './coverage.nIKqs-BM.js';
24
+ import { rm, readFile, writeFile, rename, stat, unlink, readdir, mkdir, copyFile } from 'node:fs/promises';
24
25
  import c from 'tinyrainbow';
25
26
  import { VitestModuleEvaluator } from '#module-evaluator';
26
27
  import { ModuleRunner } from 'vite/module-runner';
27
28
  import { Console } from 'node:console';
28
29
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers.D26ty3Ew.js';
29
- import { g as formatProjectName, w as withLabel, e as errorBanner, d as divider } from './utils.BS4fH3nR.js';
30
+ import { g as formatProjectName, w as withLabel, e as errorBanner, d as divider } from './utils.DzYdXqCH.js';
30
31
  import { createRequire, builtinModules, isBuiltin as isBuiltin$1 } from 'node:module';
31
32
  import url, { fileURLToPath, pathToFileURL } from 'node:url';
32
33
  import { i as isTTY, a as isWindows } from './env.D4Lgay0q.js';
@@ -50,7 +51,7 @@ import require$$0$2 from 'stream';
50
51
  import require$$7 from 'url';
51
52
  import require$$0 from 'zlib';
52
53
  import require$$0$1 from 'buffer';
53
- import { c as configDefaults } from './defaults.9aQKnqFk.js';
54
+ import { c as configDefaults } from './defaults.pr789SUS.js';
54
55
  import { isAgent } from 'std-env';
55
56
  import MagicString from 'magic-string';
56
57
  import { hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
@@ -491,8 +492,8 @@ class FilesStatsCache {
491
492
  await Promise.all(promises);
492
493
  }
493
494
  async updateStats(fsPath, key) {
494
- if (!fs.existsSync(fsPath)) return;
495
- const stats = await fs.promises.stat(fsPath);
495
+ if (!fs__default.existsSync(fsPath)) return;
496
+ const stats = await fs__default.promises.stat(fsPath);
496
497
  this.cache.set(key, { size: stats.size });
497
498
  }
498
499
  removeStats(fsPath) {
@@ -533,8 +534,8 @@ class ResultsCache {
533
534
  }
534
535
  async readFromCache() {
535
536
  if (!this.cachePath) return;
536
- if (!fs.existsSync(this.cachePath)) return;
537
- const resultsCache = await fs.promises.readFile(this.cachePath, "utf8");
537
+ if (!fs__default.existsSync(this.cachePath)) return;
538
+ const resultsCache = await fs__default.promises.readFile(this.cachePath, "utf8");
538
539
  const { results, version } = JSON.parse(resultsCache || "[]");
539
540
  const [major, minor] = version.split(".");
540
541
  // handling changed in 0.30.0
@@ -571,12 +572,12 @@ class ResultsCache {
571
572
  if (!this.cachePath) return;
572
573
  const results = Array.from(this.cache.entries());
573
574
  const cacheDirname = dirname(this.cachePath);
574
- if (!fs.existsSync(cacheDirname)) await fs.promises.mkdir(cacheDirname, { recursive: true });
575
+ if (!fs__default.existsSync(cacheDirname)) await fs__default.promises.mkdir(cacheDirname, { recursive: true });
575
576
  const cache = JSON.stringify({
576
577
  version: this.version,
577
578
  results
578
579
  });
579
- await fs.promises.writeFile(this.cachePath, cache);
580
+ await fs__default.promises.writeFile(this.cachePath, cache);
580
581
  }
581
582
  }
582
583
 
@@ -888,7 +889,7 @@ const lockfileFormats = [
888
889
  const lockfilePaths = lockfileFormats.map((l) => l.path);
889
890
  function getLockfileHash(root) {
890
891
  const lockfilePath = lookupFile(root, lockfilePaths);
891
- let content = lockfilePath ? fs.readFileSync(lockfilePath, "utf-8") : "";
892
+ let content = lockfilePath ? fs__default.readFileSync(lockfilePath, "utf-8") : "";
892
893
  if (lockfilePath) {
893
894
  const normalizedLockfilePath = lockfilePath.replaceAll("\\", "/");
894
895
  const lockfileFormat = lockfileFormats.find((f) => normalizedLockfilePath.endsWith(f.path));
@@ -920,7 +921,7 @@ function tryReadFileSync(file) {
920
921
  function tryStatSync(file) {
921
922
  try {
922
923
  // The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
923
- return fs.statSync(file, { throwIfNoEntry: false });
924
+ return fs__default.statSync(file, { throwIfNoEntry: false });
924
925
  } catch {}
925
926
  }
926
927
 
@@ -9145,6 +9146,7 @@ function serializeConfig(project) {
9145
9146
  bail: config.bail,
9146
9147
  defines: config.defines,
9147
9148
  chaiConfig: config.chaiConfig,
9149
+ taskTitleValueFormatTruncate: config.taskTitleValueFormatTruncate,
9148
9150
  setupFiles: config.setupFiles,
9149
9151
  allowOnly: config.allowOnly,
9150
9152
  testTimeout: config.testTimeout,
@@ -9233,7 +9235,8 @@ function serializeConfig(project) {
9233
9235
  },
9234
9236
  providerOptions: provider?.name === "playwright" ? { actionTimeout: provider?.options?.actionTimeout } : {},
9235
9237
  trackUnhandledErrors: browser.trackUnhandledErrors ?? true,
9236
- trace: browser.trace.mode
9238
+ trace: browser.trace.mode,
9239
+ traceView: browser.traceView
9237
9240
  };
9238
9241
  })(config.browser),
9239
9242
  standalone: config.standalone,
@@ -11338,6 +11341,45 @@ function getPotentialProjectNames(project) {
11338
11341
  return names;
11339
11342
  }
11340
11343
 
11344
+ function createReport(ctx, scope) {
11345
+ const root = ctx.config.root;
11346
+ const vitestDir = resolve$1(root, ".vitest");
11347
+ const reportDir = resolve$1(vitestDir, scope);
11348
+ if (!fs.existsSync(vitestDir)) fs.mkdirSync(vitestDir);
11349
+ if (!fs.existsSync(reportDir)) fs.mkdirSync(reportDir);
11350
+ return {
11351
+ root: reportDir,
11352
+ async clean(force = false) {
11353
+ if (fs.existsSync(reportDir)) {
11354
+ // Do not delete results when run with --merge-reports, unless forced to.
11355
+ // In test runs with --shard, it's possible that users do some other handling for
11356
+ // the reports after 'vitest --merge-reports' run. For example upload all the '.vitest/attachments'.
11357
+ if (ctx.config.mergeReports && !force) return;
11358
+ await rm(reportDir, {
11359
+ recursive: true,
11360
+ force: true
11361
+ });
11362
+ }
11363
+ await mkdir(reportDir);
11364
+ },
11365
+ async readFile(filename, encoding = "utf8") {
11366
+ return await readFile(resolve$1(vitestDir, scope, filename), encoding);
11367
+ },
11368
+ async readdir() {
11369
+ return await readdir(resolve$1(vitestDir, scope));
11370
+ },
11371
+ async writeFile(filename, content, encoding = "utf8") {
11372
+ await writeFile(resolve$1(vitestDir, scope, filename), content, encoding);
11373
+ },
11374
+ async delete(filename) {
11375
+ await rm(resolve$1(vitestDir, scope, filename), {
11376
+ recursive: true,
11377
+ force: true
11378
+ });
11379
+ }
11380
+ };
11381
+ }
11382
+
11341
11383
  async function loadCustomReporterModule(path, runner) {
11342
11384
  let customReporterModule;
11343
11385
  try {
@@ -14042,6 +14084,12 @@ class Vitest {
14042
14084
  return wildcardPatternToRegExp(project.slice(1)).test(name);
14043
14085
  });
14044
14086
  }
14087
+ /**
14088
+ * Create a report that's scoped to a specific reporter directory.
14089
+ */
14090
+ createReport(scope) {
14091
+ return createReport(this, scope);
14092
+ }
14045
14093
  }
14046
14094
  function assert(condition, property, name = property) {
14047
14095
  if (!condition) throw new Error(`The ${name} was not set. It means that \`vitest.${property}\` was called before the Vite server was established. Await the Vitest promise before accessing \`vitest.${property}\`.`);
@@ -139,6 +139,7 @@ interface SerializedConfig {
139
139
  showDiff?: boolean;
140
140
  truncateThreshold?: number;
141
141
  } | undefined;
142
+ taskTitleValueFormatTruncate: number;
142
143
  api: {
143
144
  allowExec: boolean | undefined;
144
145
  allowWrite: boolean | undefined;
@@ -175,6 +176,11 @@ interface SerializedConfig {
175
176
  actionTimeout?: number;
176
177
  };
177
178
  trace: BrowserTraceViewMode;
179
+ traceView: {
180
+ enabled: boolean;
181
+ recordCanvas: boolean;
182
+ inlineImages: boolean;
183
+ };
178
184
  trackUnhandledErrors: boolean;
179
185
  detailsPanelPosition: "right" | "bottom";
180
186
  };
@@ -5,16 +5,16 @@ import { pathToFileURL, fileURLToPath } from 'node:url';
5
5
  import { slash, shuffle, toArray, cleanUrl } from '@vitest/utils/helpers';
6
6
  import { resolve, relative, normalize, join } from 'pathe';
7
7
  import pm from 'picomatch';
8
- import { glob } from 'tinyglobby';
8
+ import { isDynamicPattern, glob } from 'tinyglobby';
9
9
  import c from 'tinyrainbow';
10
- import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigDefaults } from './defaults.9aQKnqFk.js';
10
+ import { c as configDefaults, e as benchmarkConfigDefaults, a as coverageConfigDefaults } from './defaults.pr789SUS.js';
11
11
  import crypto from 'node:crypto';
12
- import { r as resolveModule } from './index.BCY_7LL2.js';
12
+ import { r as resolveModule } from './index.CesbTg1C.js';
13
13
  import { mergeConfig } from 'vite';
14
14
  import { c as configFiles, d as defaultBrowserPort, a as defaultInspectPort, b as defaultPort } from './constants.CPYnjOGj.js';
15
15
  import './env.D4Lgay0q.js';
16
16
  import nodeos__default from 'node:os';
17
- import { w as withLabel } from './utils.BS4fH3nR.js';
17
+ import { w as withLabel } from './utils.DzYdXqCH.js';
18
18
  import { isAgent, isCI, provider } from 'std-env';
19
19
  import { r as resolveCoverageProviderModule } from './coverage.CTzCuANN.js';
20
20
 
@@ -339,6 +339,11 @@ function resolveConfig$1(vitest, options, viteConfig) {
339
339
  resolved.deps.web.transformGlobPattern ??= [];
340
340
  resolved.setupFiles = toArray(resolved.setupFiles || []).map((file) => resolvePath(file, resolved.root));
341
341
  resolved.globalSetup = toArray(resolved.globalSetup || []).map((file) => resolvePath(file, resolved.root));
342
+ if (resolved.coverage.include) resolved.coverage.include = resolved.coverage.include.map((pattern) => {
343
+ if (isDynamicPattern(pattern)) return pattern;
344
+ // Convert patterns like ["src", "packages/server"] to ["src/**", "packages/server/**"]
345
+ return pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
346
+ });
342
347
  // Add hard-coded default coverage exclusions. These cannot be overridden by user config.
343
348
  // Override original exclude array for cases where user re-uses same object in test.exclude.
344
349
  resolved.coverage.exclude = [
@@ -524,11 +529,23 @@ function resolveConfig$1(vitest, options, viteConfig) {
524
529
  if (resolved.browser.ui) resolved.includeTaskLocation ??= true;
525
530
  } else if (resolved.ui) resolved.includeTaskLocation ??= true;
526
531
  if (typeof resolved.browser.trace === "string" || !resolved.browser.trace) resolved.browser.trace = { mode: resolved.browser.trace || "off" };
532
+ const traceView = resolved.browser.traceView;
533
+ resolved.browser.traceView = typeof traceView === "object" ? {
534
+ enabled: traceView.enabled ?? false,
535
+ recordCanvas: traceView.recordCanvas ?? false,
536
+ inlineImages: traceView.inlineImages ?? false
537
+ } : {
538
+ enabled: traceView ?? false,
539
+ recordCanvas: false,
540
+ inlineImages: false
541
+ };
542
+ if (resolved.browser.enabled && resolved.browser.traceView.enabled) resolved.browser.detailsPanelPosition = "bottom";
527
543
  if (resolved.browser.trace.tracesDir != null) resolved.browser.trace.tracesDir = resolvePath(resolved.browser.trace.tracesDir, resolved.root);
528
544
  if (toArray(resolved.reporters).some((reporter) => {
529
545
  if (Array.isArray(reporter)) return reporter[0] === "html";
530
546
  return false;
531
547
  })) resolved.includeTaskLocation ??= true;
548
+ else if (resolved.browser.enabled && resolved.browser.traceView.enabled && !resolved.watch) logger.console.warn(c.yellow(withLabel("yellow", "Vitest", "--browser.traceView is enabled without the HTML reporter.")));
532
549
  resolved.server ??= {};
533
550
  resolved.server.deps ??= {};
534
551
  if (resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP) {
@@ -669,10 +686,15 @@ Update your dependencies and make sure the versions match.`));
669
686
  this.globCache.set(filename, false);
670
687
  return false;
671
688
  }
689
+ const matchingRoot = roots.find((root) => filename.startsWith(`${slash(root)}/`) || filename === slash(root));
690
+ const relativeFilename = matchingRoot ? relative(matchingRoot, filename) : filename;
691
+ if (pm.isMatch(relativeFilename, this.options.exclude, { dot: true })) {
692
+ this.globCache.set(filename, false);
693
+ return false;
694
+ }
672
695
  // By default `coverage.include` matches all files, except "coverage.exclude"
673
696
  const glob = this.options.include || "**";
674
- let included = pm.isMatch(filename, glob, {
675
- contains: true,
697
+ let included = pm.isMatch(relativeFilename, glob, {
676
698
  dot: true,
677
699
  ignore: this.options.exclude
678
700
  });
@@ -76,6 +76,7 @@ const configDefaults = Object.freeze({
76
76
  exclude: defaultExclude
77
77
  },
78
78
  slowTestThreshold: 300,
79
+ taskTitleValueFormatTruncate: 40,
79
80
  disableConsoleIntercept: false,
80
81
  detectAsyncLeaks: false
81
82
  });
@@ -1,6 +1,6 @@
1
1
  import { g as globalApis } from './constants.CPYnjOGj.js';
2
- import { i as index } from './index.DdgEv5B1.js';
3
- import './test.DNmyFkvJ.js';
2
+ import { i as index } from './index.BcGySndd.js';
3
+ import './test.C8WyxAQk.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils/helpers';
6
6
  import '@vitest/utils/timers';
@@ -1,9 +1,9 @@
1
1
  import { chai } from '@vitest/expect';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.DYx3LtFI.js';
3
+ import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.CYy2gJEr.js';
4
4
  import { r as rpc } from './rpc.MzXet3jl.js';
5
5
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
6
- import { T as TestRunner, N as NodeBenchmarkRunner } from './test.DNmyFkvJ.js';
6
+ import { T as TestRunner, N as NodeBenchmarkRunner } from './test.C8WyxAQk.js';
7
7
 
8
8
  function setupChaiConfig(config) {
9
9
  Object.assign(chai.config, config);
@@ -1,4 +1,4 @@
1
- import { v as vi, N as NodeBenchmarkRunner, S as Snapshots, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.DNmyFkvJ.js';
1
+ import { v as vi, N as NodeBenchmarkRunner, S as Snapshots, T as TestRunner, a as assert, c as createExpect, g as globalExpect, i as inject, s as should, b as vitest } from './test.C8WyxAQk.js';
2
2
  import { b as bench } from './benchmark.CX_oY03V.js';
3
3
  import { V as VitestEvaluatedModules } from './evaluatedModules.Dg1zASAC.js';
4
4
  import { expectTypeOf } from 'expect-type';
@@ -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,9 +1,9 @@
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
9
  import { readdir, stat, readFile, mkdir, writeFile } from 'node:fs/promises';
@@ -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
  ]);
@@ -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
  }
@@ -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.CEnv6XRv.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.