Files
awoooi/apps/web/playwright.config.ts
OG T 3bfb9c51f5 chore: Skills + CLAUDE.md + Playwright 配置更新
- SRE-QA Skills 擴充
- CLAUDE.md 指引更新
- playwright.config.ts 優化

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-29 16:04:43 +08:00

62 lines
1.5 KiB
TypeScript
Raw 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'
/**
* Playwright E2E 測試配置
* =======================
* Phase VI: 截圖 + 錄影自動產出
*/
// Phase 20: 支持環境變數覆蓋 baseURL可針對生產環境測試
const baseURL = process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000'
const isRemote = baseURL !== 'http://localhost:3000'
export default defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { outputFolder: 'test-results/html-report' }],
['list'],
],
use: {
// Base URL for navigation (可通過 PLAYWRIGHT_BASE_URL 環境變數覆蓋)
baseURL,
// 截圖與錄影 - 統帥強制要求
screenshot: 'on',
video: 'on',
trace: 'on-first-retry',
// Viewport
viewport: { width: 1920, height: 1080 },
// Timeouts
actionTimeout: 10000,
navigationTimeout: 30000,
},
// Output directory for screenshots and videos
outputDir: 'test-results',
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
// Web server configuration - start Next.js dev server
// 當使用遠端 URL (PLAYWRIGHT_BASE_URL) 時跳過本地 dev server
...(isRemote ? {} : {
webServer: {
command: 'pnpm dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
}),
})