diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..c007caf --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,97 @@ +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, + }, +}); diff --git a/tests/e2e/setup.spec.ts b/tests/e2e/setup.spec.ts new file mode 100644 index 0000000..24536ed --- /dev/null +++ b/tests/e2e/setup.spec.ts @@ -0,0 +1,13 @@ +import { test, expect } from '@playwright/test'; + +/** + * Initial setup verification test. + * This test verifies the Playwright configuration is working correctly. + */ +test.describe('Setup Verification', () => { + test('Playwright is configured correctly', async ({ page }) => { + // This test serves as a configuration verification + // It will be removed or updated once proper E2E tests are added + expect(page).toBeDefined(); + }); +});