@vitest/snapshot 2.0.0-beta.2 → 2.0.0-beta.3
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.
- package/dist/index.js +10 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -310,7 +310,7 @@ function serialize(val, indent = 2, formatOverrides = {}) {
|
|
310
310
|
);
|
311
311
|
}
|
312
312
|
function escapeBacktickString(str) {
|
313
|
-
return str.replace(
|
313
|
+
return str.replace(/`|\\|\$\{/g, "\\$&");
|
314
314
|
}
|
315
315
|
function printBacktickString(str) {
|
316
316
|
return `\`${escapeBacktickString(str)}\``;
|
@@ -338,7 +338,7 @@ ${snapshots.join("\n\n")}
|
|
338
338
|
function prepareExpected(expected) {
|
339
339
|
function findStartIndent() {
|
340
340
|
var _a, _b;
|
341
|
-
const matchObject = /^( +)}\s+$/m.exec(expected || "");
|
341
|
+
const matchObject = /^( +)\}\s+$/m.exec(expected || "");
|
342
342
|
const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
|
343
343
|
if (objectIndent)
|
344
344
|
return objectIndent;
|
@@ -348,7 +348,7 @@ function prepareExpected(expected) {
|
|
348
348
|
const startIndent = findStartIndent();
|
349
349
|
let expectedTrimmed = expected == null ? void 0 : expected.trim();
|
350
350
|
if (startIndent) {
|
351
|
-
expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/
|
351
|
+
expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +\}$/, "}");
|
352
352
|
}
|
353
353
|
return expectedTrimmed;
|
354
354
|
}
|
@@ -945,8 +945,8 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
945
945
|
return index;
|
946
946
|
}
|
947
947
|
|
948
|
-
const CHROME_IE_STACK_REGEXP = /^\s*at .*(
|
949
|
-
const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(
|
948
|
+
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
|
949
|
+
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
|
950
950
|
const stackIgnorePatterns = [
|
951
951
|
"node:internal",
|
952
952
|
/\/packages\/\w+\/dist\//,
|
@@ -986,7 +986,7 @@ function parseSingleFFOrSafariStack(raw) {
|
|
986
986
|
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
|
987
987
|
if (!line.includes("@") && !line.includes(":"))
|
988
988
|
return null;
|
989
|
-
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(
|
989
|
+
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
|
990
990
|
const matches = line.match(functionNameRegex);
|
991
991
|
const functionName = matches && matches[1] ? matches[1] : void 0;
|
992
992
|
const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ""));
|
@@ -1079,7 +1079,7 @@ async function saveInlineSnapshots(environment, snapshots) {
|
|
1079
1079
|
await environment.saveSnapshotFile(file, transformed);
|
1080
1080
|
}));
|
1081
1081
|
}
|
1082
|
-
const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S
|
1082
|
+
const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;
|
1083
1083
|
function replaceObjectSnap(code, s, index, newSnap) {
|
1084
1084
|
let _code = code.slice(index);
|
1085
1085
|
const startMatch = startObjectRegex.exec(_code);
|
@@ -1121,12 +1121,12 @@ function prepareSnapString(snap, source, index) {
|
|
1121
1121
|
const isOneline = lines.length <= 1;
|
1122
1122
|
const quote = "`";
|
1123
1123
|
if (isOneline)
|
1124
|
-
return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(
|
1124
|
+
return `${quote}${lines.join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}${quote}`;
|
1125
1125
|
return `${quote}
|
1126
|
-
${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(
|
1126
|
+
${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\$\{/g, "\\${")}
|
1127
1127
|
${indent}${quote}`;
|
1128
1128
|
}
|
1129
|
-
const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S
|
1129
|
+
const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/;
|
1130
1130
|
function replaceInlineSnap(code, s, index, newSnap) {
|
1131
1131
|
const codeStartingAtIndex = code.slice(index);
|
1132
1132
|
const startMatch = startRegex.exec(codeStartingAtIndex);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/snapshot",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.0.0-beta.
|
4
|
+
"version": "2.0.0-beta.3",
|
5
5
|
"description": "Vitest snapshot manager",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -45,7 +45,7 @@
|
|
45
45
|
"devDependencies": {
|
46
46
|
"@types/natural-compare": "^1.4.3",
|
47
47
|
"natural-compare": "^1.4.0",
|
48
|
-
"@vitest/utils": "2.0.0-beta.
|
48
|
+
"@vitest/utils": "2.0.0-beta.3"
|
49
49
|
},
|
50
50
|
"scripts": {
|
51
51
|
"build": "rimraf dist && rollup -c",
|