What’s the best practice to 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 to login and do something when the tests are launched by npx playwright test --project=chromium
, what’s the best practice to do this?
I tried to set up environment variable before test, something like set BROWSER=firefox
, and check process.env.BROWSER
to launch different browser in global-setup.ts
, but I believe there should be a better solution.