@vitest/snapshot 0.34.3 → 0.34.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 (2) hide show
  1. package/dist/index.js +4 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1034,8 +1034,10 @@ ${indent}${quote}`;
1034
1034
  }
1035
1035
  const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*[\w_$]*(['"`\)])/m;
1036
1036
  function replaceInlineSnap(code, s, index, newSnap) {
1037
- const startMatch = startRegex.exec(code.slice(index));
1038
- if (!startMatch)
1037
+ const codeStartingAtIndex = code.slice(index);
1038
+ const startMatch = startRegex.exec(codeStartingAtIndex);
1039
+ const firstKeywordMatch = /toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/.exec(codeStartingAtIndex);
1040
+ if (!startMatch || startMatch.index !== (firstKeywordMatch == null ? void 0 : firstKeywordMatch.index))
1039
1041
  return replaceObjectSnap(code, s, index, newSnap);
1040
1042
  const quote = startMatch[1];
1041
1043
  const startIndex = index + startMatch.index + startMatch[0].length;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/snapshot",
3
3
  "type": "module",
4
- "version": "0.34.3",
4
+ "version": "0.34.5",
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.1",
47
47
  "natural-compare": "^1.4.0",
48
- "@vitest/utils": "0.34.3"
48
+ "@vitest/utils": "0.34.5"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rimraf dist && rollup -c",