Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EvgenyOrekhov/3096ed8973c3f1e663733b1660222622 to your computer and use it in GitHub Desktop.
Save EvgenyOrekhov/3096ed8973c3f1e663733b1660222622 to your computer and use it in GitHub Desktop.
Playwright - separate tests for mobile and desktop

<name>.mobile.spec.ts files will run only on mobile browsers.

<name>.desktop.spec.ts files will run only on desktop browsers.

import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
// ...
projects: [
/* Desktop */
{
name: 'Desktop Chrome',
testIgnore: '**/*/*.mobile.spec.ts',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'Desktop Firefox',
testIgnore: '**/*/*.mobile.spec.ts',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'Desktop Safari',
testIgnore: '**/*/*.mobile.spec.ts',
use: { ...devices['Desktop Safari'] },
},
/* Mobile */
{
name: 'Mobile Chrome',
testIgnore: '**/*/*.desktop.spec.ts',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
testIgnore: '**/*/*.desktop.spec.ts',
use: { ...devices['iPhone 13 Pro Max'] },
},
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment