Headless wird sicher erzwungen (auch wenn lokal anders).

Der Next.js-Server wird gebaut und via npm start im selben Container gestartet (statt npm run dev).

Robustere Browser-Flags für Container.

Artefakte (Trace/Screenshot/Video) nur bei Fehlern, damit der CI schnell bleibt.

baseURL kommt aus ENV (E2E_BASE_URL) – lokal bleibt’s http://localhost:3000.

PLAYWRIGHT_BROWSERS_PATH=0 bleibt (Option B).
This commit is contained in:
ISA
2025-08-29 11:45:09 +02:00
parent 9f43fdc820
commit 05c1c9c0cf
7 changed files with 61 additions and 21 deletions

View File

@@ -1,28 +1,53 @@
import { defineConfig, devices } from "@playwright/test";
const CI = !!process.env.CI;
export default defineConfig({
testDir: "./playwright/tests",
// Globale Zeitlimits
timeout: 90_000,
expect: { timeout: 10_000 },
expect: { timeout: 15_000 }, // etwas großzügiger im CI
// Setup/Parallelisierung
globalSetup: "./playwright/global-setup",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
forbidOnly: CI,
retries: CI ? 2 : 0,
workers: CI ? 1 : undefined,
reporter: [["html", { outputFolder: "playwright/report" }]],
// Reporter & Ausgabepfade
reporter: [
["list"],
["html", { outputFolder: "playwright/report", open: "never" }],
],
outputDir: "playwright/test-results",
// Standard-Defaults für alle Tests/Projekte
use: {
baseURL: "http://localhost:3000",
headless: true,
launchOptions: { slowMo: 300 },
// 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 },
video: "on",
screenshot: "on",
trace: "on-first-retry",
// 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",
@@ -30,9 +55,11 @@ export default defineConfig({
},
],
// Webserver: baue & starte Next.js (statt "dev")
webServer: {
command: "npm run dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
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
},
});