geo/frontend/playwright.config.ts

53 lines
1.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig, devices } from "@playwright/test";
// E2E_BUILD=1 时使用生产构建,避免按需编译导致超时
const useBuild = process.env.E2E_BUILD === "1";
export default defineConfig({
testDir: "./e2e/tests",
// 本地开发启用并行CI 环境串行
fullyParallel: !process.env.CI,
forbidOnly: !!process.env.CI,
// 本地 1 次重试CI 2 次
retries: process.env.CI ? 2 : 1,
// 本地 2 个 worker避免机器卡顿CI 1 个
workers: process.env.CI ? 1 : 2,
reporter: "html",
// 生产构建已预编译,超时可以缩短
timeout: useBuild ? 60 * 1000 : 120 * 1000,
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry",
screenshot: "only-on-failure",
video: "retain-on-failure",
actionTimeout: 30000,
navigationTimeout: useBuild ? 15000 : 60000,
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
webServer: {
// E2E_BUILD=1 时先 build 再 start否则用 dev
command: useBuild
? "npm run build && npm start"
: "npm run dev",
url: "http://localhost:3000/api/auth/session",
reuseExistingServer: true,
timeout: useBuild ? 300 * 1000 : 120 * 1000,
maxRetries: 3,
},
});