@vitest/snapshot
Advanced tools
Comparing version 2.1.0-beta.5 to 2.1.0-beta.6
@@ -40,2 +40,3 @@ import { S as SnapshotStateOptions, a as SnapshotMatchOptions, b as SnapshotResult, R as RawSnapshotInfo } from './index-Y6kQUiCB.js'; | ||
private _inlineSnapshots; | ||
private _inlineSnapshotStacks; | ||
private _rawSnapshots; | ||
@@ -42,0 +43,0 @@ private _uncheckedKeys; |
@@ -1379,2 +1379,3 @@ import { plugins, format } from '@vitest/pretty-format'; | ||
this._inlineSnapshots = []; | ||
this._inlineSnapshotStacks = []; | ||
this._rawSnapshots = []; | ||
@@ -1402,2 +1403,3 @@ this._uncheckedKeys = new Set(Object.keys(this._snapshotData)); | ||
_inlineSnapshots; | ||
_inlineSnapshotStacks; | ||
_rawSnapshots; | ||
@@ -1445,24 +1447,7 @@ _uncheckedKeys; | ||
_addSnapshot(key, receivedSerialized, options) { | ||
var _a, _b; | ||
this._dirty = true; | ||
if (options.isInline) { | ||
const error = options.error || new Error("snapshot"); | ||
const stacks = parseErrorStacktrace( | ||
error, | ||
{ ignoreStackEntries: [] } | ||
); | ||
const _stack = this._inferInlineSnapshotStack(stacks); | ||
if (!_stack) { | ||
throw new Error( | ||
`@vitest/snapshot: Couldn't infer stack frame for inline snapshot. | ||
${JSON.stringify( | ||
stacks | ||
)}` | ||
); | ||
} | ||
const stack = ((_b = (_a = this.environment).processStackTrace) == null ? void 0 : _b.call(_a, _stack)) || _stack; | ||
stack.column--; | ||
if (options.stack) { | ||
this._inlineSnapshots.push({ | ||
snapshot: receivedSerialized, | ||
...stack | ||
...options.stack | ||
}); | ||
@@ -1543,2 +1528,3 @@ } else if (options.rawSnapshot) { | ||
}) { | ||
var _a, _b; | ||
this._counters.set(testName, (this._counters.get(testName) || 0) + 1); | ||
@@ -1569,2 +1555,25 @@ const count = Number(this._counters.get(testName)); | ||
} | ||
let stack; | ||
if (isInline) { | ||
const stacks = parseErrorStacktrace( | ||
error || new Error("snapshot"), | ||
{ ignoreStackEntries: [] } | ||
); | ||
const _stack = this._inferInlineSnapshotStack(stacks); | ||
if (!_stack) { | ||
throw new Error( | ||
`@vitest/snapshot: Couldn't infer stack frame for inline snapshot. | ||
${JSON.stringify( | ||
stacks | ||
)}` | ||
); | ||
} | ||
stack = ((_b = (_a = this.environment).processStackTrace) == null ? void 0 : _b.call(_a, _stack)) || _stack; | ||
stack.column--; | ||
if (this._inlineSnapshotStacks.some((s) => s.file === stack.file && s.line === stack.line && s.column === stack.column)) { | ||
this._inlineSnapshots = this._inlineSnapshots.filter((s) => !(s.file === stack.file && s.line === stack.line && s.column === stack.column)); | ||
throw new Error("toMatchInlineSnapshot cannot be called multiple times at the same location."); | ||
} | ||
this._inlineSnapshotStacks.push(stack); | ||
} | ||
if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) { | ||
@@ -1579,4 +1588,3 @@ if (this._updateSnapshot === "all") { | ||
this._addSnapshot(key, receivedSerialized, { | ||
error, | ||
isInline, | ||
stack, | ||
rawSnapshot | ||
@@ -1589,4 +1597,3 @@ }); | ||
this._addSnapshot(key, receivedSerialized, { | ||
error, | ||
isInline, | ||
stack, | ||
rawSnapshot | ||
@@ -1593,0 +1600,0 @@ }); |
{ | ||
"name": "@vitest/snapshot", | ||
"type": "module", | ||
"version": "2.1.0-beta.5", | ||
"version": "2.1.0-beta.6", | ||
"description": "Vitest snapshot manager", | ||
@@ -43,3 +43,3 @@ "license": "MIT", | ||
"pathe": "^1.1.2", | ||
"@vitest/pretty-format": "2.1.0-beta.5" | ||
"@vitest/pretty-format": "2.1.0-beta.6" | ||
}, | ||
@@ -49,3 +49,3 @@ "devDependencies": { | ||
"natural-compare": "^1.4.0", | ||
"@vitest/utils": "2.1.0-beta.5" | ||
"@vitest/utils": "2.1.0-beta.6" | ||
}, | ||
@@ -52,0 +52,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71944
2083
+ Added@vitest/pretty-format@2.1.0-beta.6(transitive)
- Removed@vitest/pretty-format@2.1.0-beta.5(transitive)