1. playwright.config.ts: - 添加类型断言 'fast' | 'standard' | 'deep' - 为tierConfig添加明确的Record类型 - 移除不必要的fallback 2. test-data-cleaner.ts: - 修复Object is possibly 'undefined'错误 - 添加可选链和空值检查
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
import { defineConfig, devices } from '@playwright/test';
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
const isCI = !!process.env.CI;
|
const isCI = !!process.env.CI;
|
||||||
const testTier = process.env.TEST_TIER || 'standard';
|
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 baseURL = process.env.BASE_URL || (isCI ? 'http://localhost:3000' : 'https://novalon.cn');
|
||||||
|
|
||||||
const tierConfig = {
|
const tierConfig: Record<'fast' | 'standard' | 'deep', {
|
||||||
|
timeout: number;
|
||||||
|
retries: number;
|
||||||
|
workers: number | undefined;
|
||||||
|
}> = {
|
||||||
fast: {
|
fast: {
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
retries: 0,
|
retries: 0,
|
||||||
@@ -22,7 +26,7 @@ const tierConfig = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = tierConfig[testTier] || tierConfig.standard;
|
const config = tierConfig[testTier];
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: './e2e',
|
testDir: './e2e',
|
||||||
|
|||||||
@@ -71,8 +71,11 @@ export class TestDataCleaner {
|
|||||||
static clearCookies(): void {
|
static clearCookies(): void {
|
||||||
if (typeof document !== 'undefined' && document.cookie) {
|
if (typeof document !== 'undefined' && document.cookie) {
|
||||||
document.cookie.split(';').forEach(cookie => {
|
document.cookie.split(';').forEach(cookie => {
|
||||||
const name = cookie.split('=')[0].trim();
|
const parts = cookie.split('=');
|
||||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
const name = parts[0]?.trim();
|
||||||
|
if (name) {
|
||||||
|
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user