import { defineConfig, devices } from '@playwright/test';
/**
* Playwright Configuration for E2E Tests
*
* Run tests with:
* npx playwright test
* npx playwright test --headed
* npx playwright test --debug
* npx playwright show-report
*/
export default defineConfig({
// Test directory
testDir: './tests/e2e',
// Maximum time one test can run
timeout: 60 * 1000,
// Test configuration
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
// Reporter configuration
reporter: [
['html'],
['list'],
['json', { outputFile: 'test-results/e2e-results.json' }]
],
// Shared settings for all projects
use: {
// Base URL from environment or default to staging
baseURL: process.env.STAGING_URL || 'http://localhost:5173',
// Collect trace when retrying
trace: 'on-first-retry',
// Screenshot on failure
screenshot: 'only-on-failure',
// Video on failure
video: 'retain-on-failure',
// Timeouts
actionTimeout: 10 * 1000,
navigationTimeout: 30 * 1000,
},
// Test projects for different browsers
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// Mobile viewports
{
name: 'mobile-chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'mobile-safari',
use: { ...devices['iPhone 12'] },
},
],
// Web server for local development testing
webServer: process.env.CI ? undefined : {
command: 'npm run dev',
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});