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.
This commit is contained in:
Richard van der Hoff 2025-11-27 17:13:22 +00:00 committed by GitHub
parent 1b11b3d1c0
commit 4c928d2854
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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";