| 1 |
const { defineConfig, devices } = require('@playwright/test'); |
| 2 |
|
| 3 |
/** |
| 4 |
* @see https://playwright.dev/docs/test-configuration |
| 5 |
*/ |
| 6 |
module.exports = defineConfig({ |
| 7 |
testDir: './tests/playwright', |
| 8 |
/* Run tests in files in parallel */ |
| 9 |
fullyParallel: true, |
| 10 |
/* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 11 |
forbidOnly: !!process.env.CI, |
| 12 |
/* Retry on CI only */ |
| 13 |
retries: process.env.CI ? 2 : 0, |
| 14 |
/* Single worker on CI — tests share one WordPress instance so parallel |
| 15 |
execution causes session/state interference (e.g., logout kills other sessions). */ |
| 16 |
workers: process.env.CI ? 1 : undefined, |
| 17 |
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 18 |
reporter: process.env.CI ? 'github' : 'list', |
| 19 |
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 20 |
use: { |
| 21 |
/* Base URL to use in actions like `await page.goto('/')`. */ |
| 22 |
baseURL: process.env.WP_BASE_URL || 'http://localhost:2623', |
| 23 |
|
| 24 |
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
| 25 |
trace: 'on-first-retry', |
| 26 |
|
| 27 |
/* Screenshot on failure */ |
| 28 |
screenshot: 'only-on-failure', |
| 29 |
|
| 30 |
/* Video on retry */ |
| 31 |
video: 'retain-on-failure', |
| 32 |
}, |
| 33 |
|
| 34 |
/* Configure projects for major browsers */ |
| 35 |
projects: [ |
| 36 |
/* Auth setup — runs first, saves login state for other projects */ |
| 37 |
{ |
| 38 |
name: 'setup', |
| 39 |
testMatch: /auth\.setup\.js/, |
| 40 |
}, |
| 41 |
|
| 42 |
{ |
| 43 |
name: 'chromium', |
| 44 |
use: { |
| 45 |
...devices['Desktop Chrome'], |
| 46 |
storageState: 'tests/playwright/.auth/user.json', |
| 47 |
}, |
| 48 |
dependencies: ['setup'], |
| 49 |
testIgnore: /auth\.setup\.js/, |
| 50 |
}, |
| 51 |
|
| 52 |
{ |
| 53 |
name: 'firefox', |
| 54 |
use: { |
| 55 |
...devices['Desktop Firefox'], |
| 56 |
storageState: 'tests/playwright/.auth/user.json', |
| 57 |
}, |
| 58 |
dependencies: ['setup'], |
| 59 |
testIgnore: /auth\.setup\.js/, |
| 60 |
}, |
| 61 |
|
| 62 |
{ |
| 63 |
name: 'webkit', |
| 64 |
use: { |
| 65 |
...devices['Desktop Safari'], |
| 66 |
storageState: 'tests/playwright/.auth/user.json', |
| 67 |
}, |
| 68 |
dependencies: ['setup'], |
| 69 |
testIgnore: /auth\.setup\.js/, |
| 70 |
}, |
| 71 |
], |
| 72 |
|
| 73 |
/* Run your local dev server before starting the tests */ |
| 74 |
webServer: process.env.SKIP_WP_SERVER ? undefined : { |
| 75 |
command: 'npm run env:tests:start', |
| 76 |
url: process.env.WP_BASE_URL || 'http://localhost:2623', |
| 77 |
reuseExistingServer: !process.env.CI, |
| 78 |
timeout: 180 * 1000, |
| 79 |
stdout: 'pipe', |
| 80 |
stderr: 'pipe', |
| 81 |
}, |
| 82 |
|
| 83 |
/* Global setup and teardown */ |
| 84 |
globalSetup: './tests/playwright/global-setup.js', |
| 85 |
globalTeardown: './tests/playwright/global-teardown.js', |
| 86 |
}); |
| 87 |
|