feat: 简化测试场景,提高稳定性
- 创建独立的global-teardown.ts文件 - 增加测试间隔(每个测试后等待2秒) - 添加后端健康检查,确保服务可用 - 优化测试隔离,清理localStorage和sessionStorage - 降低后端负载,提高测试稳定性
This commit is contained in:
@@ -1,21 +1,3 @@
|
||||
import { FullConfig } from '@playwright/test';
|
||||
import { exec } from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
async function globalTeardown(config: FullConfig) {
|
||||
console.log('🧹 开始全局测试环境清理...');
|
||||
|
||||
console.log('🛑 停止后端服务...');
|
||||
try {
|
||||
await execAsync('lsof -ti:8084 | xargs kill -9 2>/dev/null || true');
|
||||
console.log('✅ 后端服务已停止');
|
||||
} catch (error) {
|
||||
console.log('⚠️ 后端服务停止时出现警告:', error);
|
||||
}
|
||||
|
||||
console.log('✅ 全局测试环境清理完成');
|
||||
}
|
||||
import { globalTeardown } from './global-setup';
|
||||
|
||||
export default globalTeardown;
|
||||
|
||||
Reference in New Issue
Block a user