import { defineConfig, devices } from "@playwright/test"; const CI = !!process.env.CI; export default defineConfig({ testDir: "./playwright/tests", // Globale Zeitlimits timeout: 90_000, expect: { timeout: 15_000 }, // etwas großzügiger im CI // Setup/Parallelisierung globalSetup: "./playwright/global-setup", fullyParallel: true, forbidOnly: CI, retries: CI ? 2 : 0, workers: CI ? 1 : undefined, // Reporter & Ausgabepfade reporter: [ ["list"], ["html", { outputFolder: "playwright/report", open: "never" }], ], outputDir: "playwright/test-results", // Standard-Defaults für alle Tests/Projekte use: { // Base-URL: im CI per ENV steuerbar baseURL: process.env.E2E_BASE_URL || "http://localhost:3000", // Headless im CI (und wenn PW_HEADLESS=1); lokal darfst du headed verwenden headless: process.env.PW_HEADLESS === "1" || CI, // Container-robuste Flags launchOptions: { args: ["--no-sandbox", "--disable-dev-shm-usage"], }, viewport: { width: 1920, height: 1080 }, // Artefakte – sparsam, aber genug fürs Debugging video: CI ? "retain-on-failure" : "on-first-retry", screenshot: CI ? "only-on-failure" : "only-on-failure", trace: "retain-on-failure", // Optional: falls du Test-IDs nutzt testIdAttribute: "data-testid", }, // Projekte (nur Chromium) projects: [ { name: "chromium", use: { ...devices["Desktop Chrome"] }, }, ], // Webserver: baue & starte Next.js (statt "dev") webServer: { command: "npm run build && npm run start -p 3000", url: process.env.E2E_BASE_URL || "http://localhost:3000", reuseExistingServer: !CI, timeout: 120_000, // Zeit für Build+Start }, });