From 65844e0dd81663211874a17e4f4f2d089e9c9023 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Fri, 9 Aug 2024 09:22:42 +0100 Subject: [PATCH] Ensure there are in-browser errors Refs ad53282373feda48d3c34d57783e26e51cbc75a7 --- integration/base.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/integration/base.ts b/integration/base.ts index 5e2c8b9..bfd6c3e 100644 --- a/integration/base.ts +++ b/integration/base.ts @@ -1,4 +1,10 @@ -import { type Fixtures, type PlaywrightTestArgs, type PlaywrightTestOptions, test as baseTest } from '@playwright/test' +import { + type Fixtures, + type PlaywrightTestArgs, + type PlaywrightTestOptions, + test as baseTest, + expect, +} from '@playwright/test' export { expect } from '@playwright/test' @@ -6,6 +12,17 @@ const appFixtures: Fixtures, Record, Playwrig baseURL: async ({}, use) => { await use('http://localhost:3000') }, + context: async ({ context }, use) => { + const errors: Array = [] + + context.on('weberror', error => { + errors.push(error.error().message) + }) + + await use(context) + + expect(errors).toHaveLength(0) + }, } export const test = baseTest.extend(appFixtures)