Files
Portfolio/playwright.config.ts

90 lines
2.1 KiB
TypeScript

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 - test against running Docker container
baseURL: process.env.BASE_URL || 'http://localhost:3001',
// 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 },
},
},
],
// Use running Docker container - no webServer needed
// 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,
},
});