vitest 5.0.3 → 5.0.5

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 (72) 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.CzXt2BO_.js} +40 -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.CLrZKo1g.js} +21 -23
  7. package/dist/chunks/cli-api.De07GUeT.js +13894 -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.C5g4egeG.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.BK86Cncq.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.CXEE6_2C.js} +10 -10
  19. package/dist/chunks/{index.DpLw24bj.js → index.1TqnEahn.js} +7209 -19488
  20. package/dist/chunks/{index.DXQx-kDM.js → index.BoyTG_B7.js} +9 -4
  21. package/dist/chunks/{index.k8L_ZRzq.js → index.CK-t0WMg.js} +60 -53
  22. package/dist/chunks/{index.ggMXe2IF.js → index.CoUIxZd4.js} +7 -5
  23. package/dist/chunks/{index.cx-_w29y.js → index.D0heQG4v.js} +5 -3
  24. package/dist/chunks/{index.C4tKZ0yW.js → index.aTZaPVhf.js} +88 -68
  25. package/dist/chunks/{init-forks.hzLs7kMZ.js → init-forks.CRxIPOJR.js} +1 -1
  26. package/dist/chunks/{init-threads.COb0VD5D.js → init-threads.Dv3kwST_.js} +1 -1
  27. package/dist/chunks/{init.D0qF-GGk.js → init.PvxYpuCm.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.BxrHJNAF.js} +26 -5
  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.BPv-BBRv.js} +134 -110
  40. package/dist/chunks/{setup-common.BglbuAHD.js → setup-common.HGAqWOnX.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.FGl2rw_t.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/module-evaluator.js +16 -12
  57. package/dist/node.d.ts +9 -10
  58. package/dist/node.js +26 -25
  59. package/dist/runtime.d.ts +4 -4
  60. package/dist/runtime.js +4 -4
  61. package/dist/spy.js +1 -1
  62. package/dist/task-utils.js +6 -4
  63. package/dist/worker.d.ts +4 -4
  64. package/dist/worker.js +21 -20
  65. package/dist/workers/forks.js +19 -18
  66. package/dist/workers/runVmTests.js +24 -14
  67. package/dist/workers/threads.js +19 -18
  68. package/dist/workers/vmForks.js +13 -13
  69. package/dist/workers/vmThreads.js +13 -13
  70. package/package.json +28 -27
  71. package/dist/chunks/cli-api.C4x4GGip.js +0 -528
  72. package/dist/chunks/tinyrainbow.Ht9iggcq.js +0 -95
@@ -1,8 +1,8 @@
1
- import { f as format, p as plugins } from './index.cx-_w29y.js';
2
- import { y } from './tinyrainbow.Ht9iggcq.js';
3
- import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.CXBnkt9a.js';
4
- import { p as deepClone, q as getOwnProperties, g as getType$1, u as isObject, v as filterOutComments, w as ordinal, e as createDefer, x as assertTypes, t as toArray, y as isNegativeNaN, z as unique, A as objectAttr } from './pathe.M-eThtNZ.CknpM8Or.js';
5
- import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.DUxvo12T.js';
1
+ import { f as format, p as plugins } from './index.D0heQG4v.js';
2
+ import { $ } from './tinyrainbow.Do8I1XRG.js';
3
+ import { s as stringify, f as format$1, a as formatRegExp, t as truncateString, i as inspect } from './display.BlTmubjj.js';
4
+ import { p as deepClone, q as getOwnProperties, g as getType$1, u as isObject, v as filterOutComments, w as ordinal, e as createDefer, x as assertTypes, t as toArray, y as isNegativeNaN, z as unique, A as objectAttr } from './pathe.M-eThtNZ.Ba-7h1rE.js';
5
+ import { d as diffSequences, b as serializeValue, p as parseStacktrace, a as getSafeTimers } from './source-map.DdKI5IHB.js';
6
6
  import { createTaskName, createFileTask, calculateSuiteHash, interpretTaskModes, hasFailed } from '../task-utils.js';
7
7
 
8
8
  const RealDate = Date;
@@ -508,25 +508,27 @@ function joinAlignedDiffsNoExpand(diffs, options) {
508
508
  while (i !== iLength) {
509
509
  const iStart = i;
510
510
  while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
511
- if (iStart !== i) if (iStart === 0) {
512
- // at start
513
- if (i > nContextLines) {
514
- jLength -= i - nContextLines;
515
- hasExcessAtStartOrEnd = true;
516
- }
517
- } else if (i === iLength) {
518
- // at end
519
- const n = i - iStart;
520
- if (n > nContextLines) {
521
- jLength -= n - nContextLines;
522
- hasExcessAtStartOrEnd = true;
523
- }
524
- } else {
525
- // between changes
526
- const n = i - iStart;
527
- if (n > nContextLines2) {
528
- jLength -= n - nContextLines2;
529
- nExcessesBetweenChanges += 1;
511
+ if (iStart !== i) {
512
+ if (iStart === 0) {
513
+ // at start
514
+ if (i > nContextLines) {
515
+ jLength -= i - nContextLines;
516
+ hasExcessAtStartOrEnd = true;
517
+ }
518
+ } else if (i === iLength) {
519
+ // at end
520
+ const n = i - iStart;
521
+ if (n > nContextLines) {
522
+ jLength -= n - nContextLines;
523
+ hasExcessAtStartOrEnd = true;
524
+ }
525
+ } else {
526
+ // between changes
527
+ const n = i - iStart;
528
+ if (n > nContextLines2) {
529
+ jLength -= n - nContextLines2;
530
+ nExcessesBetweenChanges += 1;
531
+ }
530
532
  }
531
533
  }
532
534
  while (i !== iLength && diffs[i][0] !== DIFF_EQUAL) i += 1;
@@ -564,36 +566,38 @@ function joinAlignedDiffsNoExpand(diffs, options) {
564
566
  while (i !== iLength) {
565
567
  let iStart = i;
566
568
  while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
567
- if (iStart !== i) if (iStart === 0) {
568
- // at beginning
569
- if (i > nContextLines) {
570
- iStart = i - nContextLines;
571
- aStart = iStart;
572
- bStart = iStart;
573
- aEnd = aStart;
574
- bEnd = bStart;
575
- }
576
- for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
577
- } else if (i === iLength) {
578
- // at end
579
- const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
580
- for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
581
- } else {
582
- // between changes
583
- const nCommon = i - iStart;
584
- if (nCommon > nContextLines2) {
585
- const iEnd = iStart + nContextLines;
569
+ if (iStart !== i) {
570
+ if (iStart === 0) {
571
+ // at beginning
572
+ if (i > nContextLines) {
573
+ iStart = i - nContextLines;
574
+ aStart = iStart;
575
+ bStart = iStart;
576
+ aEnd = aStart;
577
+ bEnd = bStart;
578
+ }
579
+ for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
580
+ } else if (i === iLength) {
581
+ // at end
582
+ const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
586
583
  for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
587
- lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
588
- jPatchMark = lines.length;
589
- lines.push("");
590
- const nOmit = nCommon - nContextLines2;
591
- aStart = aEnd + nOmit;
592
- bStart = bEnd + nOmit;
593
- aEnd = aStart;
594
- bEnd = bStart;
595
- for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
596
- } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
584
+ } else {
585
+ // between changes
586
+ const nCommon = i - iStart;
587
+ if (nCommon > nContextLines2) {
588
+ const iEnd = iStart + nContextLines;
589
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
590
+ lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
591
+ jPatchMark = lines.length;
592
+ lines.push("");
593
+ const nOmit = nCommon - nContextLines2;
594
+ aStart = aEnd + nOmit;
595
+ bStart = bEnd + nOmit;
596
+ aEnd = aStart;
597
+ bEnd = bStart;
598
+ for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
599
+ } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
600
+ }
597
601
  }
598
602
  while (i !== iLength && diffs[i][0] === DIFF_DELETE) {
599
603
  pushDeleteLine(diffs[i][1]);
@@ -629,14 +633,14 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
629
633
  function getDefaultOptions() {
630
634
  return {
631
635
  aAnnotation: "Expected",
632
- aColor: y.green,
636
+ aColor: $.green,
633
637
  aIndicator: "-",
634
638
  bAnnotation: "Received",
635
- bColor: y.red,
639
+ bColor: $.red,
636
640
  bIndicator: "+",
637
- changeColor: y.inverse,
641
+ changeColor: $.inverse,
638
642
  changeLineTrailingSpaceColor: noColor,
639
- commonColor: y.dim,
643
+ commonColor: $.dim,
640
644
  commonIndicator: " ",
641
645
  commonLineTrailingSpaceColor: noColor,
642
646
  compareKeys: void 0,
@@ -645,7 +649,7 @@ function getDefaultOptions() {
645
649
  expand: false,
646
650
  includeChangeCounts: false,
647
651
  omitAnnotationLines: false,
648
- patchColor: y.yellow,
652
+ patchColor: $.yellow,
649
653
  printBasicPrototype: false,
650
654
  truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
651
655
  truncateAnnotation: "... Diff result is truncated",
@@ -1260,13 +1264,13 @@ function replaceTrailingSpaces(text) {
1260
1264
  return text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
1261
1265
  }
1262
1266
  function printReceived(object) {
1263
- return y.red(replaceTrailingSpaces(stringify(object)));
1267
+ return $.red(replaceTrailingSpaces(stringify(object)));
1264
1268
  }
1265
1269
  function printExpected(value) {
1266
- return y.green(replaceTrailingSpaces(stringify(value)));
1270
+ return $.green(replaceTrailingSpaces(stringify(value)));
1267
1271
  }
1268
1272
  function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
1269
- return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? y.inverse(diff[1]) : diff[1] : ""), "");
1273
+ return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? $.inverse(diff[1]) : diff[1] : ""), "");
1270
1274
  }
1271
1275
 
1272
1276
  function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
@@ -1658,8 +1662,12 @@ function withFixtures(fn, options) {
1658
1662
  // access the parent fixture ({ a: ({ a }) => {} })
1659
1663
  if (cachedFixtures.has(fixture)) continue;
1660
1664
  cachedFixtures.add(fixture);
1661
- const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
1662
- context[fixture.name] = resolvedValue;
1665
+ try {
1666
+ context[fixture.name] = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
1667
+ } catch (error) {
1668
+ cachedFixtures.delete(fixture);
1669
+ throw error;
1670
+ }
1663
1671
  cleanupFnArray.push(() => {
1664
1672
  cachedFixtures.delete(fixture);
1665
1673
  });
@@ -1701,8 +1709,9 @@ async function resolveScopeFixtureValue(fixtures, suite, fixture) {
1701
1709
  ...fileContext
1702
1710
  } : fixtureContext, cleanupFnFileArray).then((value) => {
1703
1711
  fixtureContext[fixture.name] = value;
1704
- scopedFixturePromiseCache.delete(fixture);
1705
1712
  return value;
1713
+ }).finally(() => {
1714
+ scopedFixturePromiseCache.delete(fixture);
1706
1715
  });
1707
1716
  scopedFixturePromiseCache.set(fixture, promise);
1708
1717
  return promise;
@@ -1750,8 +1759,10 @@ function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new S
1750
1759
  pendingFixtures.push(fixture);
1751
1760
  return;
1752
1761
  }
1753
- if (depSet.has(fixture)) if (fixture.parent) fixture = fixture.parent;
1754
- else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
1762
+ if (depSet.has(fixture)) {
1763
+ if (fixture.parent) fixture = fixture.parent;
1764
+ else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
1765
+ }
1755
1766
  depSet.add(fixture);
1756
1767
  resolveDeps(Array.from(fixture.deps, (n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
1757
1768
  pendingFixtures.push(fixture);
@@ -1838,11 +1849,11 @@ function setCurrentTest(test) {
1838
1849
  function getCurrentTest() {
1839
1850
  return _test;
1840
1851
  }
1841
- const tests = [];
1852
+ const tests = /* @__PURE__ */ new Set();
1842
1853
  function addRunningTest(test) {
1843
- tests.push(test);
1854
+ tests.add(test);
1844
1855
  return () => {
1845
- tests.splice(tests.indexOf(test));
1856
+ tests.delete(test);
1846
1857
  };
1847
1858
  }
1848
1859
  function getRunningTests() {
@@ -1862,6 +1873,10 @@ function createChainable(keys, fn, context) {
1862
1873
  Object.defineProperty(chain, kChainableContext, {
1863
1874
  value: {
1864
1875
  withContext: () => chain.bind(context),
1876
+ extendContext: (ctx) => create({
1877
+ ...context,
1878
+ ...ctx
1879
+ }),
1865
1880
  getFixtures: () => context.fixtures,
1866
1881
  setContext: (key, value) => {
1867
1882
  context[key] = value;
@@ -2584,6 +2599,10 @@ function createSuiteHooks() {
2584
2599
  };
2585
2600
  }
2586
2601
  const POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
2602
+ function assignDefined(target, source) {
2603
+ for (const key in source) if (source[key] !== void 0) target[key] = source[key];
2604
+ return target;
2605
+ }
2587
2606
  function parseArguments(optionsOrFn, timeoutOrTest) {
2588
2607
  if (timeoutOrTest != null && typeof timeoutOrTest === "object") throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
2589
2608
  let options = {};
@@ -2615,16 +2634,16 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
2615
2634
  return tagDefinition;
2616
2635
  }).filter((r) => r != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
2617
2636
  const { name, description, priority, meta, ...options } = tag;
2618
- Object.assign(acc, options);
2637
+ assignDefined(acc, options);
2619
2638
  if (meta) acc.meta = Object.assign(acc.meta ?? Object.create(null), meta);
2620
2639
  return acc;
2621
2640
  }, {});
2622
2641
  const testOwnMeta = options.meta;
2623
- options = {
2624
- ...collectorContext.currentSuite?.options,
2625
- ...tagsOptions,
2626
- ...options
2627
- };
2642
+ const parentOptions = collectorContext.currentSuite?.options;
2643
+ options = assignDefined({
2644
+ ...parentOptions,
2645
+ ...tagsOptions
2646
+ }, options);
2628
2647
  const timeout = options.timeout ?? runner.config.testTimeout;
2629
2648
  // TODO: should this be `parentTask.meta`?
2630
2649
  // currently we don't inherit
@@ -2696,8 +2715,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
2696
2715
  const concurrent = this.concurrent ?? options?.concurrent;
2697
2716
  if (concurrent != null) options.concurrent = concurrent;
2698
2717
  const test = task(formatName(name), {
2699
- ...this,
2700
- ...options,
2718
+ ...assignDefined({ ...this }, options),
2701
2719
  handler
2702
2720
  });
2703
2721
  test.type = "test";
@@ -2796,10 +2814,7 @@ function createSuite() {
2796
2814
  let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2797
2815
  const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
2798
2816
  // inherit options from current suite
2799
- options = {
2800
- ...parentOptions,
2801
- ...options
2802
- };
2817
+ options = assignDefined({ ...parentOptions }, options);
2803
2818
  const shuffle = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
2804
2819
  if (shuffle != null) options.shuffle = shuffle;
2805
2820
  let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
@@ -2822,9 +2837,10 @@ function createSuite() {
2822
2837
  const fnFirst = typeof optionsOrFn === "function";
2823
2838
  cases.forEach((i, idx) => {
2824
2839
  const items = Array.isArray(i) ? i : [i];
2825
- if (fnFirst) if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2826
- else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2827
- else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2840
+ if (fnFirst) {
2841
+ if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2842
+ else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2843
+ } else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2828
2844
  else suite(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2829
2845
  });
2830
2846
  context.setContext("each", void 0);
@@ -2865,9 +2881,10 @@ function createTaskCollector(fn) {
2865
2881
  const fnFirst = typeof optionsOrFn === "function";
2866
2882
  cases.forEach((i, idx) => {
2867
2883
  const items = Array.isArray(i) ? i : [i];
2868
- if (fnFirst) if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2869
- else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2870
- else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2884
+ if (fnFirst) {
2885
+ if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2886
+ else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
2887
+ } else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2871
2888
  else test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2872
2889
  });
2873
2890
  context.setContext("each", void 0);
@@ -2891,10 +2908,10 @@ function createTaskCollector(fn) {
2891
2908
  };
2892
2909
  };
2893
2910
  taskFn.skipIf = function(condition) {
2894
- return condition ? this.skip : this;
2911
+ return getChainableContext(this).extendContext({ skip: !!condition });
2895
2912
  };
2896
2913
  taskFn.runIf = function(condition) {
2897
- return condition ? this : this.skip;
2914
+ return getChainableContext(this).extendContext({ skip: !condition });
2898
2915
  };
2899
2916
  /**
2900
2917
  * Parse builder pattern arguments into a fixtures object.
@@ -3004,7 +3021,7 @@ function formatTitle(template, items, idx) {
3004
3021
  const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
3005
3022
  const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
3006
3023
  // print string without quotes
3007
- if (typeof value === "string") return truncateString(value, inspectOptions.truncate);
3024
+ if (typeof value === "string") return inspectOptions.truncate ? truncateString(value, inspectOptions.truncate) : value;
3008
3025
  return inspect(value, inspectOptions);
3009
3026
  });
3010
3027
  }
@@ -3573,12 +3590,11 @@ async function callTestHooks(runner, test, hooks, sequence) {
3573
3590
  context.onTestFailed = onTestFailed;
3574
3591
  context.onTestFinished = onTestFinished;
3575
3592
  }
3576
- async function callSuiteHook(suite, currentTask, name, runner, args) {
3593
+ async function callSuiteHook(suite, currentTask, name, runner, args, cleanups = []) {
3577
3594
  const sequence = runner.config.sequence.hooks;
3578
- const callbacks = [];
3579
3595
  // stop at file level
3580
3596
  const parentSuite = "filepath" in suite ? null : suite.suite || suite.file;
3581
- if (name === "beforeEach" && parentSuite) callbacks.push(...await callSuiteHook(parentSuite, currentTask, name, runner, args));
3597
+ if (name === "beforeEach" && parentSuite) await callSuiteHook(parentSuite, currentTask, name, runner, args, cleanups);
3582
3598
  const hooks = getSuiteHooks(suite, name, sequence);
3583
3599
  if (hooks.length > 0) updateSuiteHookState(currentTask, name, "run", runner);
3584
3600
  async function runHook(hook) {
@@ -3586,11 +3602,17 @@ async function callSuiteHook(suite, currentTask, name, runner, args) {
3586
3602
  return getBeforeHookCleanupCallback(hook, await hook(...args), name === "beforeEach" ? args[0] : void 0);
3587
3603
  });
3588
3604
  }
3589
- if (sequence === "parallel") callbacks.push(...await Promise.all(hooks.map((hook) => runHook(hook))));
3590
- else for (const hook of hooks) callbacks.push(await runHook(hook));
3605
+ if (sequence === "parallel") {
3606
+ const results = await Promise.allSettled(hooks.map((hook) => runHook(hook)));
3607
+ // hooks can reject with the same `signal.reason`
3608
+ const errors = /* @__PURE__ */ new Set();
3609
+ for (const result of results) if (result.status === "fulfilled") cleanups.push(result.value);
3610
+ else errors.add(result.reason);
3611
+ if (errors.size === 1) throw [...errors][0];
3612
+ if (errors.size > 1) throw new AggregateError([...errors], `Multiple "${name}" hooks failed.`);
3613
+ } else for (const hook of hooks) cleanups.push(await runHook(hook));
3591
3614
  if (hooks.length > 0) updateSuiteHookState(currentTask, name, "pass", runner);
3592
- if (name === "afterEach" && parentSuite) callbacks.push(...await callSuiteHook(parentSuite, currentTask, name, runner, args));
3593
- return callbacks;
3615
+ if (name === "afterEach" && parentSuite) await callSuiteHook(parentSuite, currentTask, name, runner, args);
3594
3616
  }
3595
3617
  function getAroundEachHooks(suite) {
3596
3618
  const hooks = [];
@@ -3862,7 +3884,7 @@ async function runTest(test, runner) {
3862
3884
  const retry = getRetryCount(test.retry);
3863
3885
  for (let retryCount = 0; retryCount <= retry; retryCount++) {
3864
3886
  const attemptErrorsStart = test.result.errors?.length ?? 0;
3865
- let beforeEachCleanups = [];
3887
+ const beforeEachCleanups = [];
3866
3888
  // fixtureCheckpoint is passed by callAroundEachHooks - it represents the count
3867
3889
  // of fixture cleanup functions AFTER all aroundEach fixtures have been resolved
3868
3890
  // but BEFORE the test runs. This allows us to clean up only fixtures created
@@ -3874,7 +3896,7 @@ async function runTest(test, runner) {
3874
3896
  repeats: repeatCount
3875
3897
  });
3876
3898
  test.result.repeatCount = repeatCount;
3877
- beforeEachCleanups = await $("test.beforeEach", () => callSuiteHook(suite, test, "beforeEach", runner, [test.context, suite]));
3899
+ await $("test.beforeEach", () => callSuiteHook(suite, test, "beforeEach", runner, [test.context, suite], beforeEachCleanups));
3878
3900
  if (runner.runTask) await $("test.callback", () => limitMaxConcurrency(() => runner.runTask(test)));
3879
3901
  else {
3880
3902
  const fn = getFn(test);
@@ -4029,7 +4051,7 @@ async function runSuite(suite, runner) {
4029
4051
  };
4030
4052
  const $ = runner.trace;
4031
4053
  updateTask("suite-prepare", suite, runner);
4032
- let beforeAllCleanups = [];
4054
+ const beforeAllCleanups = [];
4033
4055
  if (suite.mode === "skip") {
4034
4056
  suite.result.state = "skip";
4035
4057
  updateTask("suite-finished", suite, runner);
@@ -4044,7 +4066,7 @@ async function runSuite(suite, runner) {
4044
4066
  try {
4045
4067
  // beforeAll
4046
4068
  try {
4047
- beforeAllCleanups = await $("suite.beforeAll", () => callSuiteHook(suite, suite, "beforeAll", runner, [suite]));
4069
+ await $("suite.beforeAll", () => callSuiteHook(suite, suite, "beforeAll", runner, [suite], beforeAllCleanups));
4048
4070
  } catch (e) {
4049
4071
  failTask(suite.result, e, runner.config._diffOptions);
4050
4072
  markTasksAsSkipped(suite, runner);
@@ -4084,14 +4106,16 @@ async function runSuite(suite, runner) {
4084
4106
  if (!suiteRan) markTasksAsSkipped(suite, runner);
4085
4107
  failTask(suite.result, e, runner.config._diffOptions);
4086
4108
  }
4087
- if (suite.mode === "run" || suite.mode === "queued") if (!runner.config.passWithNoTests && !suite.containsTest) {
4088
- suite.result.state = "fail";
4089
- if (!suite.result.errors?.length) {
4090
- const error = processError(/* @__PURE__ */ new Error(`No test found in suite ${suite.name}`));
4091
- suite.result.errors = [error];
4092
- }
4093
- } else if (hasFailed(suite)) suite.result.state = "fail";
4094
- else suite.result.state = "pass";
4109
+ if (suite.mode === "run" || suite.mode === "queued") {
4110
+ if (!runner.config.passWithNoTests && !suite.containsTest) {
4111
+ suite.result.state = "fail";
4112
+ if (!suite.result.errors?.length) {
4113
+ const error = processError(/* @__PURE__ */ new Error(`No test found in suite ${suite.name}`));
4114
+ suite.result.errors = [error];
4115
+ }
4116
+ } else if (hasFailed(suite)) suite.result.state = "fail";
4117
+ else suite.result.state = "pass";
4118
+ }
4095
4119
  suite.result.duration = now() - start;
4096
4120
  await runner.onAfterRunSuite?.(suite);
4097
4121
  updateTask("suite-finished", suite, runner);
@@ -4183,4 +4207,4 @@ async function publicCollect(specs, runner) {
4183
4207
  return files;
4184
4208
  }
4185
4209
 
4186
- export { limitConcurrency as A, shuffle as B, createTagsFilter as C, TestSyntaxError as T, processError as a, printDiffOrStringify as b, createTaskCollector as c, diff as d, getCurrentSuite as e, createChainable as f, getCurrentTest as g, getHooks as h, getFn as i, afterAll as j, afterEach as k, aroundAll as l, matchesTags as m, aroundEach as n, beforeAll as o, publicCollect as p, beforeEach as q, describe as r, startTests as s, it as t, onTestFailed as u, onTestFinished as v, recordArtifact as w, suite as x, test as y, validateTags as z };
4210
+ export { createTagsFilter as A, validateTags as B, shuffle as C, TestSyntaxError as T, processError as a, printDiffOrStringify as b, createTaskCollector as c, diff as d, getCurrentSuite as e, createChainable as f, getCurrentTest as g, getHooks as h, getFn as i, afterAll as j, afterEach as k, aroundAll as l, matchesTags as m, aroundEach as n, beforeAll as o, publicCollect as p, beforeEach as q, describe as r, startTests as s, it as t, onTestFailed as u, onTestFinished as v, recordArtifact as w, suite as x, test as y, limitConcurrency as z };
@@ -1,5 +1,5 @@
1
- import { s as setSafeTimers } from './source-map.DUxvo12T.js';
2
- import { a as addSerializer } from './plugins.D2ut1V9b.js';
1
+ import { s as setSafeTimers } from './source-map.DdKI5IHB.js';
2
+ import { a as addSerializer } from './plugins.DPQHVT0p.js';
3
3
 
4
4
  let globalSetup = false;
5
5
  async function setupCommonEnv(config) {
@@ -7,7 +7,7 @@ async function setupCommonEnv(config) {
7
7
  if (globalSetup) return;
8
8
  globalSetup = true;
9
9
  setSafeTimers();
10
- if (config.globals) (await import('./globals.9QtHn8Sr.js')).registerApiGlobally();
10
+ if (config.globals) (await import('./globals.CXEE6_2C.js')).registerApiGlobally();
11
11
  }
12
12
  function setupDefines(config) {
13
13
  for (const key in config.defines) globalThis[key] = config.defines[key];
@@ -1,5 +1,5 @@
1
- import { g as getDefaultExportFromCjs } from './index.cx-_w29y.js';
2
- import { m as isPrimitive, o as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.CknpM8Or.js';
1
+ import { g as getDefaultExportFromCjs } from './index.D0heQG4v.js';
2
+ import { m as isPrimitive, o as notNullish, r as resolve$1 } from './pathe.M-eThtNZ.Ba-7h1rE.js';
3
3
 
4
4
  var build = {};
5
5
 
@@ -1591,7 +1591,7 @@ function extractLocation(urlLike) {
1591
1591
  const urlObj = new URL(url);
1592
1592
  urlObj.searchParams.delete("import");
1593
1593
  urlObj.searchParams.delete("browserv");
1594
- url = urlObj.pathname + urlObj.hash + urlObj.search;
1594
+ url = tryDecode(urlObj.pathname, decodeURI) + urlObj.hash + urlObj.search;
1595
1595
  }
1596
1596
  if (url.startsWith("/@fs/")) {
1597
1597
  const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
@@ -1604,6 +1604,13 @@ function extractLocation(urlLike) {
1604
1604
  parts[3] || void 0
1605
1605
  ];
1606
1606
  }
1607
+ function tryDecode(value, decode) {
1608
+ try {
1609
+ return decode(value);
1610
+ } catch {
1611
+ return value;
1612
+ }
1613
+ }
1607
1614
  function parseSingleFFOrSafariStack(raw) {
1608
1615
  let line = raw.trim();
1609
1616
  if (SAFARI_NATIVE_CODE_REGEXP.test(line)) return null;
@@ -1663,7 +1670,9 @@ function parseSingleV8Stack(raw) {
1663
1670
  let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
1664
1671
  if (!file || !lineNumber || !columnNumber) return null;
1665
1672
  if (method.startsWith("async ")) method = method.slice(6);
1666
- if (file.startsWith("file://")) file = file.slice(7);
1673
+ if (file.startsWith("file://"))
1674
+ // pathToFileURL also encodes "#" and "?", which decodeURI keeps
1675
+ file = tryDecode(file.slice(7), decodeURIComponent);
1667
1676
  // normalize Windows path (\ -> /)
1668
1677
  file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve$1(file);
1669
1678
  if (method) method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
@@ -1,4 +1,4 @@
1
- import { T as TestError, P as ParsedStack } from './config.d.BxjInJat.js';
1
+ import { T as TestError, P as ParsedStack } from './config.d.QBNYCgFU.js';
2
2
 
3
3
  interface RuntimeCoverageModuleLoader {
4
4
  import: (id: string) => Promise<{
@@ -6,13 +6,38 @@ const MOCK_RESTORE = /* @__PURE__ */ new Set();
6
6
  // but it makes the state slower to access and return different values
7
7
  // if you stored it before calling `mockClear` where it will be recreated
8
8
  const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
9
- const addDirtyMock = DIRTY_MOCK_STATES.add.bind(DIRTY_MOCK_STATES);
10
- const REGISTERED_MOCKS = /* @__PURE__ */ new Set();
9
+ // Mocks whose implementation, once-queue or name changed since their last
10
+ // `mockReset()`, so `resetAllMocks()` only visits mocks that are not already reset
11
+ const DIRTY_MOCK_CONFIGS = /* @__PURE__ */ new Set();
12
+ // a test may spy on `Set.prototype.add`, and the spy itself marks mocks dirty
13
+ const addToSet = Set.prototype.add;
14
+ const MOCK_REFS = /* @__PURE__ */ new WeakMap();
11
15
  const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
12
- REGISTERED_MOCKS.delete(ref);
16
+ DIRTY_MOCK_STATES.delete(ref);
17
+ DIRTY_MOCK_CONFIGS.delete(ref);
13
18
  });
14
19
  const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
15
20
  const MOCKS_BY_STATE = /* @__PURE__ */ new WeakMap();
21
+ function markDirty(set, mock) {
22
+ let ref = MOCK_REFS.get(mock);
23
+ if (!ref) {
24
+ ref = new WeakRef(mock);
25
+ MOCK_REFS.set(mock, ref);
26
+ MOCK_FINALIZER.register(mock, ref);
27
+ }
28
+ addToSet.call(set, ref);
29
+ }
30
+ function unmarkDirty(set, mock) {
31
+ const ref = MOCK_REFS.get(mock);
32
+ if (ref) set.delete(ref);
33
+ }
34
+ function forEachDirty(set, fn) {
35
+ for (const ref of set) {
36
+ const mock = ref.deref();
37
+ if (mock) fn(mock);
38
+ else set.delete(ref);
39
+ }
40
+ }
16
41
  function createMockInstance(options = {}) {
17
42
  const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
18
43
  if (restore) MOCK_RESTORE.add(restore);
@@ -36,9 +61,6 @@ function createMockInstance(options = {}) {
36
61
  if (resetToMockName) config.mockName = mock.name || "vi.fn()";
37
62
  MOCK_CONFIGS.set(mock, config);
38
63
  MOCKS_BY_STATE.set(state, mock);
39
- const ref = new WeakRef(mock);
40
- REGISTERED_MOCKS.add(ref);
41
- MOCK_FINALIZER.register(mock, ref);
42
64
  mock._isMockFunction = true;
43
65
  mock.getMockImplementation = () => {
44
66
  // Jest only returns `config.mockImplementation` here,
@@ -59,21 +81,25 @@ function createMockInstance(options = {}) {
59
81
  value: state
60
82
  });
61
83
  mock.mockImplementation = function mockImplementation(implementation) {
84
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
62
85
  config.mockImplementation = implementation;
63
86
  updateMockPrototype();
64
87
  return mock;
65
88
  };
66
89
  mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
90
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
67
91
  config.onceMockImplementations.push(implementation);
68
92
  updateMockPrototype();
69
93
  return mock;
70
94
  };
71
95
  mock.withImplementation = function withImplementation(implementation, callback) {
96
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
72
97
  const previousImplementation = config.mockImplementation;
73
98
  const previousOnceImplementations = config.onceMockImplementations;
74
99
  const reset = () => {
75
100
  config.mockImplementation = previousImplementation;
76
101
  config.onceMockImplementations = previousOnceImplementations;
102
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
77
103
  updateMockPrototype();
78
104
  };
79
105
  config.mockImplementation = implementation;
@@ -147,7 +173,7 @@ function createMockInstance(options = {}) {
147
173
  state.invocationCallOrder = [];
148
174
  state.results = [];
149
175
  state.settledResults = [];
150
- DIRTY_MOCK_STATES.delete(mock);
176
+ unmarkDirty(DIRTY_MOCK_STATES, mock);
151
177
  return mock;
152
178
  };
153
179
  mock.mockReset = function mockReset() {
@@ -155,6 +181,7 @@ function createMockInstance(options = {}) {
155
181
  config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
156
182
  config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
157
183
  config.onceMockImplementations = [];
184
+ unmarkDirty(DIRTY_MOCK_CONFIGS, mock);
158
185
  updateMockPrototype();
159
186
  return mock;
160
187
  };
@@ -163,7 +190,10 @@ function createMockInstance(options = {}) {
163
190
  return restore?.();
164
191
  };
165
192
  mock.mockName = function mockName(name) {
166
- if (typeof name === "string") config.mockName = name;
193
+ if (typeof name === "string") {
194
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
195
+ config.mockName = name;
196
+ }
167
197
  return mock;
168
198
  };
169
199
  mock.getMockName = function getMockName() {
@@ -269,8 +299,8 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
269
299
  const namedObject = {
270
300
  // to keep the name of the function intact
271
301
  [name]: function(...args) {
272
- addDirtyMock(namedObject[name]);
273
- if (prototypeMock) addDirtyMock(prototypeMock);
302
+ markDirty(DIRTY_MOCK_STATES, namedObject[name]);
303
+ if (prototypeMock) markDirty(DIRTY_MOCK_STATES, prototypeMock);
274
304
  registerCalls(args, state, prototypeState);
275
305
  registerInvocationOrder(invocationCallCounter++, state, prototypeState);
276
306
  const result = {
@@ -453,14 +483,13 @@ function restoreAllMocks() {
453
483
  MOCK_RESTORE.clear();
454
484
  }
455
485
  function clearAllMocks() {
456
- for (const mock of DIRTY_MOCK_STATES) mock.mockClear();
486
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockClear());
457
487
  }
458
488
  function resetAllMocks() {
459
- for (const ref of REGISTERED_MOCKS) {
460
- const mock = ref.deref();
461
- if (mock) mock.mockReset();
462
- else REGISTERED_MOCKS.delete(ref);
463
- }
489
+ // `mockReset()` removes the mock from both sets, so a mock present in both
490
+ // is visited once.
491
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockReset());
492
+ forEachDirty(DIRTY_MOCK_CONFIGS, (mock) => mock.mockReset());
464
493
  }
465
494
  function throwConstructorError(shorthand) {
466
495
  throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
@@ -1,4 +1,4 @@
1
- import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.BxjInJat.js';
1
+ import { bn as SnapshotState, m as Test, bo as PromisifyAssertion, bp as Tester, bq as Plugin, ad as BenchResult, a as File } from './config.d.QBNYCgFU.js';
2
2
 
3
3
  interface SnapshotMatcher<
4
4
  R extends void | Promise<void>,