···158158 // location for js files, but `column-1` points to the same in both js/ts
159159 // https://github.com/vitejs/vite/issues/8657
160160 stack.column--
161161+ // reject multiple inline snapshots at the same location
162162+ const duplicateIndex = this._inlineSnapshots.findIndex(s => s.file === stack.file && s.line === stack.line && s.column === stack.column)
163163+ if (duplicateIndex >= 0) {
164164+ // remove the first one to avoid updating an inline snapshot
165165+ this._inlineSnapshots.splice(duplicateIndex, 1)
166166+ throw new Error('toMatchInlineSnapshot cannot be called multiple times at the same location.')
167167+ }
161168 this._inlineSnapshots.push({
162169 snapshot: receivedSerialized,
163170 ...stack,
···11+import {test, expect} from "vitest";
22+33+// this test causes infinite re-run when --watch and --update
44+// since snapshot update switches between "foo" and "bar" forever.
55+test("fail 2", () => {
66+ for (const str of ["foo", "bar"]) {
77+ expect(str).toMatchInlineSnapshot(`"bar"`);
88+ }
99+});
+7
test/cli/test/__snapshots__/fails.test.ts.snap
···3131Error: InlineSnapshot cannot be used inside of test.each or describe.each"
3232`;
33333434+exports[`should fail inline-snapshop-inside-loop-update-all.test.ts > inline-snapshop-inside-loop-update-all.test.ts 1`] = `
3535+"Error: toMatchInlineSnapshot cannot be called multiple times at the same location.
3636+Error: toMatchInlineSnapshot cannot be called multiple times at the same location."
3737+`;
3838+3939+exports[`should fail inline-snapshop-inside-loop-update-none.test.ts > inline-snapshop-inside-loop-update-none.test.ts 1`] = `"Error: Snapshot \`fail 2 1\` mismatched"`;
4040+3441exports[`should fail mock-import-proxy-module.test.ts > mock-import-proxy-module.test.ts 1`] = `"Error: There are some problems in resolving the mocks API."`;
35423643exports[`should fail nested-suite.test.ts > nested-suite.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`;