|
| 1 | +import { defineConfig, devices } from '@playwright/test' |
| 2 | + |
| 3 | +/** |
| 4 | + * Read environment variables from file. |
| 5 | + * https://github.com/motdotla/dotenv |
| 6 | + */ |
| 7 | +// require('dotenv').config(); |
| 8 | + |
| 9 | +/** |
| 10 | + * See https://playwright.dev/docs/test-configuration. |
| 11 | + */ |
| 12 | +export default defineConfig({ |
| 13 | + testDir: './test/e2e', |
| 14 | + /* Run tests in files in parallel */ |
| 15 | + fullyParallel: true, |
| 16 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 17 | + forbidOnly: !!process.env.CI, |
| 18 | + /* Retry on CI only */ |
| 19 | + retries: process.env.CI ? 2 : 0, |
| 20 | + /* Opt out of parallel tests on CI. */ |
| 21 | + workers: process.env.CI ? 1 : undefined, |
| 22 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 23 | + reporter: 'html', |
| 24 | + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 25 | + use: { |
| 26 | + /* Base URL to use in actions like `await page.goto('/')`. */ |
| 27 | + baseURL: process.env.BASE_URL || 'http://localhost:5173', |
| 28 | + |
| 29 | + testIdAttribute: 'data-test-id', |
| 30 | + |
| 31 | + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
| 32 | + trace: 'on-first-retry', |
| 33 | + video: 'retain-on-failure', |
| 34 | + }, |
| 35 | + |
| 36 | + /* Configure projects for major browsers */ |
| 37 | + projects: [ |
| 38 | + { |
| 39 | + name: 'chromium', |
| 40 | + use: { ...devices['Desktop Chrome'] }, |
| 41 | + }, |
| 42 | + |
| 43 | + { |
| 44 | + name: 'firefox', |
| 45 | + use: { ...devices['Desktop Firefox'] }, |
| 46 | + }, |
| 47 | + |
| 48 | + { |
| 49 | + name: 'webkit', |
| 50 | + use: { ...devices['Desktop Safari'] }, |
| 51 | + }, |
| 52 | + |
| 53 | + /* Test against mobile viewports. */ |
| 54 | + // { |
| 55 | + // name: 'Mobile Chrome', |
| 56 | + // use: { ...devices['Pixel 5'] }, |
| 57 | + // }, |
| 58 | + // { |
| 59 | + // name: 'Mobile Safari', |
| 60 | + // use: { ...devices['iPhone 12'] }, |
| 61 | + // }, |
| 62 | + |
| 63 | + /* Test against branded browsers. */ |
| 64 | + // { |
| 65 | + // name: 'Microsoft Edge', |
| 66 | + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, |
| 67 | + // }, |
| 68 | + // { |
| 69 | + // name: 'Google Chrome', |
| 70 | + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, |
| 71 | + // }, |
| 72 | + ], |
| 73 | + |
| 74 | + /* Run your local dev server before starting the tests */ |
| 75 | + webServer: { |
| 76 | + command: 'pnpm dev', |
| 77 | + url: 'http://localhost:5173', |
| 78 | + reuseExistingServer: !process.env.CI, |
| 79 | + }, |
| 80 | +}) |
0 commit comments