fix: optimize playwright config with increased timeouts and retries

This commit is contained in:
张翔
2026-03-20 07:55:29 +08:00
parent ce41fe7e26
commit 61f0c980cc
+22 -8
View File
@@ -2,21 +2,28 @@ import { defineConfig, devices } from '@playwright/test';
export default defineConfig({ export default defineConfig({
testDir: './e2e', testDir: './e2e',
fullyParallel: true, fullyParallel: false,
forbidOnly: !!process.env.CI, forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0, retries: process.env.CI ? 2 : 1,
workers: process.env.CI ? 1 : undefined, workers: process.env.CI ? 1 : 1,
reporter: [ reporter: [
['html'], ['html', { outputFolder: 'playwright-report' }],
['junit', { outputFile: 'test-results/junit.xml' }], ['json', { outputFile: 'test-results/results.json' }],
['list'] ['list']
], ],
timeout: 60000,
expect: {
timeout: 10000
},
use: { use: {
baseURL: 'http://localhost:4173', baseURL: 'http://localhost:5173',
trace: 'on-first-retry', trace: 'on-first-retry',
screenshot: 'only-on-failure', screenshot: 'only-on-failure',
video: 'retain-on-failure', video: 'retain-on-failure',
headless: true, actionTimeout: 15000,
navigationTimeout: 30000,
}, },
projects: [ projects: [
@@ -25,4 +32,11 @@ export default defineConfig({
use: { ...devices['Desktop Chrome'] }, use: { ...devices['Desktop Chrome'] },
}, },
], ],
});
webServer: {
command: 'npm run dev',
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
});