| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import { defineConfig, devices } from '@playwright/test';
- export default defineConfig({
- testDir: './specs',
- fullyParallel: true,
- forbidOnly: !!process.env.CI,
- retries: process.env.CI ? 2 : 0,
- workers: process.env.CI ? 1 : 4,
- // 缩短默认超时时间(Playwright 默认 30000ms),加快测试失败反馈
- timeout: 60000, // E2E 测试需要更长时间(多个下拉框操作)
- reporter: [
- ['html'],
- ['list'],
- ['junit', { outputFile: 'test-results/junit.xml' }]
- ],
- use: {
- baseURL: process.env.E2E_BASE_URL || 'http://localhost:8080',
- trace: 'on-first-retry',
- screenshot: 'only-on-failure',
- video: 'retain-on-failure',
- // 在每个测试前设置测试模式标志,使 Checkbox 组件使用原生版本
- initScripts: [
- '(() => { window.__PLAYWRIGHT_TEST__ = true; })()'
- ],
- },
- projects: [
- {
- name: 'chromium',
- use: { ...devices['Desktop Chrome'] },
- },
- {
- name: 'firefox',
- use: { ...devices['Desktop Firefox'] },
- },
- {
- name: 'webkit',
- use: { ...devices['Desktop Safari'] },
- },
- {
- name: 'Mobile Chrome',
- use: { ...devices['Pixel 5'] },
- },
- {
- name: 'Mobile Safari',
- use: { ...devices['iPhone 12'] },
- },
- ],
- webServer: {
- command: 'npm run dev',
- url: 'http://localhost:8080',
- reuseExistingServer: !process.env.CI,
- timeout: 120000,
- },
- });
|