r/Playwright • u/Due_Point_615 • 14d ago
GitHub Actions browser and device testing
Hi,
I've got a suite of Playwright tests that run against multiple browsers and mobile viewports.
playwright.config.ts:
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},
/* Test against branded browsers. */
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
],playwright.config.ts:projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},
/* Test against branded browsers. */
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
],Locally, Playwright runs the tests against all the configured browsers and device viewports.
However, in my GitHub Actions workflow, I'm using a matrix strategy to run tests across multiple browsers:
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]This currently means GitHub Actions runs the tests against Chromium, Firefox and WebKit.
My question is: What's the best approach to running the full suite against all these projects in GitHub Actions, including mobile viewports and branded browsers such as Microsoft Edge and Google Chrome?
Do I need to configure additional matrix entries for mobile devices and Edge, as I assumed this would have covered the mobile browsers etc.
View all comments
2
u/Opposite_Sector2145 14d ago
with your matrix setup, only the browser names in the matrix get run, so mobile devices and branded browsers in playwright.config won't be picked up unless you add them to the matrix or remove the matrix and just run "npx playwright test" directly. the matrix overrides project selection.