log when oxc or scramjet internal error happens in test suite

This commit is contained in:
wearrrrr 2024-10-21 22:55:44 -05:00
parent 98b5387a84
commit e1a71bef1d
4 changed files with 25 additions and 2 deletions

View file

@ -7,7 +7,7 @@ export default defineConfig({
testDir: "./tests",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: 0,
retries: 2,
reporter: "html",
timeout: 20000,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */

View file

@ -328,7 +328,7 @@ export class ScramjetClient {
if ((err.stack as any) instanceof Object) {
//@ts-expect-error i'm not going to explain this
err.stack = err.stack.stack;
console.error("ERROR FROM SCRMAJET INTERNALS", err);
console.error("ERROR FROM SCRAMJET INTERNALS", err);
} else {
throw err;
}

View file

@ -0,0 +1,17 @@
import { Page } from "@playwright/test";
export function registerInspect(page: Page) {
let hasOxcError = false;
let hasScramjetError = false;
page.on("console", async (msg) => {
if (msg.type() === "error") {
if (msg.text().includes("oxc parse error") && !hasOxcError) {
hasOxcError = true;
console.log("OXC parse error detected! Please review manually.")
} else if (msg.text().includes("ERROR FROM SCRAMJET INTERNALS") && !hasScramjetError) {
hasScramjetError = true;
console.log("Scramjet error detected! Please review manually.");
}
}
});
}

View file

@ -1,8 +1,11 @@
/* eslint-disable no-async-promise-executor */
import { expect, FrameLocator, Page } from "@playwright/test";
import { registerInspect } from "./inspectConsole";
export function setupPage(page: Page, url: string): Promise<FrameLocator> {
return new Promise(async (resolve) => {
// Hack to disable HTTP cache.
await page.route("**", route => route.continue());
// Goto base url defined in config.
await page.goto("/");
await page.waitForSelector(".version > b");
@ -18,6 +21,9 @@ export function setupPage(page: Page, url: string): Promise<FrameLocator> {
await page.waitForTimeout(1000);
await bar.press("Enter");
registerInspect(page);
resolve(frame);
});
}