From 4c928d28543b18eec14334e217fc24df8b598065 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 27 Nov 2025 17:13:22 +0000 Subject: [PATCH] Avoid `mergeTests` in test fixture declarations (#138) Normally, one can find the documentation on a playwright test fixture by finding its declaration (i.e., you can ctrl-click on the fixture name and find its documentaion). However, `mergeTests` re-declares the type, making it much harder to find the documentation on a given fixture. It's easy enough to avoid `mergeTests`: we just structure our `test.extend` calls as a strict hieirarchy. --- .../element-web-playwright-common/src/fixtures/axe.ts | 5 ++++- .../element-web-playwright-common/src/fixtures/index.ts | 9 +++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/element-web-playwright-common/src/fixtures/axe.ts b/packages/element-web-playwright-common/src/fixtures/axe.ts index eeeb523aed..2c0c97af45 100644 --- a/packages/element-web-playwright-common/src/fixtures/axe.ts +++ b/packages/element-web-playwright-common/src/fixtures/axe.ts @@ -6,9 +6,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ -import { test as base } from "@playwright/test"; import AxeBuilder from "@axe-core/playwright"; +import { test as base } from "./user"; + +// We want to avoid using `mergeTests` because it drops useful type information about the fixtures. Instead, we extend +// the definition of `test` from `user.ts`, so that there is a linear hierarchy. export const test = base.extend<{ /** * AxeBuilder instance for the current page diff --git a/packages/element-web-playwright-common/src/fixtures/index.ts b/packages/element-web-playwright-common/src/fixtures/index.ts index 04c8d120e3..58aebfa20e 100644 --- a/packages/element-web-playwright-common/src/fixtures/index.ts +++ b/packages/element-web-playwright-common/src/fixtures/index.ts @@ -5,11 +5,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ -import { mergeTests } from "@playwright/test"; - -import { test as axe } from "./axe.js"; -import { test as user } from "./user.js"; - export { type Services, type WorkerOptions } from "./services.js"; -export const test = mergeTests(axe, user); +// We avoid using `mergeTests` because it drops useful type information about the fixtures. +// `axe` is the top of our stack of extensions (it extends `user`, etc), so it's the one we want to use. +export { test } from "./axe";