From b96c20e04623fec011a4d7f55f58c62dcf07e340 Mon Sep 17 00:00:00 2001 From: Maximilian Hagelstam Date: Mon, 19 Jan 2026 12:55:16 +0200 Subject: [PATCH] Add an option to allow customizing the Playwright browser channel Signed-off-by: Maximilian Hagelstam --- .changeset/custom-playwright-channel.md | 15 +++++++++++++++ packages/e2e-test-utils/report-playwright.api.md | 4 +++- .../src/playwright/generateProjects.ts | 10 ++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 .changeset/custom-playwright-channel.md diff --git a/.changeset/custom-playwright-channel.md b/.changeset/custom-playwright-channel.md new file mode 100644 index 0000000000..94adf89c0e --- /dev/null +++ b/.changeset/custom-playwright-channel.md @@ -0,0 +1,15 @@ +--- +'@backstage/e2e-test-utils': patch +--- + +Added optional `channel` option to `generateProjects()` to allow customizing the Playwright browser channel for testing against different browsers variants. When not provided, the function defaults to 'chrome' to maintain backward compatibility. + +Example usage: + +```ts +import { generateProjects } from '@backstage/e2e-test-utils'; + +export default defineConfig({ + projects: generateProjects({ channel: 'msedge' }), +}); +``` diff --git a/packages/e2e-test-utils/report-playwright.api.md b/packages/e2e-test-utils/report-playwright.api.md index 7153f2e578..f286c84f4d 100644 --- a/packages/e2e-test-utils/report-playwright.api.md +++ b/packages/e2e-test-utils/report-playwright.api.md @@ -9,7 +9,9 @@ import { PlaywrightTestConfig } from '@playwright/test'; export function failOnBrowserErrors(): void; // @public -export function generateProjects(): PlaywrightTestConfig['projects']; +export function generateProjects(options?: { + channel?: string; +}): PlaywrightTestConfig['projects']; // (No @packageDocumentation comment for this package) ``` diff --git a/packages/e2e-test-utils/src/playwright/generateProjects.ts b/packages/e2e-test-utils/src/playwright/generateProjects.ts index b6f3d159c5..1919d8305a 100644 --- a/packages/e2e-test-utils/src/playwright/generateProjects.ts +++ b/packages/e2e-test-utils/src/playwright/generateProjects.ts @@ -24,8 +24,14 @@ import type { BackstagePackage } from '@backstage/cli-node'; * Generates a list of playwright projects by scanning the monorepo for packages with an `e2e-tests/` folder. * * @public + * + * @param options - Optional configuration for the generated Playwright projects. + * When provided, `options.channel` controls the browser channel used for tests. + * Valid values are listed in the [Playwright documentation](https://playwright.dev/docs/api/class-testoptions#test-options-channel). */ -export function generateProjects(): PlaywrightTestConfig['projects'] { +export function generateProjects(options?: { + channel?: string; +}): PlaywrightTestConfig['projects'] { // TODO(Rugvip): Switch this over to use @backstage/cli-node once released, and support SINCE=origin/main const { root, packages } = getPackagesSync(process.cwd()); const e2eTestPackages = [...(root ? [root] : []), ...packages].filter(pkg => { @@ -36,7 +42,7 @@ export function generateProjects(): PlaywrightTestConfig['projects'] { name: pkg.packageJson.name, testDir: resolvePath(pkg.dir, 'e2e-tests'), use: { - channel: 'chrome', + channel: options?.channel ?? 'chrome', }, })); }