e2e-tests: Fix stack traces from Puppeteer page errors.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-16 14:16:44 -07:00 committed by Anders Kaseorg
parent 8ebcaddfd9
commit ccb492a75a
1 changed files with 2 additions and 6 deletions

View File

@ -650,14 +650,10 @@ export async function run_test_async(test_function: (page: Page) => Promise<void
page.on("pageerror", (error: Error) => {
page_errored = true;
// Puppeteer gives us the stack as the message for some reason.
const error1 = new Error("dummy");
error1.stack = error.message;
const console_ready1 = console_ready;
console_ready = (async () => {
const frames = await Promise.all(
ErrorStackParser.parse(error1).map(async (frame1) => {
ErrorStackParser.parse(error).map(async (frame1) => {
let frame = frame1 as unknown as StackFrame;
try {
frame = await gps.getMappedLocation(frame);
@ -670,7 +666,7 @@ export async function run_test_async(test_function: (page: Page) => Promise<void
}),
);
await console_ready1;
console.error("Page error:", error.message.split("\n", 1)[0] + frames.join(""));
console.error("Page error:", error.message + frames.join(""));
})();
const console_ready2 = console_ready;