I have a test config file (playwright.config.ts) with many projects.
Usually, I want to test several different browsers.
However, when I'm building a test, I want to only test with a single browser/project (because the test is going to fail while I'm working on it).
I tried this command:
npx playwright test test.ts --browser='chromium'
But I get an error:
Error: Cannot use --browser option when configuration file defines projects. Specify browserName in the projects instead.
How do I "specify browserName in the projects" to limit the tests to running on one browser?
My config file:
const config: PlaywrightTestConfig = {
projects: [
{
name: 'Chrome Stable',
use: {
browserName: 'chromium',
channel: 'chrome',
},
},
{
name: 'Safari MacBook Air',
use: {
browserName: 'webkit',
viewport: {
width: 2560,
height: 1620,
},
},
},
{
name: 'Firefox Desktop',
use: {
browserName: 'firefox',
viewport: {
width: 1920,
height: 1080,
},
},
},
{
name: 'iPhone 6/7/8',
use: devices['iPhone 8'],
},
{
name: 'iPhone 6/7/8 Plus',
use: devices['iPhone 8 Plus'],
},
{
name: 'iPhone 12',
use: devices['iPhone 12'],
},
{
name: 'iPhone 12 Pro',
use: devices['iPhone 12 Pro'],
},
{
name: 'iPhone 12 Pro Max',
use: devices['iPhone 12 Pro Max'],
},
{
name: 'iPhone 5/SE',
use: devices['iPhone SE'],
},
{
name: 'iPad',
use: devices['iPad (gen 7)'],
},
{
name: 'iPad landscape',
use: devices['iPad (gen 7) landscape'],
},
{
name: 'iPad Mini',
use: devices['iPad Mini'],
},
{
name: 'iPad Mini landscape',
use: devices['iPad Mini landscape'],
},
{
name: 'iPad Pro 11',
use: devices['iPad Pro 11'],
},
{
name: 'iPad Pro 11 landscape',
use: devices['iPad Pro 11 landscape'],
},
$ npx playwright test -p chromium
giveserror: unknown option '-p'
in"@playwright/test": "^1.43.1"
. – Balaam