e44140b8b8
ci/woodpecker/push/woodpecker Pipeline failed
问题根本原因: - E2E测试访问生产环境URL (https://novalon.cn) - 应该测试代码库中的代码,而非生产环境 - CI环境需要启动本地服务器进行测试 修复方案: - 更新playwright.config.tiered.ts配置 - baseURL改为 http://localhost:3000 - 添加webServer配置,自动启动本地服务器 - 更新CI配置 - 添加BASE_URL环境变量 - 先构建项目(npm run build) - 然后运行E2E测试 验证: - E2E测试将测试本地构建的代码 - 不依赖生产环境 Ralph Loop #8 完成
59 lines
1.2 KiB
TypeScript
59 lines
1.2 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
const testTier = process.env.TEST_TIER || 'standard';
|
|
|
|
const tierConfig = {
|
|
fast: {
|
|
timeout: 15000,
|
|
retries: 0,
|
|
workers: 2,
|
|
},
|
|
standard: {
|
|
timeout: 30000,
|
|
retries: 1,
|
|
workers: 1,
|
|
},
|
|
deep: {
|
|
timeout: 60000,
|
|
retries: 2,
|
|
workers: 1,
|
|
},
|
|
};
|
|
|
|
const config = tierConfig[testTier] || tierConfig.standard;
|
|
|
|
export default defineConfig({
|
|
testDir: './',
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: config.retries,
|
|
workers: config.workers,
|
|
timeout: config.timeout,
|
|
reporter: [
|
|
['html', { outputFolder: 'reports/html', open: 'never' }],
|
|
['json', { outputFile: 'reports/results.json' }],
|
|
['list']
|
|
],
|
|
use: {
|
|
baseURL: process.env.BASE_URL || 'http://localhost:3000',
|
|
trace: 'on-first-retry',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
launchOptions: {
|
|
args: ['--disable-dev-shm-usage', '--no-sandbox']
|
|
}
|
|
},
|
|
webServer: process.env.CI ? {
|
|
command: 'npm run start',
|
|
port: 3000,
|
|
timeout: 120000,
|
|
reuseExistingServer: false,
|
|
} : undefined,
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
});
|