e0ca8235c8
ci/woodpecker/push/woodpecker Pipeline failed
1. playwright.config.ts: - 添加类型断言 'fast' | 'standard' | 'deep' - 为tierConfig添加明确的Record类型 - 移除不必要的fallback 2. test-data-cleaner.ts: - 修复Object is possibly 'undefined'错误 - 添加可选链和空值检查
90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
const isCI = !!process.env.CI;
|
|
const testTier = (process.env.TEST_TIER || 'standard') as 'fast' | 'standard' | 'deep';
|
|
const baseURL = process.env.BASE_URL || (isCI ? 'http://localhost:3000' : 'https://novalon.cn');
|
|
|
|
const tierConfig: Record<'fast' | 'standard' | 'deep', {
|
|
timeout: number;
|
|
retries: number;
|
|
workers: number | undefined;
|
|
}> = {
|
|
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];
|
|
|
|
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'] },
|
|
},
|
|
],
|
|
});
|