import { defineConfig, devices } from '@playwright/test'; // URL base configurable via variable de entorno (para CI/CD) const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'; const isCI = !!process.env['CI']; const isProduction = baseURL.includes('https://'); export default defineConfig({ testDir: './e2e', fullyParallel: true, forbidOnly: isCI, retries: isCI ? 2 : 0, workers: isCI ? 1 : undefined, reporter: isCI ? [['html'], ['list']] : 'html', timeout: isProduction ? 60000 : 30000, use: { baseURL, trace: 'on-first-retry', screenshot: 'only-on-failure', video: isCI ? 'retain-on-failure' : 'off', }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], // Solo iniciar servidor local si no es producción ...(isProduction ? {} : { webServer: { command: 'npm run start', url: 'http://localhost:4200', reuseExistingServer: !isCI, timeout: 120000, }, }), });