You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haoliang-net/frontend/playwright.config.ts

34 lines
947 B
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { defineConfig } from '@playwright/test'
// 通过环境变量 DEV_MODE 切换模式:
// - 默认IIS模式直接连接已部署的 http://127.0.0.1/admin不启动本地dev server
// - DEV_MODE=1启动 npm run dev连接 http://localhost:5173
const isDev = !!process.env.DEV_MODE
export default defineConfig({
testDir: './e2e',
timeout: 60000,
expect: { timeout: 10000 },
fullyParallel: false,
retries: 0,
use: {
baseURL: isDev ? 'http://localhost:5173' : 'http://127.0.0.1/admin',
headless: true,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
actionTimeout: 10000,
},
projects: [
{ name: 'chromium', use: { browserName: 'chromium' } },
],
// IIS模式下不启动webServer直接连接已部署的站点
...(isDev ? {
webServer: {
command: 'npm run dev',
port: 5173,
reuseExistingServer: true,
timeout: 30000,
}
} : {}),
})