import * as fs from 'fs'; import * as path from 'path'; import { TestDataFactory } from './TestDataFactory'; export class TestDataCleaner { static async cleanupDatabase(): Promise { console.log('清理测试数据库...'); } static async cleanupFiles(): Promise { const testResultsDir = path.join(process.cwd(), 'test-results'); if (fs.existsSync(testResultsDir)) { const files = fs.readdirSync(testResultsDir); for (const file of files) { const filePath = path.join(testResultsDir, file); const stat = fs.statSync(filePath); if (stat.isDirectory()) { fs.rmSync(filePath, { recursive: true, force: true }); } else { fs.unlinkSync(filePath); } } } } static async cleanupCache(): Promise { TestDataFactory.clearCache(); } static async cleanupAll(): Promise { await this.cleanupDatabase(); await this.cleanupFiles(); await this.cleanupCache(); } }