vitest 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/browser.d.ts +4 -4
  3. package/dist/browser.js +11 -11
  4. package/dist/chunks/{base.DhkQeZwd.js → base.CYbb9pQW.js} +39 -15
  5. package/dist/chunks/{browser.d.3cffPS1V.d.ts → browser.d.FGQ9_rK6.d.ts} +3 -3
  6. package/dist/chunks/{cac.DfDGTQ9W.js → cac.DTXWs6Ni.js} +21 -23
  7. package/dist/chunks/cli-api.Bx28WXzL.js +13879 -0
  8. package/dist/chunks/{config.d.BxjInJat.d.ts → config.d.QBNYCgFU.d.ts} +20 -9
  9. package/dist/chunks/{console.RBA5x-0t.js → console.DtI4yxfN.js} +5 -5
  10. package/dist/chunks/{coverage.S6Dao4g-.js → coverage.-bm5IxnW.js} +1 -1
  11. package/dist/chunks/{coverage._yXj5zeb.js → coverage.cTDc4uSS.js} +1 -1
  12. package/dist/chunks/{creator.203NYCo3.js → creator.CLL8QFMS.js} +43 -53
  13. package/dist/chunks/{defaults.D2ip7f-X.js → defaults.B1FCaFfh.js} +2 -2
  14. package/dist/chunks/{display.CXBnkt9a.js → display.BlTmubjj.js} +1 -1
  15. package/dist/chunks/{doctor.CpHPRoza.js → doctor.Bqc8NDDb.js} +40 -41
  16. package/dist/chunks/{env.DzFJjrmK.js → env.BKKtU2WC.js} +1 -1
  17. package/dist/chunks/{environment.d.DAj1Vt__.d.ts → environment.d.BY56MoGs.d.ts} +1 -1
  18. package/dist/chunks/{globals.9QtHn8Sr.js → globals.CTWMSIPL.js} +10 -10
  19. package/dist/chunks/{index.DpLw24bj.js → index.B8VfM7Mf.js} +6233 -18539
  20. package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
  21. package/dist/chunks/{index.k8L_ZRzq.js → index.CPNMO3h-.js} +54 -46
  22. package/dist/chunks/{index.cx-_w29y.js → index.D0heQG4v.js} +5 -3
  23. package/dist/chunks/{index.ggMXe2IF.js → index.GYMZ12wH.js} +5 -5
  24. package/dist/chunks/{index.C4tKZ0yW.js → index.uwTEEBsB.js} +88 -68
  25. package/dist/chunks/{init-forks.hzLs7kMZ.js → init-forks.CbYYa5xq.js} +1 -1
  26. package/dist/chunks/{init-threads.COb0VD5D.js → init-threads.DtjdvxPl.js} +1 -1
  27. package/dist/chunks/{init.D0qF-GGk.js → init.DrHtV5zd.js} +7 -6
  28. package/dist/chunks/module-dependencies.CwNPkcV4.js +71 -0
  29. package/dist/chunks/{native.CBlba4VV.js → native.cdzHIdmv.js} +47 -33
  30. package/dist/chunks/{nativeModuleMocker.CXSh3m91.js → nativeModuleMocker.D8f4cW4A.js} +2 -2
  31. package/dist/chunks/{nativeModuleRunner.jwZPY3dg.js → nativeModuleRunner.xi64Afb2.js} +1 -1
  32. package/dist/chunks/{node.BzimPqT5.js → node.uQulW0ei.js} +1 -1
  33. package/dist/chunks/{pathe.M-eThtNZ.CknpM8Or.js → pathe.M-eThtNZ.Ba-7h1rE.js} +8 -6
  34. package/dist/chunks/{plugin.d.BsjqSb4-.d.ts → plugin.d.C8mmycim.d.ts} +88 -53
  35. package/dist/chunks/{plugins.D2ut1V9b.js → plugins.DPQHVT0p.js} +1 -1
  36. package/dist/chunks/{resolver.fbW9AUvG.js → resolver.CtCcxIy1.js} +1 -1
  37. package/dist/chunks/{rpc.BTmCtPly.js → rpc.DpkUyY1N.js} +2 -2
  38. package/dist/chunks/{rpc.d.BPFHl-HE.d.ts → rpc.d.Cft1biqy.d.ts} +2 -1
  39. package/dist/chunks/{run.BTlFXlnv.js → run.Cm2sd7-x.js} +97 -82
  40. package/dist/chunks/{setup-common.BglbuAHD.js → setup-common.BABL3z3m.js} +3 -3
  41. package/dist/chunks/{source-map.DUxvo12T.js → source-map.DdKI5IHB.js} +13 -4
  42. package/dist/chunks/{source-map.d.BLHtC2OB.d.ts → source-map.d.kzFtk_dj.d.ts} +1 -1
  43. package/dist/chunks/{spy.DgMTfhrK.js → spy.DDMXghXv.js} +45 -16
  44. package/dist/chunks/{task-utils.d.C-IeGxLU.d.ts → task-utils.d.PFh2BV6Q.d.ts} +1 -1
  45. package/dist/chunks/tinyrainbow.Do8I1XRG.js +88 -0
  46. package/dist/chunks/{utils.RcGwuOc_.js → utils.DSfl_w8V.js} +44 -42
  47. package/dist/chunks/{vm.vTyZj_02.js → vm.Uo_C9Uld.js} +14 -11
  48. package/dist/chunks/{worker.d.Bt2A2mmi.d.ts → worker.d.BH-r1bPu.d.ts} +8 -3
  49. package/dist/cli.js +4 -4
  50. package/dist/config.cjs +1 -1
  51. package/dist/config.d.ts +9 -10
  52. package/dist/config.js +2 -2
  53. package/dist/index.d.ts +10 -10
  54. package/dist/index.js +10 -10
  55. package/dist/module-evaluator.d.ts +2 -2
  56. package/dist/node.d.ts +9 -10
  57. package/dist/node.js +26 -25
  58. package/dist/runtime.d.ts +4 -4
  59. package/dist/runtime.js +4 -4
  60. package/dist/spy.js +1 -1
  61. package/dist/task-utils.js +6 -4
  62. package/dist/worker.d.ts +4 -4
  63. package/dist/worker.js +21 -20
  64. package/dist/workers/forks.js +19 -18
  65. package/dist/workers/runVmTests.js +23 -14
  66. package/dist/workers/threads.js +19 -18
  67. package/dist/workers/vmForks.js +13 -13
  68. package/dist/workers/vmThreads.js +13 -13
  69. package/package.json +28 -27
  70. package/dist/chunks/cli-api.C4x4GGip.js +0 -528
  71. package/dist/chunks/tinyrainbow.Ht9iggcq.js +0 -95
@@ -185,15 +185,20 @@ async function installPackage(names, options = {}) {
185
185
  const [agent] = detectedAgent.split("@");
186
186
  if (!Array.isArray(names)) names = [names];
187
187
  const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
188
- if (options.preferOffline) if (detectedAgent === "yarn@berry") args.unshift("--cached");
189
- else args.unshift("--prefer-offline");
188
+ if (options.preferOffline) {
189
+ if (detectedAgent === "yarn@berry") args.unshift("--cached");
190
+ else args.unshift("--prefer-offline");
191
+ }
190
192
  if (agent === "pnpm") {
191
193
  args.unshift(
192
194
  /**
193
- * Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
195
+ * Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`.
196
+ * Uses the `--config.` escape hatch instead of `--prod=false` because pnpm >=12.4.1
197
+ * routes `install <pkg>` through its `add`-compatible parser, which rejects `--prod`.
194
198
  * @see https://pnpm.io/cli/install#--prod--p
199
+ * @see https://github.com/pnpm/pnpm/issues/14868
195
200
  */
196
- "--prod=false"
201
+ "--config.prod=false"
197
202
  );
198
203
  if (existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.unshift("-w");
199
204
  }
@@ -1,5 +1,5 @@
1
1
  import fs__default from 'node:fs';
2
- import { n as normalize, k as splitFileAndPostfix$1, j as join, l as isBareImport } from './pathe.M-eThtNZ.CknpM8Or.js';
2
+ import { n as normalize, k as splitFileAndPostfix$1, j as join, l as isBareImport } from './pathe.M-eThtNZ.Ba-7h1rE.js';
3
3
  import { i as isBuiltin, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
4
4
  import { E as EnvironmentTeardownError, a as getSafeWorkerState } from './utils.DYj33du9.js';
5
5
  import { pathToFileURL, URL as URL$1 } from 'node:url';
@@ -565,6 +565,7 @@ class VitestModuleRunner extends viteModuleRunner.ModuleRunner {
565
565
  return await this.cachedModule(url, importer);
566
566
  }
567
567
  _cachedRequest(url, module, callstack = [], metadata) {
568
+ this.vitestOptions.getWorkerState().dependencies?.add(module.id);
568
569
  // @ts-expect-error "cachedRequest" is private
569
570
  return super.cachedRequest(url, module, callstack, metadata);
570
571
  }
@@ -639,7 +640,10 @@ function getCachedVitestImport(id, state) {
639
640
  const relativeRoot = relativeIds[root] ?? (relativeIds[root] = getRelativeDistDir(root));
640
641
  if (id.includes(distDir) || id.includes(normalizedDistDir)) {
641
642
  const { file, postfix } = splitFileAndPostfix$1(id);
642
- const externalize = id.startsWith("file://") ? id : `${pathToFileURL(file)}${postfix}`;
643
+ // Vite resolves the Windows drive letter in upper case, but Node.js caches
644
+ // modules by URL, so keep the drive letter Vitest itself was loaded with
645
+ const path = file.startsWith(normalizedDistDir) ? distDir + file.slice(normalizedDistDir.length) : file;
646
+ const externalize = id.startsWith("file://") ? id : `${pathToFileURL(path)}${postfix}`;
643
647
  externalizeMap.set(id, externalize);
644
648
  return {
645
649
  externalize,
@@ -788,13 +792,15 @@ function startVitestModuleRunner(options) {
788
792
  // the null prototype is not preserved by the IPC serialization, so
789
793
  // ids like "constructor" must not fall through to Object.prototype
790
794
  const warmResult = warm && (Object.hasOwn(warm, id) ? warm[id] : Object.hasOwn(warm, rawId) ? warm[rawId] : void 0);
791
- if (warmResult) if ("tmp" in warmResult) try {
792
- return {
793
- code: readFileSync(warmResult.tmp, "utf-8"),
794
- ...warmResult
795
- };
796
- } catch {}
797
- else return warmResult;
795
+ if (warmResult) {
796
+ if ("tmp" in warmResult) try {
797
+ return {
798
+ code: readFileSync(warmResult.tmp, "utf-8"),
799
+ ...warmResult
800
+ };
801
+ } catch {}
802
+ else return warmResult;
803
+ }
798
804
  }
799
805
  const otelCarrier = traces?.getContextCarrier();
800
806
  const result = await trackFetchTime(rpc().fetch(id, importer, environment(), options, otelCarrier));
@@ -1526,43 +1532,45 @@ var node = {
1526
1532
  let context = vm.createContext();
1527
1533
  let global = vm.runInContext("this", context);
1528
1534
  const contextGlobals = new Set(Object.getOwnPropertyNames(global));
1529
- for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey)) if (descriptor.configurable) Object.defineProperty(global, nodeGlobalsKey, {
1530
- configurable: true,
1531
- enumerable: descriptor.enumerable,
1532
- get() {
1533
- // @ts-expect-error: no index signature
1534
- const val = globalThis[nodeGlobalsKey];
1535
- // override lazy getter
1536
- Object.defineProperty(global, nodeGlobalsKey, {
1537
- configurable: true,
1538
- enumerable: descriptor.enumerable,
1539
- value: val,
1540
- writable: descriptor.writable === true || nodeGlobalsKey === "performance"
1541
- });
1542
- return val;
1543
- },
1544
- set(val) {
1545
- // override lazy getter
1546
- Object.defineProperty(global, nodeGlobalsKey, {
1547
- configurable: true,
1548
- enumerable: descriptor.enumerable,
1549
- value: val,
1550
- writable: true
1551
- });
1552
- }
1553
- });
1554
- else if ("value" in descriptor) Object.defineProperty(global, nodeGlobalsKey, {
1555
- configurable: false,
1556
- enumerable: descriptor.enumerable,
1557
- value: descriptor.value,
1558
- writable: descriptor.writable
1559
- });
1560
- else Object.defineProperty(global, nodeGlobalsKey, {
1561
- configurable: false,
1562
- enumerable: descriptor.enumerable,
1563
- get: descriptor.get,
1564
- set: descriptor.set
1565
- });
1535
+ for (const [nodeGlobalsKey, descriptor] of nodeGlobals) if (!contextGlobals.has(nodeGlobalsKey)) {
1536
+ if (descriptor.configurable) Object.defineProperty(global, nodeGlobalsKey, {
1537
+ configurable: true,
1538
+ enumerable: descriptor.enumerable,
1539
+ get() {
1540
+ // @ts-expect-error: no index signature
1541
+ const val = globalThis[nodeGlobalsKey];
1542
+ // override lazy getter
1543
+ Object.defineProperty(global, nodeGlobalsKey, {
1544
+ configurable: true,
1545
+ enumerable: descriptor.enumerable,
1546
+ value: val,
1547
+ writable: descriptor.writable === true || nodeGlobalsKey === "performance"
1548
+ });
1549
+ return val;
1550
+ },
1551
+ set(val) {
1552
+ // override lazy getter
1553
+ Object.defineProperty(global, nodeGlobalsKey, {
1554
+ configurable: true,
1555
+ enumerable: descriptor.enumerable,
1556
+ value: val,
1557
+ writable: true
1558
+ });
1559
+ }
1560
+ });
1561
+ else if ("value" in descriptor) Object.defineProperty(global, nodeGlobalsKey, {
1562
+ configurable: false,
1563
+ enumerable: descriptor.enumerable,
1564
+ value: descriptor.value,
1565
+ writable: descriptor.writable
1566
+ });
1567
+ else Object.defineProperty(global, nodeGlobalsKey, {
1568
+ configurable: false,
1569
+ enumerable: descriptor.enumerable,
1570
+ get: descriptor.get,
1571
+ set: descriptor.set
1572
+ });
1573
+ }
1566
1574
  global.global = global;
1567
1575
  global.Buffer = Buffer;
1568
1576
  global.ArrayBuffer = ArrayBuffer;
@@ -1,4 +1,4 @@
1
- import { y } from './tinyrainbow.Ht9iggcq.js';
1
+ import { $ } from './tinyrainbow.Do8I1XRG.js';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
@@ -508,6 +508,7 @@ function requireReactIs_production () {
508
508
  type === REACT_STRICT_MODE_TYPE ||
509
509
  type === REACT_SUSPENSE_TYPE ||
510
510
  type === REACT_SUSPENSE_LIST_TYPE ||
511
+ type === REACT_VIEW_TRANSITION_TYPE ||
511
512
  ("object" === typeof type &&
512
513
  null !== type &&
513
514
  (type.$$typeof === REACT_LAZY_TYPE ||
@@ -648,6 +649,7 @@ function requireReactIs_development$1 () {
648
649
  type === REACT_STRICT_MODE_TYPE ||
649
650
  type === REACT_SUSPENSE_TYPE ||
650
651
  type === REACT_SUSPENSE_LIST_TYPE ||
652
+ type === REACT_VIEW_TRANSITION_TYPE ||
651
653
  ("object" === typeof type &&
652
654
  null !== type &&
653
655
  (type.$$typeof === REACT_LAZY_TYPE ||
@@ -1071,7 +1073,7 @@ function printFunction(val, printFunctionName) {
1071
1073
  return `[Function ${val.name || "anonymous"}]`;
1072
1074
  }
1073
1075
  function printSymbol(val) {
1074
- return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
1076
+ return Symbol.prototype.toString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
1075
1077
  }
1076
1078
  function printError(val) {
1077
1079
  return `[${errorToString.call(val)}]`;
@@ -1239,7 +1241,7 @@ function validateOptions(options) {
1239
1241
  function getColorsHighlight() {
1240
1242
  return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1241
1243
  const value = DEFAULT_THEME[key];
1242
- const color = value && y[value];
1244
+ const color = value && $[value];
1243
1245
  if (color && typeof color.close === "string" && typeof color.open === "string") colors[key] = color;
1244
1246
  else throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
1245
1247
  return colors;
@@ -1,10 +1,10 @@
1
1
  import * as chai from 'chai';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { t as takeCoverageInsideWorker } from './coverage.S6Dao4g-.js';
4
- import { r as rpc } from './rpc.BTmCtPly.js';
5
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BglbuAHD.js';
3
+ import { t as takeCoverageInsideWorker } from './coverage.-bm5IxnW.js';
4
+ import { r as rpc } from './rpc.DpkUyY1N.js';
5
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BABL3z3m.js';
6
6
  import { g as getWorkerState } from './utils.DYj33du9.js';
7
- import { T as TestRunner } from './index.C4tKZ0yW.js';
7
+ import { T as TestRunner } from './index.uwTEEBsB.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -12,7 +12,7 @@ function setupChaiConfig(config) {
12
12
 
13
13
  async function resolveSnapshotEnvironment(config, moduleRunner) {
14
14
  if (!config.snapshotEnvironment) {
15
- const { VitestNodeSnapshotEnvironment } = await import('./node.BzimPqT5.js');
15
+ const { VitestNodeSnapshotEnvironment } = await import('./node.uQulW0ei.js');
16
16
  return new VitestNodeSnapshotEnvironment();
17
17
  }
18
18
  const mod = await moduleRunner.import(config.snapshotEnvironment);
@@ -1,17 +1,17 @@
1
- import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.BTlFXlnv.js';
1
+ import { b as printDiffOrStringify, d as diff, a as processError, T as TestSyntaxError, g as getCurrentTest, c as createTaskCollector, e as getCurrentSuite, f as createChainable, h as getHooks, i as getFn, m as matchesTags, j as afterAll, k as afterEach, l as aroundAll, n as aroundEach, o as beforeAll, q as beforeEach, r as describe, t as it, u as onTestFailed, v as onTestFinished, w as recordArtifact, x as suite, y as test } from './run.Cm2sd7-x.js';
2
2
  import { i as isChildProcess, r as resetModules, g as getWorkerState } from './utils.DYj33du9.js';
3
- import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.DUxvo12T.js';
4
- import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.DgMTfhrK.js';
5
- import { u as isObject, B as getCallLastIndex, g as getType, D as noop, x as assertTypes, w as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.CknpM8Or.js';
6
- import { g as getDefaultExportFromCjs, f as format, a as commonjsGlobal } from './index.cx-_w29y.js';
7
- import { s as stringify, i as inspect } from './display.CXBnkt9a.js';
8
- import { y } from './tinyrainbow.Ht9iggcq.js';
3
+ import { e as parseErrorStacktrace, a as getSafeTimers, f as parseSingleStack, h as delay } from './source-map.DdKI5IHB.js';
4
+ import { i as isMockFunction, f as fn, a as spyOn, r as restoreAllMocks, b as resetAllMocks, c as clearAllMocks } from './spy.DDMXghXv.js';
5
+ import { u as isObject, B as getCallLastIndex, g as getType, D as noop, x as assertTypes, w as ordinal, E as createSimpleStackTrace, i as isAbsolute, a as relative, n as normalize } from './pathe.M-eThtNZ.Ba-7h1rE.js';
6
+ import { g as getDefaultExportFromCjs, f as format, a as commonjsGlobal } from './index.D0heQG4v.js';
7
+ import { s as stringify, i as inspect } from './display.BlTmubjj.js';
8
+ import { $ } from './tinyrainbow.Do8I1XRG.js';
9
9
  import * as chai from 'chai';
10
10
  import { use, util } from 'chai';
11
11
  import { getNames, getTests, getTestName, createFileTask } from '../task-utils.js';
12
- import { g as getSerializers, a as addSerializer } from './plugins.D2ut1V9b.js';
12
+ import { g as getSerializers, a as addSerializer } from './plugins.DPQHVT0p.js';
13
13
  import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
14
- import { r as rpc, V as VitestEvaluatedModules } from './rpc.BTmCtPly.js';
14
+ import { r as rpc, V as VitestEvaluatedModules } from './rpc.DpkUyY1N.js';
15
15
  import { Bench } from 'tinybench';
16
16
  import { expectTypeOf } from 'expect-type';
17
17
 
@@ -133,7 +133,8 @@ function serialize(val, indent = 2, formatOverrides = {}) {
133
133
  }));
134
134
  }
135
135
  function escapeBacktickString(str) {
136
- return str.replace(/`|\\|\$\{/g, "\\$&");
136
+ // a raw CR inside a template literal is read back as LF
137
+ return str.replace(/`|\\|\$\{/g, "\\$&").replace(/\r/g, "\\r");
137
138
  }
138
139
  function printBacktickString(str) {
139
140
  return `\`${escapeBacktickString(str)}\``;
@@ -176,9 +177,10 @@ function deepMergeSnapshot(target, source) {
176
177
  if (isObject(target) && isObject(source)) {
177
178
  const mergedOutput = { ...target };
178
179
  Object.keys(source).forEach((key) => {
179
- if (isObject(source[key]) && !source[key].$$typeof) if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
180
- else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
181
- else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
180
+ if (isObject(source[key]) && !source[key].$$typeof) {
181
+ if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
182
+ else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
183
+ } else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
182
184
  else Object.assign(mergedOutput, { [key]: source[key] });
183
185
  });
184
186
  return mergedOutput;
@@ -378,6 +380,7 @@ class SnapshotState {
378
380
  _inlineSnapshotStacks;
379
381
  _testIdToKeys = new DefaultMap(() => []);
380
382
  _rawSnapshots;
383
+ _rawSnapshotFiles = /* @__PURE__ */ new Set();
381
384
  _uncheckedKeys;
382
385
  _snapshotFormat;
383
386
  _environment;
@@ -571,17 +574,18 @@ class SnapshotState {
571
574
  // * The update flag is set to 'none'.
572
575
  // * There's no snapshot file or a file without this snapshot on a CI environment.
573
576
  if (opts.hasSnapshot && this._updateSnapshot === "all" || (!opts.hasSnapshot || !opts.snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
574
- if (this._updateSnapshot === "all") if (!opts.pass) {
575
- if (opts.hasSnapshot) this.updated.increment(opts.testId);
576
- else this.added.increment(opts.testId);
577
- this._addSnapshot(opts.key, opts.addValue, {
578
- stack: opts.stack,
579
- testId: opts.testId,
580
- rawSnapshot: opts.rawSnapshot,
581
- assertionName: opts.assertionName
582
- });
583
- } else this.matched.increment(opts.testId);
584
- else {
577
+ if (this._updateSnapshot === "all") {
578
+ if (!opts.pass) {
579
+ if (opts.hasSnapshot) this.updated.increment(opts.testId);
580
+ else this.added.increment(opts.testId);
581
+ this._addSnapshot(opts.key, opts.addValue, {
582
+ stack: opts.stack,
583
+ testId: opts.testId,
584
+ rawSnapshot: opts.rawSnapshot,
585
+ assertionName: opts.assertionName
586
+ });
587
+ } else this.matched.increment(opts.testId);
588
+ } else {
585
589
  this._addSnapshot(opts.key, opts.addValue, {
586
590
  stack: opts.stack,
587
591
  testId: opts.testId,
@@ -681,6 +685,7 @@ class SnapshotState {
681
685
  let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
682
686
  if (!rawSnapshot) receivedSerialized = addExtraLineBreaks(receivedSerialized);
683
687
  if (rawSnapshot) {
688
+ this._rawSnapshotFiles.add(rawSnapshot.file);
684
689
  // normalize EOL when snapshot contains CRLF but received is LF
685
690
  if (rawSnapshot.content && /\r\n/.test(rawSnapshot.content) && !/\r\n/.test(receivedSerialized)) rawSnapshot.content = normalizeNewlines(rawSnapshot.content);
686
691
  }
@@ -741,6 +746,14 @@ class SnapshotState {
741
746
  assertionName
742
747
  });
743
748
  }
749
+ /**
750
+ * The snapshot file, if the test file stores snapshots in it, and every asserted file snapshot.
751
+ */
752
+ getSnapshotFiles() {
753
+ const files = Array.from(this._rawSnapshotFiles);
754
+ if (this._fileExists || Object.keys(this._snapshotData).length) files.unshift(this.snapshotPath);
755
+ return files;
756
+ }
744
757
  async pack() {
745
758
  const snapshot = {
746
759
  filepath: this.testFilePath,
@@ -1066,7 +1079,7 @@ const ChaiStyleAssertions = (chai, utils) => {
1066
1079
  defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
1067
1080
  defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
1068
1081
  defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
1069
- defMethod("returned", "toHaveReturned");
1082
+ defMethod("returned", "toHaveReturnedWith");
1070
1083
  defMethod("returnedWith", "toHaveReturnedWith");
1071
1084
  defMethod("returnedTimes", "toHaveReturnedTimes");
1072
1085
  defMethod("lastReturnedWith", "toHaveLastReturnedWith");
@@ -1107,10 +1120,11 @@ ${printReceived(actual)}`
1107
1120
  },
1108
1121
  toBeOneOf(actual, expected) {
1109
1122
  const { equals, customTesters } = this;
1110
- const { printReceived, printExpected, matcherHint } = this.utils;
1123
+ const { printReceived, printExpected, matcherHint, iterableEquality } = this.utils;
1124
+ const testers = [...customTesters, iterableEquality];
1111
1125
  let pass;
1112
- if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual, customTesters));
1113
- else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual, customTesters));
1126
+ if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual, testers));
1127
+ else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual, testers));
1114
1128
  else throw new TypeError(`You must provide an array or set to ${matcherHint(".toBeOneOf")}, not '${typeof expected}'.`);
1115
1129
  return {
1116
1130
  pass,
@@ -1132,11 +1146,11 @@ ${printReceived(actual)}`
1132
1146
  }
1133
1147
  };
1134
1148
 
1135
- const EXPECTED_COLOR = y.green;
1136
- const RECEIVED_COLOR = y.red;
1137
- const INVERTED_COLOR = y.inverse;
1138
- const BOLD_WEIGHT = y.bold;
1139
- const DIM_COLOR = y.dim;
1149
+ const EXPECTED_COLOR = $.green;
1150
+ const RECEIVED_COLOR = $.red;
1151
+ const INVERTED_COLOR = $.inverse;
1152
+ const BOLD_WEIGHT = $.bold;
1153
+ const DIM_COLOR = $.dim;
1140
1154
  function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
1141
1155
  const { comment = "", isDirectExpectCall = false, isNot = false, promise = "", secondArgument = "", expectedColor = EXPECTED_COLOR, receivedColor = RECEIVED_COLOR, secondArgumentColor = EXPECTED_COLOR } = options;
1142
1156
  let hint = "";
@@ -1983,10 +1997,12 @@ const JestChaiExpect = (chai, utils) => {
1983
1997
  if (promise === "rejects") utils.flag(this, "object", () => {
1984
1998
  throw object;
1985
1999
  });
1986
- else if (promise === "resolves" && typeof object !== "function") if (!isNot) {
1987
- const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
1988
- throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
1989
- } else return;
2000
+ else if (promise === "resolves" && typeof object !== "function") {
2001
+ if (!isNot) {
2002
+ const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
2003
+ throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
2004
+ } else return;
2005
+ }
1990
2006
  _super.apply(this, args);
1991
2007
  };
1992
2008
  });
@@ -2079,7 +2095,7 @@ const JestChaiExpect = (chai, utils) => {
2079
2095
  def("toContainEqual", function(expected) {
2080
2096
  const obj = utils.flag(this, "object");
2081
2097
  const index = Array.from(obj).findIndex((item) => {
2082
- return equals(item, expected, customTesters);
2098
+ return equals(item, expected, [...customTesters, iterableEquality]);
2083
2099
  });
2084
2100
  this.assert(index !== -1, "expected #{this} to deep equally contain #{exp}", "expected #{this} to not deep equally contain #{exp}", expected);
2085
2101
  });
@@ -2160,7 +2176,7 @@ const JestChaiExpect = (chai, utils) => {
2160
2176
  return utils.getPathInfo(actual, propertyName);
2161
2177
  };
2162
2178
  const { value, exists } = getValue();
2163
- const pass = exists && (args.length === 1 || equals(expected, value, customTesters));
2179
+ const pass = exists && (args.length === 1 || equals(expected, value, [...customTesters, iterableEquality]));
2164
2180
  const valueString = args.length === 1 ? "" : ` with value ${inspect(expected, { truncate: 40 })}`;
2165
2181
  return this.assert(pass, `expected #{this} to have property "${propertyName}"${valueString}`, `expected #{this} to not have property "${propertyName}"${valueString}`, expected, exists ? value : void 0);
2166
2182
  });
@@ -2290,11 +2306,12 @@ const JestChaiExpect = (chai, utils) => {
2290
2306
  const isNot = utils.flag(this, "negate");
2291
2307
  let thrown = null;
2292
2308
  if (promise === "rejects") thrown = obj;
2293
- else if (promise === "resolves" && typeof obj !== "function") if (!isNot) {
2294
- const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
2295
- throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
2296
- } else return;
2297
- else {
2309
+ else if (promise === "resolves" && typeof obj !== "function") {
2310
+ if (!isNot) {
2311
+ const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
2312
+ throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
2313
+ } else return;
2314
+ } else {
2298
2315
  let isThrow = false;
2299
2316
  try {
2300
2317
  obj();
@@ -2317,7 +2334,7 @@ const JestChaiExpect = (chai, utils) => {
2317
2334
  }
2318
2335
  if (typeof expected === "object" && "asymmetricMatch" in expected && typeof expected.asymmetricMatch === "function") {
2319
2336
  const matcher = expected;
2320
- return this.assert(thrown && matcher.asymmetricMatch(thrown), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
2337
+ return this.assert(thrown && matcher.asymmetricMatch(thrown, [...customTesters, iterableEquality]), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
2321
2338
  }
2322
2339
  const equal = equals(thrown, expected, [...customTesters, iterableEquality]);
2323
2340
  return this.assert(equal, "expected a thrown value to equal #{exp}", "expected a thrown value not to equal #{exp}", expected, thrown);
@@ -2356,11 +2373,11 @@ const JestChaiExpect = (chai, utils) => {
2356
2373
  });
2357
2374
  [{
2358
2375
  name: "toHaveResolvedWith",
2359
- condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result)),
2376
+ condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result, [...customTesters, iterableEquality])),
2360
2377
  action: "resolve"
2361
2378
  }, {
2362
2379
  name: ["toHaveReturnedWith", "toReturnWith"],
2363
- condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result)),
2380
+ condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result, [...customTesters, iterableEquality])),
2364
2381
  action: "return"
2365
2382
  }].forEach(({ name, condition, action }) => {
2366
2383
  def(name, function(value) {
@@ -2384,14 +2401,14 @@ const JestChaiExpect = (chai, utils) => {
2384
2401
  name: "toHaveLastResolvedWith",
2385
2402
  condition: (spy, value) => {
2386
2403
  const result = spy.mock.settledResults.at(-1);
2387
- return Boolean(result && result.type === "fulfilled" && equals(result.value, value));
2404
+ return Boolean(result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]));
2388
2405
  },
2389
2406
  action: "resolve"
2390
2407
  }, {
2391
2408
  name: "toHaveLastReturnedWith",
2392
2409
  condition: (spy, value) => {
2393
2410
  const result = spy.mock.results.at(-1);
2394
- return Boolean(result && result.type === "return" && equals(result.value, value));
2411
+ return Boolean(result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]));
2395
2412
  },
2396
2413
  action: "return"
2397
2414
  }].forEach(({ name, condition, action }) => {
@@ -2406,14 +2423,14 @@ const JestChaiExpect = (chai, utils) => {
2406
2423
  name: "toHaveNthResolvedWith",
2407
2424
  condition: (spy, index, value) => {
2408
2425
  const result = spy.mock.settledResults[index - 1];
2409
- return result && result.type === "fulfilled" && equals(result.value, value);
2426
+ return result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]);
2410
2427
  },
2411
2428
  action: "resolve"
2412
2429
  }, {
2413
2430
  name: "toHaveNthReturnedWith",
2414
2431
  condition: (spy, index, value) => {
2415
2432
  const result = spy.mock.results[index - 1];
2416
- return result && result.type === "return" && equals(result.value, value);
2433
+ return result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]);
2417
2434
  },
2418
2435
  action: "return"
2419
2436
  }].forEach(({ name, condition, action }) => {
@@ -2493,25 +2510,25 @@ const JestChaiExpect = (chai, utils) => {
2493
2510
  });
2494
2511
  };
2495
2512
  function formatCalls(spy, msg, showActualCall) {
2496
- if (spy.mock.calls.length) msg += y.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
2497
- let methodCall = y.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
2513
+ if (spy.mock.calls.length) msg += $.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
2514
+ let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
2498
2515
  if (showActualCall) methodCall += diff(showActualCall, callArg, { omitAnnotationLines: true });
2499
2516
  else methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
2500
2517
  methodCall += "\n";
2501
2518
  return methodCall;
2502
2519
  }).join("\n")}`);
2503
- msg += y.gray(`\n\nNumber of calls: ${y.bold(spy.mock.calls.length)}\n`);
2520
+ msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
2504
2521
  return msg;
2505
2522
  }
2506
2523
  function formatReturns(spy, results, msg, showActualReturn) {
2507
- if (results.length) msg += y.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
2508
- let methodCall = y.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
2524
+ if (results.length) msg += $.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
2525
+ let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
2509
2526
  if (showActualReturn) methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
2510
2527
  else methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
2511
2528
  methodCall += "\n";
2512
2529
  return methodCall;
2513
2530
  }).join("\n")}`);
2514
- msg += y.gray(`\n\nNumber of calls: ${y.bold(spy.mock.calls.length)}\n`);
2531
+ msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
2515
2532
  return msg;
2516
2533
  }
2517
2534
 
@@ -6883,13 +6900,15 @@ class FakeTimers {
6883
6900
  return 0;
6884
6901
  }
6885
6902
  setTimerTickMode(mode, interval) {
6886
- if (this._checkFakeTimers()) if (mode === "manual") this._clock.setTickMode({ mode: "manual" });
6887
- else if (mode === "nextTimerAsync") this._clock.setTickMode({ mode: "nextAsync" });
6888
- else if (mode === "interval") this._clock.setTickMode({
6889
- mode: "interval",
6890
- delta: interval
6891
- });
6892
- else throw new Error(`Invalid tick mode: ${mode}`);
6903
+ if (this._checkFakeTimers()) {
6904
+ if (mode === "manual") this._clock.setTickMode({ mode: "manual" });
6905
+ else if (mode === "nextTimerAsync") this._clock.setTickMode({ mode: "nextAsync" });
6906
+ else if (mode === "interval") this._clock.setTickMode({
6907
+ mode: "interval",
6908
+ delta: interval
6909
+ });
6910
+ else throw new Error(`Invalid tick mode: ${mode}`);
6911
+ }
6893
6912
  }
6894
6913
  configure(config) {
6895
6914
  this._userConfig = config;
@@ -8243,8 +8262,8 @@ function createBench(test, config, moduleRunner) {
8243
8262
  if (excessiveInvocations?.length) {
8244
8263
  const entries = excessiveInvocations.map(({ moduleId, exportName }) => ` - ${formatModuleId(moduleId, workerState.config.root)} > ${exportName}`).join("\n");
8245
8264
  console.warn([
8246
- y.yellow(y.bold("Benchmark Warning")),
8247
- `Benchmark ${y.bold(`"${groupName(options)}"`)} accessed module export getters too many times.`,
8265
+ $.yellow($.bold("Benchmark Warning")),
8266
+ `Benchmark ${$.bold(`"${groupName(options)}"`)} accessed module export getters too many times.`,
8248
8267
  "",
8249
8268
  "This can make results unreliable because export getters add overhead.",
8250
8269
  "See https://vitest.dev/guide/benchmarking#module-runner-overhead",
@@ -8369,8 +8388,8 @@ function createBench(test, config, moduleRunner) {
8369
8388
  const names = Array.from(pending, (reg) => `"${reg.name}"`).join(", ");
8370
8389
  pending.clear();
8371
8390
  console.warn([
8372
- y.yellow(y.bold("Benchmark Warning")),
8373
- `Test ${y.bold(`"${test.fullTestName}"`)} registered benchmarks that never ran: ${names}.`,
8391
+ $.yellow($.bold("Benchmark Warning")),
8392
+ `Test ${$.bold(`"${test.fullTestName}"`)} registered benchmarks that never ran: ${names}.`,
8374
8393
  "",
8375
8394
  "Call `.run()` on the registration, or pass it to `bench.compare()`.",
8376
8395
  "See https://vitest.dev/guide/benchmarking#defining-a-benchmark"
@@ -8463,6 +8482,7 @@ class TestRunner {
8463
8482
  const name = getNames(test).slice(1).join(" > ");
8464
8483
  this.snapshotClient.skipTest(suite.file.filepath, name);
8465
8484
  }
8485
+ this.snapshotClient.getSnapshotState(suite.file.filepath).getSnapshotFiles().forEach((file) => this.workerState.dependencies?.add(file));
8466
8486
  const result = await this.snapshotClient.finish(suite.file.filepath);
8467
8487
  if (this.workerState.config.snapshotOptions.updateSnapshot === "none" && result.unchecked) {
8468
8488
  let message = `Obsolete snapshots found when no snapshot update is expected.\n`;
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.D0qF-GGk.js';
1
+ import { i as init } from './init.DrHtV5zd.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.D0qF-GGk.js';
2
+ import { i as init } from './init.DrHtV5zd.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) {
@@ -2,12 +2,12 @@ import { readFileSync } from 'node:fs';
2
2
  import module$1, { isBuiltin } from 'node:module';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { EvaluatedModules, ModuleRunner } from 'vite/module-runner';
5
- import { e as environments, b as VitestTransport } from './index.k8L_ZRzq.js';
6
- import { r as resolve } from './pathe.M-eThtNZ.CknpM8Or.js';
7
- import { b as serializeValue, c as createStackString, p as parseStacktrace } from './source-map.DUxvo12T.js';
8
- import { m } from './tinyrainbow.Ht9iggcq.js';
5
+ import { e as environments, b as VitestTransport } from './index.CPNMO3h-.js';
6
+ import { r as resolve } from './pathe.M-eThtNZ.Ba-7h1rE.js';
7
+ import { b as serializeValue, c as createStackString, p as parseStacktrace } from './source-map.DdKI5IHB.js';
8
+ import { w } from './tinyrainbow.Do8I1XRG.js';
9
9
  import { Traces } from '../traces.js';
10
- import { o as onCancel, V as VitestEvaluatedModules, a as rpcDone, c as createRuntimeRpc } from './rpc.BTmCtPly.js';
10
+ import { o as onCancel, V as VitestEvaluatedModules, a as rpcDone, c as createRuntimeRpc } from './rpc.DpkUyY1N.js';
11
11
  import { s as setupInspect } from './inspector.CvyFGlXm.js';
12
12
  import { E as EnvironmentTeardownError } from './utils.DYj33du9.js';
13
13
 
@@ -163,6 +163,7 @@ async function execute(method, ctx, worker, traces) {
163
163
  evaluatedModules: new VitestEvaluatedModules(),
164
164
  resolvingModules,
165
165
  moduleExecutionInfo: /* @__PURE__ */ new Map(),
166
+ dependencies: ctx.config.experimental.recordDependencies ? /* @__PURE__ */ new Set() : void 0,
166
167
  config: ctx.config,
167
168
  // this is set later by vm or base
168
169
  environment: null,
@@ -266,7 +267,7 @@ function init(worker) {
266
267
  process.env.VITEST_WORKER_ID = String(message.workerId);
267
268
  reportMemory = message.options.reportMemory;
268
269
  poolId = message.poolId;
269
- if (message.context.config.disableColors) m();
270
+ if (message.context.config.disableColors) w();
270
271
  traces ??= await new Traces({
271
272
  enabled: message.traces.enabled,
272
273
  sdkPath: message.traces.sdkPath