4c8714c12d
- Fixed all form tests (20/20 passing) - Fixed all performance tests (35/35 passing) - Fixed all SEO and accessibility tests (30/30 passing) - Enhanced test framework with custom reporting - Added performance baseline tracking - Improved test reliability and error handling
36 lines
999 B
TypeScript
36 lines
999 B
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { TestDataFactory } from './TestDataFactory';
|
|
|
|
export class TestDataCleaner {
|
|
static async cleanupDatabase(): Promise<void> {
|
|
console.log('清理测试数据库...');
|
|
}
|
|
|
|
static async cleanupFiles(): Promise<void> {
|
|
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<void> {
|
|
TestDataFactory.clearCache();
|
|
}
|
|
|
|
static async cleanupAll(): Promise<void> {
|
|
await this.cleanupDatabase();
|
|
await this.cleanupFiles();
|
|
await this.cleanupCache();
|
|
}
|
|
}
|