|
| 1 | +import type { PlaywrightTestConfig } from "@playwright/test"; |
| 2 | +import { devices } from "@playwright/test"; |
| 3 | + |
| 4 | +/** |
| 5 | + * Read environment variables from file. |
| 6 | + * https://github.com/motdotla/dotenv |
| 7 | + */ |
| 8 | +// require('dotenv').config(); |
| 9 | + |
| 10 | +/** |
| 11 | + * See https://playwright.dev/docs/test-configuration. |
| 12 | + */ |
| 13 | +const config: PlaywrightTestConfig = { |
| 14 | + testDir: "./e2e", |
| 15 | + /* Maximum time one test can run for. */ |
| 16 | + timeout: 30 * 1000, |
| 17 | + expect: { |
| 18 | + /** |
| 19 | + * Maximum time expect() should wait for the condition to be met. |
| 20 | + * For example in `await expect(locator).toHaveText();` |
| 21 | + */ |
| 22 | + timeout: 5000, |
| 23 | + }, |
| 24 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 25 | + forbidOnly: !!process.env.CI, |
| 26 | + /* Retry on CI only */ |
| 27 | + retries: process.env.CI ? 2 : 0, |
| 28 | + /* Opt out of parallel tests on CI. */ |
| 29 | + workers: process.env.CI ? 1 : undefined, |
| 30 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 31 | + reporter: "html", |
| 32 | + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 33 | + use: { |
| 34 | + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ |
| 35 | + actionTimeout: 0, |
| 36 | + /* Base URL to use in actions like `await page.goto('/')`. */ |
| 37 | + baseURL: "http://localhost:5173", |
| 38 | + |
| 39 | + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
| 40 | + trace: "on-first-retry", |
| 41 | + |
| 42 | + /* Only on CI systems run the tests headless */ |
| 43 | + headless: !!process.env.CI, |
| 44 | + }, |
| 45 | + |
| 46 | + /* Configure projects for major browsers */ |
| 47 | + projects: [ |
| 48 | + { |
| 49 | + name: "chromium", |
| 50 | + use: { |
| 51 | + ...devices["Desktop Chrome"], |
| 52 | + }, |
| 53 | + }, |
| 54 | + { |
| 55 | + name: "firefox", |
| 56 | + use: { |
| 57 | + ...devices["Desktop Firefox"], |
| 58 | + }, |
| 59 | + }, |
| 60 | + { |
| 61 | + name: "webkit", |
| 62 | + use: { |
| 63 | + ...devices["Desktop Safari"], |
| 64 | + }, |
| 65 | + }, |
| 66 | + |
| 67 | + /* Test against mobile viewports. */ |
| 68 | + // { |
| 69 | + // name: 'Mobile Chrome', |
| 70 | + // use: { |
| 71 | + // ...devices['Pixel 5'], |
| 72 | + // }, |
| 73 | + // }, |
| 74 | + // { |
| 75 | + // name: 'Mobile Safari', |
| 76 | + // use: { |
| 77 | + // ...devices['iPhone 12'], |
| 78 | + // }, |
| 79 | + // }, |
| 80 | + |
| 81 | + /* Test against branded browsers. */ |
| 82 | + // { |
| 83 | + // name: 'Microsoft Edge', |
| 84 | + // use: { |
| 85 | + // channel: 'msedge', |
| 86 | + // }, |
| 87 | + // }, |
| 88 | + // { |
| 89 | + // name: 'Google Chrome', |
| 90 | + // use: { |
| 91 | + // channel: 'chrome', |
| 92 | + // }, |
| 93 | + // }, |
| 94 | + ], |
| 95 | + |
| 96 | + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ |
| 97 | + // outputDir: 'test-results/', |
| 98 | + |
| 99 | + /* Run your local dev server before starting the tests */ |
| 100 | + webServer: { |
| 101 | + /** |
| 102 | + * Use the dev server by default for faster feedback loop. |
| 103 | + * Use the preview server on CI for more realistic testing. |
| 104 | + Playwright will re-use the local server if there is already a dev-server running. |
| 105 | + */ |
| 106 | + command: process.env.CI ? "vite preview --port 5173" : "vite dev", |
| 107 | + port: 5173, |
| 108 | + reuseExistingServer: !process.env.CI, |
| 109 | + }, |
| 110 | +}; |
| 111 | + |
| 112 | +export default config; |
0 commit comments