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, // Opt out of parallel tests on CI workers: process.env.CI ? 1 : undefined, // Reporter to use reporter: [ ['html', { open: 'never' }], ['list'], ], // Shared settings for all projects use: { // Base URL to use in actions like `await page.goto('/')` baseURL: 'http://localhost:3000', // Collect trace when retrying the failed test trace: 'on-first-retry', // Take screenshot on failure screenshot: 'only-on-failure', }, // Configure projects - Chromium only for Lighthouse compatibility projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], // Launch options for Lighthouse launchOptions: { args: ['--remote-debugging-port=9222'], }, }, }, // Mobile Chrome for responsive testing { name: 'mobile-chrome', use: { ...devices['Pixel 5'], launchOptions: { args: ['--remote-debugging-port=9223'], }, }, }, // Tablet viewport for responsive testing { name: 'tablet', use: { viewport: { width: 768, height: 1024 }, launchOptions: { args: ['--remote-debugging-port=9224'], }, }, }, ], // Configure web server to start before tests webServer: { command: 'npm run dev', url: 'http://localhost:3000', reuseExistingServer: !process.env.CI, timeout: 120000, }, // Global timeout for each test timeout: 60000, // Expect timeout expect: { timeout: 10000, }, });