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('✅ 全局测试环境清理完成'); } export default globalTeardown;