|
| 1 | +import type { PlaywrightTestConfig } from '@playwright/test'; |
| 2 | +import { devices } from '@playwright/test'; |
| 3 | + |
| 4 | +// Fix urls not resolving to localhost on Node v17+ |
| 5 | +// See: https://github.com/axios/axios/issues/3821#issuecomment-1413727575 |
| 6 | +import { setDefaultResultOrder } from 'dns'; |
| 7 | +setDefaultResultOrder('ipv4first'); |
| 8 | + |
| 9 | +const eventProxyPort = 3031; |
| 10 | +const expressPort = 3030; |
| 11 | + |
| 12 | +/** |
| 13 | + * See https://playwright.dev/docs/test-configuration. |
| 14 | + */ |
| 15 | +const config: PlaywrightTestConfig = { |
| 16 | + testDir: './tests', |
| 17 | + /* Maximum time one test can run for. */ |
| 18 | + timeout: 150_000, |
| 19 | + expect: { |
| 20 | + /** |
| 21 | + * Maximum time expect() should wait for the condition to be met. |
| 22 | + * For example in `await expect(locator).toHaveText();` |
| 23 | + */ |
| 24 | + timeout: 5000, |
| 25 | + }, |
| 26 | + /* Run tests in files in parallel */ |
| 27 | + fullyParallel: true, |
| 28 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 29 | + forbidOnly: !!process.env.CI, |
| 30 | + /* Retry on CI only */ |
| 31 | + retries: 0, |
| 32 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 33 | + reporter: 'list', |
| 34 | + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 35 | + use: { |
| 36 | + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ |
| 37 | + actionTimeout: 0, |
| 38 | + |
| 39 | + /* Base URL to use in actions like `await page.goto('/')`. */ |
| 40 | + baseURL: `http://localhost:${expressPort}`, |
| 41 | + }, |
| 42 | + |
| 43 | + /* Configure projects for major browsers */ |
| 44 | + projects: [ |
| 45 | + { |
| 46 | + name: 'chromium', |
| 47 | + use: { |
| 48 | + ...devices['Desktop Chrome'], |
| 49 | + }, |
| 50 | + }, |
| 51 | + ], |
| 52 | + |
| 53 | + /* Run your local dev server before starting the tests */ |
| 54 | + webServer: [ |
| 55 | + { |
| 56 | + command: 'node start-event-proxy.mjs', |
| 57 | + port: eventProxyPort, |
| 58 | + stdout: 'pipe', |
| 59 | + stderr: 'pipe', |
| 60 | + }, |
| 61 | + { |
| 62 | + command: 'pnpm start', |
| 63 | + port: expressPort, |
| 64 | + stdout: 'pipe', |
| 65 | + stderr: 'pipe', |
| 66 | + }, |
| 67 | + ], |
| 68 | +}; |
| 69 | + |
| 70 | +export default config; |
0 commit comments