|
| 1 | +/* |
| 2 | + * Copyright (C) con terra GmbH |
| 3 | + */ |
| 4 | +import { |
| 5 | + defineConfig, |
| 6 | + devices, |
| 7 | + PlaywrightTestConfig |
| 8 | +} from "@playwright/test"; |
| 9 | +import { env } from "process"; |
| 10 | + |
| 11 | +/** |
| 12 | + * See https://playwright.dev/docs/test-configuration. |
| 13 | + */ |
| 14 | +const baseURL = env.BASE_URL || "http://localhost:9090"; |
| 15 | +const testDir = env.TESTS_DIR || "./src/test/end-to-end/test"; |
| 16 | +const outputDir = env.TARGET_DIR || "./target/playwright/output"; |
| 17 | + |
| 18 | +const isCI = !!env.CI; |
| 19 | + |
| 20 | +const snapshotsFolder = env.SNAPSHOTS_DIR || "./src/test/end-to-end/test/snapshots/local"; |
| 21 | + |
| 22 | +const config: PlaywrightTestConfig = { |
| 23 | + testDir, |
| 24 | + outputDir: `${outputDir}/results`, |
| 25 | + |
| 26 | + snapshotPathTemplate: `${snapshotsFolder}/{testFileName}-snapshots/{arg}-{projectName}{ext}`, |
| 27 | + |
| 28 | + /* Run tests in files in parallel */ |
| 29 | + fullyParallel: true, |
| 30 | + /* Retry on CI only */ |
| 31 | + retries: isCI ? 1 : 0, |
| 32 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 33 | + forbidOnly: isCI, |
| 34 | + /* Opt out of parallel tests on CI. */ |
| 35 | + workers: isCI ? 1 : 2, |
| 36 | + |
| 37 | + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 38 | + use: { |
| 39 | + /* Base URL to use in actions like `await page.goto('/')`. */ |
| 40 | + baseURL, |
| 41 | + |
| 42 | + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
| 43 | + trace: "on-first-retry" |
| 44 | + }, |
| 45 | + |
| 46 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 47 | + reporter: [ |
| 48 | + [ |
| 49 | + "html", |
| 50 | + { |
| 51 | + outputFolder: `${outputDir}/reports/html`, |
| 52 | + open: isCI ? "never" : "always" |
| 53 | + } |
| 54 | + ], |
| 55 | + ["junit", { outputFile: `${outputDir}/reports/junit/results.xml` }] |
| 56 | + ], |
| 57 | + |
| 58 | + expect: { |
| 59 | + toHaveScreenshot: { |
| 60 | + maxDiffPixelRatio: 0.1, |
| 61 | + threshold: 0.05 |
| 62 | + }, |
| 63 | + // increased timeout (default is 5000) |
| 64 | + // pro: less flaky tests, no need to wait for network state |
| 65 | + // con: longer test duration where assertions are failing |
| 66 | + timeout: 30000 |
| 67 | + }, |
| 68 | + |
| 69 | + /* Configure projects for major browsers */ |
| 70 | + projects: [ |
| 71 | + { |
| 72 | + name: "Desktop Chrome", |
| 73 | + use: { |
| 74 | + ...devices["Desktop Chrome"], |
| 75 | + launchOptions: { |
| 76 | + // enable WEBGL for headless tests |
| 77 | + args: isCI |
| 78 | + ? ["--disable-gpu"] |
| 79 | + : [] |
| 80 | + }, |
| 81 | + viewport: { width: 1920, height: 1080 } |
| 82 | + } |
| 83 | + } |
| 84 | + ], |
| 85 | + |
| 86 | + timeout: isCI ? 120000 : 30000 |
| 87 | +}; |
| 88 | +export default defineConfig(config); |
0 commit comments