@vitest/snapshot 3.0.0 → 3.0.2

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 (2) hide show
  1. package/dist/index.js +27 -27
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ function decodeInteger(reader, relative) {
23
23
  const shouldNegate = value & 1;
24
24
  value >>>= 1;
25
25
  if (shouldNegate) {
26
- value = -0x80000000 | -value;
26
+ value = -2147483648 | -value;
27
27
  }
28
28
  return relative + value;
29
29
  }
@@ -663,7 +663,7 @@ function extractLocation(urlLike) {
663
663
  const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
664
664
  url = url.slice(isWindows ? 5 : 4);
665
665
  }
666
- return [url, parts[2] || void 0, parts[3] || void 0];
666
+ return [url, parts[2] || undefined, parts[3] || undefined];
667
667
  }
668
668
  function parseSingleFFOrSafariStack(raw) {
669
669
  let line = raw.trim();
@@ -681,7 +681,7 @@ function parseSingleFFOrSafariStack(raw) {
681
681
  }
682
682
  const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
683
683
  const matches = line.match(functionNameRegex);
684
- const functionName = matches && matches[1] ? matches[1] : void 0;
684
+ const functionName = matches && matches[1] ? matches[1] : undefined;
685
685
  const [url, lineNumber, columnNumber] = extractLocation(
686
686
  line.replace(functionNameRegex, "")
687
687
  );
@@ -710,7 +710,7 @@ function parseSingleV8Stack(raw) {
710
710
  location ? location[1] : sanitizedLine
711
711
  );
712
712
  let method = location && sanitizedLine || "";
713
- let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
713
+ let file = url && ["eval", "<anonymous>"].includes(url) ? undefined : url;
714
714
  if (!file || !lineNumber || !columnNumber) {
715
715
  return null;
716
716
  }
@@ -744,7 +744,7 @@ function parseStacktrace(stack, options = {}) {
744
744
  if (options.getFileName) {
745
745
  stack2.file = options.getFileName(stack2.file);
746
746
  }
747
- const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
747
+ const map = (_a = options.getSourceMap) == null ? undefined : _a.call(options, stack2.file);
748
748
  if (!map || typeof map !== "object" || !map.version) {
749
749
  return stack2;
750
750
  }
@@ -873,7 +873,7 @@ function requireJsTokens () {
873
873
  yield ({
874
874
  type: "RegularExpressionLiteral",
875
875
  value: match[0],
876
- closed: match[1] !== void 0 && match[1] !== "\\"
876
+ closed: match[1] !== undefined && match[1] !== "\\"
877
877
  });
878
878
  continue;
879
879
  }
@@ -1011,7 +1011,7 @@ function requireJsTokens () {
1011
1011
  yield ({
1012
1012
  type: "StringLiteral",
1013
1013
  value: match[0],
1014
- closed: match[2] !== void 0
1014
+ closed: match[2] !== undefined
1015
1015
  });
1016
1016
  continue;
1017
1017
  }
@@ -1112,7 +1112,7 @@ function requireJsTokens () {
1112
1112
  yield ({
1113
1113
  type: "JSXString",
1114
1114
  value: match[0],
1115
- closed: match[2] !== void 0
1115
+ closed: match[2] !== undefined
1116
1116
  });
1117
1117
  continue;
1118
1118
  }
@@ -1187,7 +1187,7 @@ function requireJsTokens () {
1187
1187
  yield ({
1188
1188
  type: "MultiLineComment",
1189
1189
  value: match[0],
1190
- closed: match[1] !== void 0
1190
+ closed: match[1] !== undefined
1191
1191
  });
1192
1192
  continue;
1193
1193
  }
@@ -1210,7 +1210,7 @@ function requireJsTokens () {
1210
1210
  value: firstCodePoint
1211
1211
  });
1212
1212
  }
1213
- return void 0;
1213
+ return undefined;
1214
1214
  };
1215
1215
  return jsTokens_1;
1216
1216
  }
@@ -1318,11 +1318,11 @@ function a(n) {
1318
1318
  }
1319
1319
  a.open = "";
1320
1320
  a.close = "";
1321
- function C(n = !1) {
1322
- let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
1323
- return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
1321
+ function C(n = false) {
1322
+ let e = typeof process != "undefined" ? process : undefined, i = (e == null ? undefined : e.env) || {}, g = (e == null ? undefined : e.argv) || [];
1323
+ return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? undefined : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
1324
1324
  }
1325
- function p(n = !1) {
1325
+ function p(n = false) {
1326
1326
  let e = C(n), i = (r, t, c, o) => {
1327
1327
  let l = "", s = 0;
1328
1328
  do
@@ -1481,7 +1481,7 @@ function replaceInlineSnap(code, s, currentIndex, newSnap) {
1481
1481
  const firstKeywordMatch = /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/.exec(
1482
1482
  codeStartingAtIndex
1483
1483
  );
1484
- if (!startMatch || startMatch.index !== (firstKeywordMatch == null ? void 0 : firstKeywordMatch.index)) {
1484
+ if (!startMatch || startMatch.index !== (firstKeywordMatch == null ? undefined : firstKeywordMatch.index)) {
1485
1485
  return replaceObjectSnap(code, s, index, newSnap);
1486
1486
  }
1487
1487
  const quote = startMatch[1];
@@ -1732,17 +1732,17 @@ function prepareExpected(expected) {
1732
1732
  function findStartIndent() {
1733
1733
  var _a, _b;
1734
1734
  const matchObject = /^( +)\}\s+$/m.exec(expected || "");
1735
- const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
1735
+ const objectIndent = (_a = matchObject == null ? undefined : matchObject[1]) == null ? undefined : _a.length;
1736
1736
  if (objectIndent) {
1737
1737
  return objectIndent;
1738
1738
  }
1739
1739
  const matchText = /^\n( +)"/.exec(expected || "");
1740
- return ((_b = matchText == null ? void 0 : matchText[1]) == null ? void 0 : _b.length) || 0;
1740
+ return ((_b = matchText == null ? undefined : matchText[1]) == null ? undefined : _b.length) || 0;
1741
1741
  }
1742
1742
  const startIndent = findStartIndent();
1743
- let expectedTrimmed = expected == null ? void 0 : expected.trim();
1743
+ let expectedTrimmed = expected == null ? undefined : expected.trim();
1744
1744
  if (startIndent) {
1745
- expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +\}$/, "}");
1745
+ expectedTrimmed = expectedTrimmed == null ? undefined : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +\}$/, "}");
1746
1746
  }
1747
1747
  return expectedTrimmed;
1748
1748
  }
@@ -1981,10 +1981,10 @@ class SnapshotState {
1981
1981
  key = testNameToKey(testName, count);
1982
1982
  }
1983
1983
  this._testIdToKeys.get(testId).push(key);
1984
- if (!(isInline && this._snapshotData[key] !== void 0)) {
1984
+ if (!(isInline && this._snapshotData[key] !== undefined)) {
1985
1985
  this._uncheckedKeys.delete(key);
1986
1986
  }
1987
- let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
1987
+ let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, undefined, this._snapshotFormat);
1988
1988
  if (!rawSnapshot) {
1989
1989
  receivedSerialized = addExtraLineBreaks(receivedSerialized);
1990
1990
  }
@@ -1996,7 +1996,7 @@ class SnapshotState {
1996
1996
  const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
1997
1997
  const expectedTrimmed = rawSnapshot ? expected : prepareExpected(expected);
1998
1998
  const pass = expectedTrimmed === (rawSnapshot ? receivedSerialized : prepareExpected(receivedSerialized));
1999
- const hasSnapshot = expected !== void 0;
1999
+ const hasSnapshot = expected !== undefined;
2000
2000
  const snapshotIsPersisted = isInline || this._fileExists || rawSnapshot && rawSnapshot.content != null;
2001
2001
  if (pass && !isInline && !rawSnapshot) {
2002
2002
  this._snapshotData[key] = receivedSerialized;
@@ -2016,7 +2016,7 @@ ${JSON.stringify(
2016
2016
  )}`
2017
2017
  );
2018
2018
  }
2019
- stack = ((_b = (_a = this.environment).processStackTrace) == null ? void 0 : _b.call(_a, _stack)) || _stack;
2019
+ stack = ((_b = (_a = this.environment).processStackTrace) == null ? undefined : _b.call(_a, _stack)) || _stack;
2020
2020
  stack.column--;
2021
2021
  if (this._inlineSnapshotStacks.some((s) => s.file === stack.file && s.line === stack.line && s.column === stack.column)) {
2022
2022
  this._inlineSnapshots = this._inlineSnapshots.filter((s) => !(s.file === stack.file && s.line === stack.line && s.column === stack.column));
@@ -2061,7 +2061,7 @@ ${JSON.stringify(
2061
2061
  return {
2062
2062
  actual: rawSnapshot ? receivedSerialized : removeExtraLineBreaks(receivedSerialized),
2063
2063
  count,
2064
- expected: expectedTrimmed !== void 0 ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : void 0,
2064
+ expected: expectedTrimmed !== undefined ? rawSnapshot ? expectedTrimmed : removeExtraLineBreaks(expectedTrimmed) : undefined,
2065
2065
  key,
2066
2066
  pass: false
2067
2067
  };
@@ -2215,8 +2215,8 @@ class SnapshotClient {
2215
2215
  throw createMismatchError(
2216
2216
  `Snapshot \`${key || "unknown"}\` mismatched`,
2217
2217
  snapshotState.expand,
2218
- rawSnapshot ? actual : actual == null ? void 0 : actual.trim(),
2219
- rawSnapshot ? expected : expected == null ? void 0 : expected.trim()
2218
+ rawSnapshot ? actual : actual == null ? undefined : actual.trim(),
2219
+ rawSnapshot ? expected : expected == null ? undefined : expected.trim()
2220
2220
  );
2221
2221
  }
2222
2222
  }
@@ -2235,7 +2235,7 @@ class SnapshotClient {
2235
2235
  filepath,
2236
2236
  rawSnapshot.file
2237
2237
  );
2238
- rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) ?? void 0;
2238
+ rawSnapshot.content = await snapshotState.environment.readSnapshotFile(rawSnapshot.file) ?? undefined;
2239
2239
  }
2240
2240
  return this.assert(options);
2241
2241
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/snapshot",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
5
5
  "description": "Vitest snapshot manager",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -39,13 +39,13 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "magic-string": "^0.30.17",
42
- "pathe": "^2.0.0",
43
- "@vitest/pretty-format": "3.0.0"
42
+ "pathe": "^2.0.1",
43
+ "@vitest/pretty-format": "3.0.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/natural-compare": "^1.4.3",
47
47
  "natural-compare": "^1.4.0",
48
- "@vitest/utils": "3.0.0"
48
+ "@vitest/utils": "3.0.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rimraf dist && rollup -c",