42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test'
|
|
|
|
/**
|
|
* E2E(L3)—— 只用来覆盖单测跑不了的部分:
|
|
* 真实布局(弹层定位 / 层叠上下文)、命中测试、拖拽、焦点陷阱、DOM 重建检测。
|
|
*
|
|
* 面向工具/AI 的设计:
|
|
* - `webServer` 自动拉起 playground,不需要手工起服务
|
|
* - 失败自动留截图 + trace + video,产物在 test-results/
|
|
* - json reporter 输出 test-results/e2e.json,便于脚本读取与二次分析
|
|
*/
|
|
export default defineConfig({
|
|
testDir: './e2e',
|
|
timeout: 30_000,
|
|
expect: { timeout: 5_000 },
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 1 : 0,
|
|
reporter: [
|
|
['list'],
|
|
['json', { outputFile: 'test-results/e2e.json' }],
|
|
],
|
|
use: {
|
|
baseURL: 'http://localhost:5200',
|
|
// 失败留证据:截图定位视觉问题、trace 可下载后在浏览器里逐步回放
|
|
// (刻意不开 video:体积大,且每次启动清理产物容易撞到 IDE 的批量删除守卫)
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
video: 'off',
|
|
viewport: { width: 1280, height: 900 },
|
|
},
|
|
webServer: {
|
|
command: 'pnpm exec vite --config playground/vite.config.ts',
|
|
url: 'http://localhost:5200',
|
|
reuseExistingServer: true,
|
|
timeout: 90_000,
|
|
stdout: 'ignore',
|
|
stderr: 'pipe',
|
|
},
|
|
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
|
})
|