feat: add console error monitoring for Playwright tests; enhance page fixture with error assertions

This commit is contained in:
2026-03-08 15:36:50 +00:00
parent a9a13a6b5b
commit 0be4852f74
4 changed files with 129 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { test as base, expect, type Page } from "@playwright/test"
import { ensureTestUser, type TestUserCredentials } from "../api/helpers/test-user"
import { attachConsoleMonitor } from "../fixtures/console-monitor"
const API_BASE = "/api"
@@ -29,6 +30,8 @@ export const test = base.extend<E2eFixtures, E2eWorkerFixtures>({
* navigation methods to "domcontentloaded".
*/
page: async ({ page }, use) => {
const monitor = attachConsoleMonitor(page)
const origGoto = page.goto.bind(page)
const origReload = page.reload.bind(page)
const origGoBack = page.goBack.bind(page)
@@ -42,6 +45,7 @@ export const test = base.extend<E2eFixtures, E2eWorkerFixtures>({
origGoForward({ waitUntil: "domcontentloaded", ...opts })) as typeof page.goForward
await use(page)
monitor.assertNoErrors()
},
// Worker-scoped: create/reuse test user once per worker