From 27e16becb1e9888a83df0b664a4fcdb932ce4c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Fri, 30 Oct 2026 05:45:03 +0000 Subject: [PATCH] test(cli): a failed late-image snapshot reports why it failed (#6793) * test(cli): a failed late-image snapshot reports why * test(cli): the late-image failure message includes the JSON the command printed --- .../snapshot.lateImages.browser.test.ts | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/packages/cli/src/commands/snapshot.lateImages.browser.test.ts b/packages/cli/src/commands/snapshot.lateImages.browser.test.ts index 3f85548978..ad52605313 100644 --- a/packages/cli/src/commands/snapshot.lateImages.browser.test.ts +++ b/packages/cli/src/commands/snapshot.lateImages.browser.test.ts @@ -69,20 +69,28 @@ function writeProject(name: string, reveal: string): string { async function snapshotAt(dir: string, time: string) { const output = join(dir, "out"); const log = vi.spyOn(console, "log").mockImplementation(() => undefined); - vi.spyOn(console, "error").mockImplementation(() => undefined); - vi.spyOn(console, "warn").mockImplementation(() => undefined); + const said: string[] = []; + const keep = (...parts: unknown[]) => void said.push(parts.map(String).join(" ")); + vi.spyOn(console, "error").mockImplementation(keep); + vi.spyOn(console, "warn").mockImplementation(keep); try { - await snapshotCommand.run?.({ - args: { - dir, - at: time, - end: false, - json: true, - output, - describe: "false", - "browser-gpu": false, - }, - } as never); + try { + await snapshotCommand.run?.({ + args: { + dir, + at: time, + end: false, + json: true, + output, + describe: "false", + "browser-gpu": false, + }, + } as never); + } catch (error) { + throw new Error(`snapshot failed: ${[...said, ...log.mock.calls.flat()].join(" | ")}`, { + cause: error, + }); + } const envelope = JSON.parse(String(log.mock.calls.at(-1)?.[0])); return { envelope, output }; } finally {