import { defineConfig, devices } from '@playwright/test' /** * Playwright E2E 测试配置 * 乐读派 AI 绘本创作集成测试 */ export default defineConfig({ testDir: './e2e', /* 测试超时 */ timeout: 30_000, expect: { timeout: 10_000, }, /* 并行执行 */ fullyParallel: true, /* CI 环境重试 */ retries: process.env.CI ? 2 : 0, /* 报告 */ reporter: [['html', { open: 'never' }], ['list']], /* 全局配置 */ use: { baseURL: process.env.FRONTEND_URL || 'http://localhost:3000', trace: 'on-first-retry', screenshot: 'only-on-failure', actionTimeout: 10_000, }, /* 浏览器项目 */ projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], /* 本地开发服务器 */ webServer: { command: 'npm run dev', port: 3000, reuseExistingServer: !process.env.CI, timeout: 30_000, }, })