How can I launch Chrome or Firefox according to the current project in global-setup.ts
?
see the code about projects in my playwright.config.ts
projects: [
{
name: 'chromium',
use: {
browserName: 'chromium'
},
timeout: 400 * 1000
},
{
name: 'firefox',
use: {
browserName: 'firefox'
},
timeout: 400 * 1000
}
]
in my global-setup.ts
, I want to launch Firefox to login when I run the test using npx playwright test --project=firefox
, and launch Chrome instead when the tests are run with npx playwright test --project=chromium
.
I tried to set up an environment variable before starting test, something like set BROWSER=firefox
, and check process.env.BROWSER
to launch different browser in global-setup.ts
, it works, but I guess Playwright could have built-in feature to support such case without defining extra environment variable.
1