From 48e262d8f1ff9f395ef3d8052fbecccdfe7e1b8b Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 16 Jan 2026 12:05:41 +0100 Subject: [PATCH] Avoid starting a homeserver when using just the axe fixture Since 4c928d28543b18eec14334e217fc24df8b598065 importing the axe fixture would cause your test to pull in the entire world of Synapse and Postgres services. For Compound Web tests, we want to be able to use axe in isolation without all the extra fixtures. Inverting the fixture hierarchy ought to do the trick. --- packages/element-web-playwright-common/src/fixtures/axe.ts | 7 +++---- .../element-web-playwright-common/src/fixtures/index.ts | 4 ++-- .../element-web-playwright-common/src/fixtures/services.ts | 4 +++- 3 files changed, 8 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 b7c03763cc..f438b56d1f 100644 --- a/packages/element-web-playwright-common/src/fixtures/axe.ts +++ b/packages/element-web-playwright-common/src/fixtures/axe.ts @@ -6,12 +6,11 @@ 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.js"; - -// 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. +// 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<{ /** * 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 de7bce2f29..04dfb50189 100644 --- a/packages/element-web-playwright-common/src/fixtures/index.ts +++ b/packages/element-web-playwright-common/src/fixtures/index.ts @@ -8,5 +8,5 @@ Please see LICENSE files in the repository root for full details. export { type Services, type WorkerOptions } from "./services.js"; // 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.js"; +// `user` is the top of our stack of extensions (it extends services, axe, etc), so it includes everything. +export { test } from "./user.js"; diff --git a/packages/element-web-playwright-common/src/fixtures/services.ts b/packages/element-web-playwright-common/src/fixtures/services.ts index 2c91bae1a0..d4256c6213 100644 --- a/packages/element-web-playwright-common/src/fixtures/services.ts +++ b/packages/element-web-playwright-common/src/fixtures/services.ts @@ -5,7 +5,6 @@ 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 { type MailpitClient } from "mailpit-api"; import { Network, type StartedNetwork } from "testcontainers"; import { PostgreSqlContainer, type StartedPostgreSqlContainer } from "@testcontainers/postgresql"; @@ -20,6 +19,9 @@ import { type StartedMailpitContainer, } from "../testcontainers/index.js"; import { Logger } from "../utils/logger.js"; +// We want to avoid using `mergeTests` in index.ts because it drops useful type information about the fixtures. Instead, +// we add `axe` into our fixture suite by using its `test` as a base, so that there is a linear hierarchy. +import { test as base } from "./axe.js"; /** * Test-scoped fixtures available in the test