import { defineConfig, devices } from '@playwright/test'; /** * OpenHIS Playwright E2E 测试配置 v2.0 * * 运行命令: * npx playwright test # 全部测试 * npx playwright test --project=chromium # 仅Chrome * npx playwright test login # 仅登录测试 * npx playwright test --ui # UI交互模式 * npx playwright test --headed # 有头模式(可视化) * npx playwright test --tags=@smoke # 仅冒烟测试 */ export default defineConfig({ testDir: './tests/e2e/specs', fullyParallel: true, timeout: 60_000, expect: { timeout: 10_000 }, retries: process.env.CI ? 2 : 1, workers: process.env.CI ? 2 : undefined, reporter: [ ['html', { outputFolder: 'tests/e2e/report', open: 'never' }], ['list'], ], use: { baseURL: process.env.TEST_BASE_URL || 'http://localhost:81', screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'retain-on-failure', viewport: { width: 1920, height: 1080 }, locale: 'zh-CN', timezoneId: 'Asia/Shanghai', actionTimeout: 15_000, navigationTimeout: 30_000, }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] } }, { name: 'firefox', use: { ...devices['Desktop Firefox'] } }, ], });