import { defineConfig, devices } from '@playwright/test'; /** * Playwright configuration for E2E and performance testing. * * This configuration is optimized for: * - Chromium-only testing (required for Lighthouse integration) * - Performance audits with playwright-lighthouse * - Testing Next.js application across all locales (de, en, sr) * * @see https://playwright.dev/docs/test-configuration */ export default defineConfig({ // Test directory testDir: './tests/e2e', // Run tests in files in parallel fullyParallel: true, // Fail the build on CI if you accidentally left test.only in the source code forbidOnly: !!process.env.CI, // Retry on CI only retries: process.env.CI ? 2 : 0, // Limit workers to avoid overwhelming the dev server workers: process.env.CI ? 1 : 4, // Reporter to use reporter: [ ['html', { open: 'never' }], ['list'], ], // Shared settings for all projects use: { // Base URL - uses dedicated test port to avoid conflicts with other dev servers baseURL: 'http://localhost:3100', // Collect trace when retrying the failed test trace: 'on-first-retry', // Take screenshot on failure screenshot: 'only-on-failure', }, // Configure projects for E2E testing // Note: --remote-debugging-port removed to allow parallel test execution. // For Lighthouse performance tests, use a separate config with a single worker. projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], }, }, // Mobile Chrome for responsive testing { name: 'mobile-chrome', use: { ...devices['Pixel 5'], }, }, // Tablet viewport for responsive testing { name: 'tablet', use: { viewport: { width: 768, height: 1024 }, }, }, ], // Configure web server to start before tests on a dedicated port webServer: { command: 'pnpm dev --port 3100', url: 'http://localhost:3100', reuseExistingServer: false, timeout: 120000, }, // Global timeout for each test timeout: 60000, // Expect timeout expect: { timeout: 10000, }, });