Skip to content

Commit a2f897d

Browse files
authored
test(wtr): add option to only run in one browser (#5685)
sometimes you just want to be quick about it
1 parent 9c58848 commit a2f897d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/@lwc/integration-wtr/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ To run individual test files, provide them as CLI arguments. If using relative p
1212

1313
Environment variables are used as controls to run tests in different modes (e.g native vs synthetic shadow, different API versions). The full list of controls is defined in [`helpers/options.js`](./helpers/options.js).
1414

15+
To run tests only for a specific browser, set the `BROWSERS` environment variable. For example, `BROWSERS=chromium yarn test:wtr`.
16+
1517
## Architecture
1618

1719
- `configs`: WTR configuration files. The main entrypoints are `integration.js` and `hydration.js`.

packages/@lwc/integration-wtr/configs/shared/browsers.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ export function getBrowsers(options) {
4545
}),
4646
];
4747
} else {
48-
return [
49-
playwrightLauncher({ product: 'chromium' }),
50-
playwrightLauncher({ product: 'firefox' }),
51-
playwrightLauncher({ product: 'webkit' }),
52-
];
48+
const browsers = options.BROWSERS?.split(',') ?? ['chromium', 'firefox', 'webkit'];
49+
return browsers.map((product) => playwrightLauncher({ product }));
5350
}
5451
}

packages/@lwc/integration-wtr/helpers/options.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ export const COVERAGE_DIR_FOR_OPTIONS =
7575
.map(([key, val]) => `${key}=${val}`)
7676
.join('/') || 'no-options';
7777

78+
/**
79+
* Comma-delimited list of browsers to use. Can be any of `chromium`, `firefox`, or `webkit`.
80+
* Does not apply when using SauceLabs.
81+
*/
82+
export const BROWSERS = process.env.BROWSERS?.replace(/\W+/g, ',');
83+
7884
// --- CI config --- //
7985

8086
/** Whether or not to report coverage. Currently unused. */

0 commit comments

Comments
 (0)