mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
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
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user