@noma.to/qwik-testing-library 1.3.0 → 1.3.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 (85) hide show
  1. package/lib/lib/mock.qwik.cjs +3 -3
  2. package/lib/lib/mock.qwik.mjs +1 -1
  3. package/lib/lib/qwik-testing-library.qwik.cjs +2 -2
  4. package/lib/lib/qwik-testing-library.qwik.mjs +3 -3
  5. package/lib/lib/qwikloader.qwik.cjs +1 -1
  6. package/lib/lib/qwikloader.qwik.mjs +1 -1
  7. package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.cjs +175 -35
  8. package/lib/node_modules/.pnpm/{@vitest_expect@2.1.8 → @vitest_expect@3.0.5}/node_modules/@vitest/expect/dist/index.qwik.mjs +180 -40
  9. package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.cjs +301 -10
  10. package/lib/node_modules/.pnpm/{@vitest_pretty-format@2.1.8 → @vitest_pretty-format@3.0.5}/node_modules/@vitest/pretty-format/dist/index.qwik.mjs +306 -15
  11. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.cjs +1 -1
  12. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/chunk-tasks.qwik.mjs +1 -1
  13. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.cjs +130 -44
  14. package/lib/node_modules/.pnpm/{@vitest_runner@2.1.8 → @vitest_runner@3.0.5}/node_modules/@vitest/runner/dist/index.qwik.mjs +130 -44
  15. package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.cjs +119 -84
  16. package/lib/node_modules/.pnpm/{@vitest_snapshot@2.1.8 → @vitest_snapshot@3.0.5}/node_modules/@vitest/snapshot/dist/index.qwik.mjs +119 -84
  17. package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.cjs +20 -3
  18. package/lib/node_modules/.pnpm/{@vitest_spy@2.1.8 → @vitest_spy@3.0.5}/node_modules/@vitest/spy/dist/index.qwik.mjs +20 -3
  19. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.cjs +3 -3
  20. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.qwik.mjs +3 -3
  21. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.cjs +37 -21
  22. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/diff.qwik.mjs +37 -21
  23. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.cjs +2 -2
  24. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/error.qwik.mjs +2 -2
  25. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.cjs +1 -1
  26. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/helpers.qwik.mjs +1 -1
  27. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.cjs +6 -4
  28. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/index.qwik.mjs +6 -4
  29. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.cjs +1 -1
  30. package/lib/node_modules/.pnpm/{@vitest_utils@2.1.8 → @vitest_utils@3.0.5}/node_modules/@vitest/utils/dist/source-map.qwik.mjs +1 -1
  31. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.mjs +6 -6
  32. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.cjs +1 -3
  33. package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/map.qwik.mjs +1 -3
  34. package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.cjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.cjs} +2 -2
  35. package/lib/node_modules/.pnpm/{pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.mjs → pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.mjs} +2 -2
  36. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +4 -0
  37. package/lib/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +5 -0
  38. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.cjs +1 -1
  39. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/utils.C8RiOc4B.qwik.mjs +1 -1
  40. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.cjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.cjs} +439 -211
  41. package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.DgezovHB.qwik.mjs → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0/node_modules/vitest/dist/chunks/vi.CjhMlMwf.qwik.mjs} +415 -187
  42. package/package.json +8 -8
  43. package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.cjs +0 -7
  44. package/lib/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/browser.qwik.mjs +0 -8
  45. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.cjs +0 -0
  46. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/arguments.qwik.mjs +0 -0
  47. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.cjs +0 -0
  48. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/array.qwik.mjs +0 -0
  49. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.cjs +0 -0
  50. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/bigint.qwik.mjs +0 -0
  51. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.cjs +0 -0
  52. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/class.qwik.mjs +0 -0
  53. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.cjs +0 -0
  54. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/date.qwik.mjs +0 -0
  55. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.cjs +0 -0
  56. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/error.qwik.mjs +0 -0
  57. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.cjs +0 -0
  58. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/function.qwik.mjs +0 -0
  59. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.cjs +0 -0
  60. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/helpers.qwik.mjs +0 -0
  61. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.cjs +0 -0
  62. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/html.qwik.mjs +0 -0
  63. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/index.qwik.cjs +0 -0
  64. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.cjs +0 -0
  65. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/number.qwik.mjs +0 -0
  66. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.cjs +0 -0
  67. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/object.qwik.mjs +0 -0
  68. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.cjs +0 -0
  69. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/promise.qwik.mjs +0 -0
  70. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.cjs +0 -0
  71. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/regexp.qwik.mjs +0 -0
  72. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.cjs +0 -0
  73. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/set.qwik.mjs +0 -0
  74. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.cjs +0 -0
  75. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/string.qwik.mjs +0 -0
  76. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.cjs +0 -0
  77. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/symbol.qwik.mjs +0 -0
  78. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.cjs +0 -0
  79. /package/lib/node_modules/.pnpm/{loupe@3.1.2 → loupe@3.1.3}/node_modules/loupe/lib/typedarray.qwik.mjs +0 -0
  80. /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.cjs +0 -0
  81. /package/lib/node_modules/.pnpm/{tinyrainbow@1.2.0 → tinyrainbow@2.0.0}/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.qwik.mjs +0 -0
  82. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.cjs +0 -0
  83. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.qwik.mjs +0 -0
  84. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.cjs +0 -0
  85. /package/lib/node_modules/.pnpm/{vitest@2.1.8_@types_node@22.10.3_@vitest_ui@2.1.8_jsdom@26.0.0 → vitest@3.0.5_@types_node@22.13.1_@vitest_ui@3.0.5_jiti@2.4.2_jsdom@26.0.0}/node_modules/vitest/dist/chunks/date.W2xKR2qe.qwik.mjs +0 -0
@@ -3,8 +3,8 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const index = require("../../../../../@vitest_pretty-format@2.1.8/node_modules/@vitest/pretty-format/dist/index.qwik.cjs");
7
- const pathe_ff20891b = require("../../../../../pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.qwik.cjs");
6
+ const index = require("../../../../../@vitest_pretty-format@3.0.5/node_modules/@vitest/pretty-format/dist/index.qwik.cjs");
7
+ const pathe_UZHd4nF = require("../../../../../pathe@2.0.2/node_modules/pathe/dist/shared/pathe.UZ-hd4nF.qwik.cjs");
8
8
  const comma = ",".charCodeAt(0);
9
9
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
10
10
  const intToChar = new Uint8Array(64);
@@ -603,7 +603,7 @@ function parseSingleV8Stack(raw) {
603
603
  if (file.startsWith("file://")) {
604
604
  file = file.slice(7);
605
605
  }
606
- file = pathe_ff20891b.r(file);
606
+ file = file.startsWith("node:") || file.startsWith("internal:") ? file : pathe_UZHd4nF.r(file);
607
607
  if (method) {
608
608
  method = method.replace(/__vite_ssr_import_\d+__\./g, "");
609
609
  }
@@ -1208,7 +1208,7 @@ function p(n = false) {
1208
1208
  ) : a;
1209
1209
  return u;
1210
1210
  }
1211
- p(false);
1211
+ p();
1212
1212
  const lineSplitRE = /\r?\n/;
1213
1213
  function positionToOffset(source, lineNumber, columnNumber) {
1214
1214
  const lines = source.split(lineSplitRE);
@@ -1613,43 +1613,66 @@ function deepMergeSnapshot(target, source) {
1613
1613
  }
1614
1614
  return target;
1615
1615
  }
1616
+ class DefaultMap extends Map {
1617
+ constructor(defaultFn, entries) {
1618
+ super(entries);
1619
+ this.defaultFn = defaultFn;
1620
+ }
1621
+ get(key) {
1622
+ if (!this.has(key)) {
1623
+ this.set(key, this.defaultFn(key));
1624
+ }
1625
+ return super.get(key);
1626
+ }
1627
+ }
1628
+ class CounterMap extends DefaultMap {
1629
+ constructor() {
1630
+ super(() => 0);
1631
+ }
1632
+ increment(key) {
1633
+ this.set(key, this.get(key) + 1);
1634
+ }
1635
+ total() {
1636
+ let total = 0;
1637
+ for (const x of this.values()) {
1638
+ total += x;
1639
+ }
1640
+ return total;
1641
+ }
1642
+ }
1616
1643
  class SnapshotState {
1617
1644
  constructor(testFilePath, snapshotPath, snapshotContent, options) {
1618
- __publicField(this, "_counters");
1645
+ __publicField(this, "_counters", new CounterMap());
1619
1646
  __publicField(this, "_dirty");
1620
1647
  __publicField(this, "_updateSnapshot");
1621
1648
  __publicField(this, "_snapshotData");
1622
1649
  __publicField(this, "_initialData");
1623
1650
  __publicField(this, "_inlineSnapshots");
1624
1651
  __publicField(this, "_inlineSnapshotStacks");
1652
+ __publicField(this, "_testIdToKeys", new DefaultMap(() => []));
1625
1653
  __publicField(this, "_rawSnapshots");
1626
1654
  __publicField(this, "_uncheckedKeys");
1627
1655
  __publicField(this, "_snapshotFormat");
1628
1656
  __publicField(this, "_environment");
1629
1657
  __publicField(this, "_fileExists");
1630
- __publicField(this, "added");
1658
+ __publicField(this, "added", new CounterMap());
1659
+ __publicField(this, "matched", new CounterMap());
1660
+ __publicField(this, "unmatched", new CounterMap());
1661
+ __publicField(this, "updated", new CounterMap());
1631
1662
  __publicField(this, "expand");
1632
- __publicField(this, "matched");
1633
- __publicField(this, "unmatched");
1634
- __publicField(this, "updated");
1635
1663
  this.testFilePath = testFilePath;
1636
1664
  this.snapshotPath = snapshotPath;
1637
1665
  const { data, dirty } = getSnapshotData(snapshotContent, options);
1638
1666
  this._fileExists = snapshotContent != null;
1639
- this._initialData = data;
1640
- this._snapshotData = data;
1667
+ this._initialData = { ...data };
1668
+ this._snapshotData = { ...data };
1641
1669
  this._dirty = dirty;
1642
1670
  this._inlineSnapshots = [];
1643
1671
  this._inlineSnapshotStacks = [];
1644
1672
  this._rawSnapshots = [];
1645
1673
  this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
1646
- this._counters = /* @__PURE__ */ new Map();
1647
1674
  this.expand = options.expand || false;
1648
- this.added = 0;
1649
- this.matched = 0;
1650
- this.unmatched = 0;
1651
1675
  this._updateSnapshot = options.updateSnapshot;
1652
- this.updated = 0;
1653
1676
  this._snapshotFormat = {
1654
1677
  printBasicPrototype: false,
1655
1678
  escapeString: false,
@@ -1671,11 +1694,30 @@ class SnapshotState {
1671
1694
  }
1672
1695
  markSnapshotsAsCheckedForTest(testName) {
1673
1696
  this._uncheckedKeys.forEach((uncheckedKey) => {
1674
- if (keyToTestName(uncheckedKey) === testName) {
1697
+ if (/ \d+$| > /.test(uncheckedKey.slice(testName.length))) {
1675
1698
  this._uncheckedKeys.delete(uncheckedKey);
1676
1699
  }
1677
1700
  });
1678
1701
  }
1702
+ clearTest(testId) {
1703
+ this._inlineSnapshots = this._inlineSnapshots.filter((s) => s.testId !== testId);
1704
+ this._inlineSnapshotStacks = this._inlineSnapshotStacks.filter((s) => s.testId !== testId);
1705
+ for (const key of this._testIdToKeys.get(testId)) {
1706
+ const name = keyToTestName(key);
1707
+ const count = this._counters.get(name);
1708
+ if (count > 0) {
1709
+ if (key in this._snapshotData || key in this._initialData) {
1710
+ this._snapshotData[key] = this._initialData[key];
1711
+ }
1712
+ this._counters.set(name, count - 1);
1713
+ }
1714
+ }
1715
+ this._testIdToKeys.delete(testId);
1716
+ this.added.delete(testId);
1717
+ this.updated.delete(testId);
1718
+ this.matched.delete(testId);
1719
+ this.unmatched.delete(testId);
1720
+ }
1679
1721
  _inferInlineSnapshotStack(stacks) {
1680
1722
  const promiseIndex = stacks.findIndex(
1681
1723
  (i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/)
@@ -1693,6 +1735,7 @@ class SnapshotState {
1693
1735
  if (options.stack) {
1694
1736
  this._inlineSnapshots.push({
1695
1737
  snapshot: receivedSerialized,
1738
+ testId: options.testId,
1696
1739
  ...options.stack
1697
1740
  });
1698
1741
  } else if (options.rawSnapshot) {
@@ -1704,15 +1747,6 @@ class SnapshotState {
1704
1747
  this._snapshotData[key] = receivedSerialized;
1705
1748
  }
1706
1749
  }
1707
- clear() {
1708
- this._snapshotData = this._initialData;
1709
- this._counters = /* @__PURE__ */ new Map();
1710
- this.added = 0;
1711
- this.matched = 0;
1712
- this.unmatched = 0;
1713
- this.updated = 0;
1714
- this._dirty = false;
1715
- }
1716
1750
  async save() {
1717
1751
  const hasExternalSnapshots = Object.keys(this._snapshotData).length;
1718
1752
  const hasInlineSnapshots = this._inlineSnapshots.length;
@@ -1761,6 +1795,7 @@ class SnapshotState {
1761
1795
  }
1762
1796
  }
1763
1797
  match({
1798
+ testId,
1764
1799
  testName,
1765
1800
  received,
1766
1801
  key,
@@ -1770,11 +1805,12 @@ class SnapshotState {
1770
1805
  rawSnapshot
1771
1806
  }) {
1772
1807
  var _a, _b;
1773
- this._counters.set(testName, (this._counters.get(testName) || 0) + 1);
1774
- const count = Number(this._counters.get(testName));
1808
+ this._counters.increment(testName);
1809
+ const count = this._counters.get(testName);
1775
1810
  if (!key) {
1776
1811
  key = testNameToKey(testName, count);
1777
1812
  }
1813
+ this._testIdToKeys.get(testId).push(key);
1778
1814
  if (!(isInline && this._snapshotData[key] !== void 0)) {
1779
1815
  this._uncheckedKeys.delete(key);
1780
1816
  }
@@ -1788,8 +1824,8 @@ class SnapshotState {
1788
1824
  }
1789
1825
  }
1790
1826
  const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
1791
- const expectedTrimmed = prepareExpected(expected);
1792
- const pass = expectedTrimmed === prepareExpected(receivedSerialized);
1827
+ const expectedTrimmed = rawSnapshot ? expected : prepareExpected(expected);
1828
+ const pass = expectedTrimmed === (rawSnapshot ? receivedSerialized : prepareExpected(receivedSerialized));
1793
1829
  const hasSnapshot = expected !== void 0;
1794
1830
  const snapshotIsPersisted = isInline || this._fileExists || rawSnapshot && rawSnapshot.content != null;
1795
1831
  if (pass && !isInline && !rawSnapshot) {
@@ -1816,29 +1852,31 @@ ${JSON.stringify(
1816
1852
  this._inlineSnapshots = this._inlineSnapshots.filter((s) => !(s.file === stack.file && s.line === stack.line && s.column === stack.column));
1817
1853
  throw new Error("toMatchInlineSnapshot cannot be called multiple times at the same location.");
1818
1854
  }
1819
- this._inlineSnapshotStacks.push(stack);
1855
+ this._inlineSnapshotStacks.push({ ...stack, testId });
1820
1856
  }
1821
1857
  if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
1822
1858
  if (this._updateSnapshot === "all") {
1823
1859
  if (!pass) {
1824
1860
  if (hasSnapshot) {
1825
- this.updated++;
1861
+ this.updated.increment(testId);
1826
1862
  } else {
1827
- this.added++;
1863
+ this.added.increment(testId);
1828
1864
  }
1829
1865
  this._addSnapshot(key, receivedSerialized, {
1830
1866
  stack,
1867
+ testId,
1831
1868
  rawSnapshot
1832
1869
  });
1833
1870
  } else {
1834
- this.matched++;
1871
+ this.matched.increment(testId);
1835
1872
  }
1836
1873
  } else {
1837
1874
  this._addSnapshot(key, receivedSerialized, {
1838
1875
  stack,
1876
+ testId,
1839
1877
  rawSnapshot
1840
1878
  });
1841
- this.added++;
1879
+ this.added.increment(testId);
1842
1880
  }
1843
1881
  return {
1844
1882
  actual: "",
@@ -1849,16 +1887,16 @@ ${JSON.stringify(
1849
1887
  };
1850
1888
  } else {
1851
1889
  if (!pass) {
1852
- this.unmatched++;
1890
+ this.unmatched.increment(testId);
1853
1891
  return {
1854
- actual: removeExtraLineBreaks(receivedSerialized),
1892
+ actual: rawSnapshot ? receivedSerialized : removeExtraLineBreaks(receivedSerialized),
1855
1893
  count,
1856
- expected: expectedTrimmed !== void 0 ? removeExtraLineBreaks(expectedTrimmed) : void 0,
1894
+ expected: expectedTrimmed !== void 0 ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : void 0,
1857
1895
  key,
1858
1896
  pass: false
1859
1897
  };
1860
1898
  } else {
1861
- this.matched++;
1899
+ this.matched.increment(testId);
1862
1900
  return {
1863
1901
  actual: "",
1864
1902
  count,
@@ -1887,10 +1925,10 @@ ${JSON.stringify(
1887
1925
  }
1888
1926
  const status = await this.save();
1889
1927
  snapshot.fileDeleted = status.deleted;
1890
- snapshot.added = this.added;
1891
- snapshot.matched = this.matched;
1892
- snapshot.unmatched = this.unmatched;
1893
- snapshot.updated = this.updated;
1928
+ snapshot.added = this.added.total();
1929
+ snapshot.matched = this.matched.total();
1930
+ snapshot.unmatched = this.unmatched.total();
1931
+ snapshot.updated = this.updated.total();
1894
1932
  snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
1895
1933
  snapshot.uncheckedKeys = Array.from(uncheckedKeys);
1896
1934
  return snapshot;
@@ -1915,43 +1953,47 @@ function createMismatchError(message, expand, actual, expected) {
1915
1953
  }
1916
1954
  class SnapshotClient {
1917
1955
  constructor(options = {}) {
1918
- __publicField(this, "filepath");
1919
- __publicField(this, "name");
1920
- __publicField(this, "snapshotState");
1921
1956
  __publicField(this, "snapshotStateMap", /* @__PURE__ */ new Map());
1922
1957
  this.options = options;
1923
1958
  }
1924
- async startCurrentRun(filepath, name, options) {
1925
- var _a;
1926
- this.filepath = filepath;
1927
- this.name = name;
1928
- if (((_a = this.snapshotState) == null ? void 0 : _a.testFilePath) !== filepath) {
1929
- await this.finishCurrentRun();
1930
- if (!this.getSnapshotState(filepath)) {
1931
- this.snapshotStateMap.set(
1932
- filepath,
1933
- await SnapshotState.create(filepath, options)
1934
- );
1935
- }
1936
- this.snapshotState = this.getSnapshotState(filepath);
1959
+ async setup(filepath, options) {
1960
+ if (this.snapshotStateMap.has(filepath)) {
1961
+ return;
1937
1962
  }
1963
+ this.snapshotStateMap.set(
1964
+ filepath,
1965
+ await SnapshotState.create(filepath, options)
1966
+ );
1938
1967
  }
1939
- getSnapshotState(filepath) {
1940
- return this.snapshotStateMap.get(filepath);
1968
+ async finish(filepath) {
1969
+ const state = this.getSnapshotState(filepath);
1970
+ const result = await state.pack();
1971
+ this.snapshotStateMap.delete(filepath);
1972
+ return result;
1941
1973
  }
1942
- clearTest() {
1943
- this.filepath = void 0;
1944
- this.name = void 0;
1974
+ skipTest(filepath, testName) {
1975
+ const state = this.getSnapshotState(filepath);
1976
+ state.markSnapshotsAsCheckedForTest(testName);
1945
1977
  }
1946
- skipTestSnapshots(name) {
1947
- var _a;
1948
- (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(name);
1978
+ clearTest(filepath, testId) {
1979
+ const state = this.getSnapshotState(filepath);
1980
+ state.clearTest(testId);
1981
+ }
1982
+ getSnapshotState(filepath) {
1983
+ const state = this.snapshotStateMap.get(filepath);
1984
+ if (!state) {
1985
+ throw new Error(
1986
+ `The snapshot state for '${filepath}' is not found. Did you call 'SnapshotClient.setup()'?`
1987
+ );
1988
+ }
1989
+ return state;
1949
1990
  }
1950
1991
  assert(options) {
1951
- var _a, _b, _c, _d;
1992
+ var _a, _b;
1952
1993
  const {
1953
- filepath = this.filepath,
1954
- name = this.name,
1994
+ filepath,
1995
+ name,
1996
+ testId = name,
1955
1997
  message,
1956
1998
  isInline = false,
1957
1999
  properties,
@@ -1964,6 +2006,7 @@ class SnapshotClient {
1964
2006
  if (!filepath) {
1965
2007
  throw new Error("Snapshot cannot be used outside of test");
1966
2008
  }
2009
+ const snapshotState = this.getSnapshotState(filepath);
1967
2010
  if (typeof properties === "object") {
1968
2011
  if (typeof received !== "object" || !received) {
1969
2012
  throw new Error(
@@ -1975,7 +2018,7 @@ class SnapshotClient {
1975
2018
  if (!pass2) {
1976
2019
  throw createMismatchError(
1977
2020
  "Snapshot properties mismatched",
1978
- (_c = this.snapshotState) == null ? void 0 : _c.expand,
2021
+ snapshotState.expand,
1979
2022
  received,
1980
2023
  properties
1981
2024
  );
@@ -1988,8 +2031,8 @@ class SnapshotClient {
1988
2031
  }
1989
2032
  }
1990
2033
  const testName = [name, ...message ? [message] : []].join(" > ");
1991
- const snapshotState = this.getSnapshotState(filepath);
1992
2034
  const { actual, expected, key, pass } = snapshotState.match({
2035
+ testId,
1993
2036
  testName,
1994
2037
  received,
1995
2038
  isInline,
@@ -2000,9 +2043,9 @@ class SnapshotClient {
2000
2043
  if (!pass) {
2001
2044
  throw createMismatchError(
2002
2045
  `Snapshot \`${key || "unknown"}\` mismatched`,
2003
- (_d = this.snapshotState) == null ? void 0 : _d.expand,
2004
- actual == null ? void 0 : actual.trim(),
2005
- expected == null ? void 0 : expected.trim()
2046
+ snapshotState.expand,
2047
+ rawSnapshot ? actual : actual == null ? void 0 : actual.trim(),
2048
+ rawSnapshot ? expected : expected == null ? void 0 : expected.trim()
2006
2049
  );
2007
2050
  }
2008
2051
  }
@@ -2010,7 +2053,7 @@ class SnapshotClient {
2010
2053
  if (!options.rawSnapshot) {
2011
2054
  throw new Error("Raw snapshot is required");
2012
2055
  }
2013
- const { filepath = this.filepath, rawSnapshot } = options;
2056
+ const { filepath, rawSnapshot } = options;
2014
2057
  if (rawSnapshot.content == null) {
2015
2058
  if (!filepath) {
2016
2059
  throw new Error("Snapshot cannot be used outside of test");
@@ -2025,14 +2068,6 @@ class SnapshotClient {
2025
2068
  }
2026
2069
  return this.assert(options);
2027
2070
  }
2028
- async finishCurrentRun() {
2029
- if (!this.snapshotState) {
2030
- return null;
2031
- }
2032
- const result = await this.snapshotState.pack();
2033
- this.snapshotState = void 0;
2034
- return result;
2035
- }
2036
2071
  clear() {
2037
2072
  this.snapshotStateMap.clear();
2038
2073
  }