Add an option to allow customizing the Playwright browser channel
Signed-off-by: Maximilian Hagelstam <maximilian.hagelstam@gmail.com>
This commit is contained in:
@@ -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' }),
|
||||
});
|
||||
```
|
||||
@@ -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)
|
||||
```
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user