mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
test(studio): a test chrome launch that fails with a non-error names what it holds (#8305)
This commit is contained in:
@@ -60,6 +60,19 @@ describe("launchTestChrome", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("names a launch failure that is not an Error by what it holds", async () => {
|
||||
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
vi.spyOn(console, "info").mockImplementation(() => {});
|
||||
try {
|
||||
// Puppeteer rejects a dropped DevTools socket with an event that holds the Error.
|
||||
const dropped = { error: new Error("read ECONNRESET") };
|
||||
await expect(launchTestChrome(vi.fn().mockRejectedValue(dropped))).rejects.toBe(dropped);
|
||||
expect(String(error.mock.calls[0]?.[0])).toContain("read ECONNRESET");
|
||||
} finally {
|
||||
vi.restoreAllMocks();
|
||||
}
|
||||
});
|
||||
|
||||
it("stops after the second stuck launch and preserves its error", async () => {
|
||||
const failure = new TimeoutError("still stuck");
|
||||
const launch = vi.fn().mockRejectedValue(failure);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { inspect } from "node:util";
|
||||
import puppeteer, { TimeoutError, type Browser, type Page } from "puppeteer-core";
|
||||
import { browserVersion, findSystemChrome } from "../vite.browser";
|
||||
|
||||
@@ -38,7 +39,8 @@ export async function launchTestChrome(
|
||||
return browser;
|
||||
} catch (error) {
|
||||
const elapsed = Date.now() - startedAt;
|
||||
const reason = error instanceof Error ? error.message : String(error);
|
||||
const reason =
|
||||
error instanceof Error ? error.message : inspect(error, { breakLength: Infinity });
|
||||
console.error(
|
||||
`[studio-test-chrome] launch ${attempt}/${LAUNCH_ATTEMPTS} failed after ${elapsed} ms: ${reason}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user