r/Playwright • u/Due_Point_615 • 8d 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.
2
u/Opposite_Sector2145 7d 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.
1
u/Status_Ad8999 7d ago
`Mobile Chrome` and `Mobile Safari` reuse the bundled `chromium` and `webkit` binaries, so you can pass `--project=chromium --project="Mobile Chrome"` in the same matrix job without extra downloads. Branded projects (`channel: 'chrome'` or `'msedge'`) need `npx playwright install --with-deps chrome msedge` explicitly in CI because default `playwright install` skips branded channels.
1
u/Alternative-Ruin275 21h ago
Check the workflow's run command first: a GitHub matrix creates jobs, but it doesn't automatically map browser engines to all seven Playwright projects.
The simplest option is one job running npx playwright test without --project; that runs every configured project. If you want separate jobs, make the matrix contain the exact project names, including “Mobile Chrome”, “Mobile Safari”, “Microsoft Edge” and “Google Chrome”, then pass the selected name as a quoted --project argument.
Install the engines and branded browser channels those projects need. Also, the Pixel/iPhone projects emulate devices; they don't run on physical phones. That distinction matters when deciding what coverage the CI result actually represents.
2
u/Brainy-Cos 7d ago
the chromium/firefox/webkit matrix only splits those three engines, it doesn't automatically run mobile device projects or edge. mobile in playwright is usually just chromium or webkit with a device descriptor (viewport, user agent, touch), so those won't show up in ci unless you actually select those projects.
if the workflow is passing --project from the matrix, define the devices and browsers as projects in playwright.config and matrix on the project names instead. the default config already has commented examples for mobile chrome, mobile safari and edge with channel: 'msedge'. so something like project: [chromium, firefox, webkit, "Mobile Chrome", "Mobile Safari"] and then npx playwright test --project="${{ matrix.project }}". or drop the filter and just run npx playwright test so every configured project runs in one job.
edge isn't part of the default install, it's a branded chromium channel, so add that project and install it on the runner with npx playwright install msedge. not really a fourth engine like firefox or webkit.