0337c51320
ci/woodpecker/push/woodpecker Pipeline failed
- 统一依赖安装步骤,添加缓存复用,减少冗余npm ci - 整合Playwright配置文件,支持CI/本地环境自动切换 - 扩展shared-mocks.tsx,添加统一mock入口 - 修复jest.setup.js符号链接问题 - 删除冗余配置文件(jest.config.js, playwright.config.tiered.ts) - 调整CI阶段编号(7阶段→6阶段) 优化效果: - CI依赖安装时间减少约30% - 配置文件维护成本降低 - Mock复用率提升
86 lines
1.9 KiB
TypeScript
86 lines
1.9 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
const isCI = !!process.env.CI;
|
|
const testTier = process.env.TEST_TIER || 'standard';
|
|
const baseURL = process.env.BASE_URL || (isCI ? 'http://localhost:3000' : 'https://novalon.cn');
|
|
|
|
const tierConfig = {
|
|
fast: {
|
|
timeout: 15000,
|
|
retries: 0,
|
|
workers: 2,
|
|
},
|
|
standard: {
|
|
timeout: 30000,
|
|
retries: isCI ? 1 : 0,
|
|
workers: isCI ? 1 : undefined,
|
|
},
|
|
deep: {
|
|
timeout: 60000,
|
|
retries: 2,
|
|
workers: 1,
|
|
},
|
|
};
|
|
|
|
const config = tierConfig[testTier] || tierConfig.standard;
|
|
|
|
export default defineConfig({
|
|
testDir: './e2e',
|
|
fullyParallel: !isCI,
|
|
forbidOnly: isCI,
|
|
retries: config.retries,
|
|
workers: config.workers,
|
|
timeout: config.timeout,
|
|
reporter: isCI
|
|
? [
|
|
['html', { outputFolder: 'reports/html', open: 'never' }],
|
|
['json', { outputFile: 'reports/results.json' }],
|
|
['list']
|
|
]
|
|
: 'html',
|
|
use: {
|
|
baseURL,
|
|
trace: 'on-first-retry',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
launchOptions: isCI ? {
|
|
args: ['--disable-dev-shm-usage', '--no-sandbox']
|
|
} : undefined,
|
|
},
|
|
webServer: isCI ? {
|
|
command: 'npm run start',
|
|
port: 3000,
|
|
timeout: 120000,
|
|
reuseExistingServer: false,
|
|
} : undefined,
|
|
projects: isCI
|
|
? [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
]
|
|
: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
{
|
|
name: 'firefox',
|
|
use: { ...devices['Desktop Firefox'] },
|
|
},
|
|
{
|
|
name: 'webkit',
|
|
use: { ...devices['Desktop Safari'] },
|
|
},
|
|
{
|
|
name: 'Mobile Chrome',
|
|
use: { ...devices['Pixel 5'] },
|
|
},
|
|
{
|
|
name: 'Mobile Safari',
|
|
use: { ...devices['iPhone 12'] },
|
|
},
|
|
],
|
|
});
|