| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { defineConfig, devices } from '@playwright/test'
- /**
- * Playwright E2E 测试配置
- * @see https://playwright.dev/docs/test-configuration
- */
- export default defineConfig({
- // 测试目录
- testDir: './e2e',
- // 测试文件匹配模式
- testMatch: '**/*.spec.ts',
- // 并行执行
- fullyParallel: true,
- // CI 环境下禁止 only
- forbidOnly: !!process.env.CI,
- // 失败重试次数
- retries: process.env.CI ? 2 : 0,
- // 并行工作线程数
- workers: process.env.CI ? 1 : undefined,
- // 报告器
- reporter: [
- ['html', { outputFolder: 'playwright-report' }],
- ['list']
- ],
- // 全局配置
- use: {
- // 基础 URL
- baseURL: 'http://localhost:8000',
- // 收集失败时的追踪信息
- trace: 'on-first-retry',
- // 截图
- screenshot: 'only-on-failure',
- // 视频录制
- video: 'on-first-retry',
- },
- // 浏览器配置
- projects: [
- {
- name: 'chromium',
- use: { ...devices['Desktop Chrome'] },
- },
- ],
- // 启动开发服务器
- webServer: {
- command: 'pnpm dev',
- url: 'http://localhost:8000',
- reuseExistingServer: !process.env.CI,
- timeout: 120 * 1000,
- },
- })
|