From f93f68056a10e7c9cd6ecd781ce80001af51a550 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 2 Jul 2026 12:18:14 +0100 Subject: [PATCH] Improve accessibility of playwright fixture documentation (#34087) * Improve accessibility of playwright fixture documentation Empirically. by pulling the type definitions for the playwright fixtures out to a type alias, we get better documentation for those fixtures. * Exclude playwright-common from coverage checks --- packages/playwright-common/src/fixtures/axe.ts | 10 ++++++---- packages/playwright-common/src/fixtures/panel.ts | 6 ++++-- packages/playwright-common/src/fixtures/user.ts | 6 ++++-- packages/playwright-common/src/index.ts | 10 ---------- vitest.config.ts | 2 ++ 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/playwright-common/src/fixtures/axe.ts b/packages/playwright-common/src/fixtures/axe.ts index 6f99b489c0..c2f5c50875 100644 --- a/packages/playwright-common/src/fixtures/axe.ts +++ b/packages/playwright-common/src/fixtures/axe.ts @@ -9,14 +9,16 @@ Please see LICENSE files in the repository root for full details. import { test as base } from "@playwright/test"; import { AxeBuilder } from "@axe-core/playwright"; -// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we -// explicitly avoid pulling anything more than playwright's base fixtures in. -export const test = base.extend<{ +export type TestFixtures = { /** * AxeBuilder instance for the current page */ axe: AxeBuilder; -}>({ +}; + +// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we +// explicitly avoid pulling anything more than playwright's base fixtures in. +export const test = base.extend({ axe: async ({ page }, use) => { const builder = new AxeBuilder({ page }); await use(builder); diff --git a/packages/playwright-common/src/fixtures/panel.ts b/packages/playwright-common/src/fixtures/panel.ts index 4d6c098b86..9bd8dda75c 100644 --- a/packages/playwright-common/src/fixtures/panel.ts +++ b/packages/playwright-common/src/fixtures/panel.ts @@ -14,7 +14,7 @@ import { test as base } from "./services.js"; */ const LEFT_PANEL_WIDTH = "368.6875px"; -export const test = base.extend<{ +export type TestFixtures = { /** * Whether the left panel should have its width fixed. * This is done because the library that we use for rendering collapsible @@ -25,7 +25,9 @@ export const test = base.extend<{ * behaviour. */ lockLeftPanelWidth: boolean; -}>({ +}; + +export const test = base.extend({ lockLeftPanelWidth: true, page: async ({ lockLeftPanelWidth, page }, use) => { const listener = async (page: Page) => { diff --git a/packages/playwright-common/src/fixtures/user.ts b/packages/playwright-common/src/fixtures/user.ts index 900dca1a23..03a4b55845 100644 --- a/packages/playwright-common/src/fixtures/user.ts +++ b/packages/playwright-common/src/fixtures/user.ts @@ -41,7 +41,7 @@ export async function populateLocalStorageWithCredentials(page: Page, credential ); } -export const test = base.extend<{ +export interface TestFixtures { /** * The displayname to use for the user registered in {@link #credentials}. * @@ -71,7 +71,9 @@ export const test = base.extend<{ * app. */ user: Credentials; -}>({ +} + +export const test = base.extend({ displayName: undefined, // We don't directly depend upon the `context` fixture, but we do need to make sure that it has been run diff --git a/packages/playwright-common/src/index.ts b/packages/playwright-common/src/index.ts index be96d53f0b..abbee03316 100644 --- a/packages/playwright-common/src/index.ts +++ b/packages/playwright-common/src/index.ts @@ -68,16 +68,6 @@ export interface TestFixtures { labsFlags: string[]; disablePresence: boolean; - /** - * Whether the left panel should have its width fixed. - * This is done because the library that we use for rendering collapsible - * panels uses math to calculate the width which can sometimes leads to +/-1px - * difference. While this does not matter to the user, it can lead to screenshot - * tests failing. - * Defaults to true, should be set to false via {@link base.use} when you want to test the collapse - * behaviour. - */ - lockLeftPanelWidth: boolean; } export const test = base.extend({ diff --git a/vitest.config.ts b/vitest.config.ts index 804a7ab368..b93610dfac 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -60,6 +60,8 @@ export default defineConfig({ "**/src/test/**", // Exclude type definition files "**/*.d.ts", + // Exclude playwright-common as it is just test utilities + "packages/playwright-common/**", ], reporter: [["lcov"]], },