Files
thrilltrack-explorer/tests/setup/global-teardown.ts
2025-10-30 15:42:28 +00:00

40 lines
1.2 KiB
TypeScript

/**
* Playwright Global Teardown
*
* Runs once after all tests to clean up the test environment.
*/
import { FullConfig } from '@playwright/test';
import { cleanupTestData, getTestDataStats } from '../fixtures/database';
async function globalTeardown(config: FullConfig) {
console.log('🧹 Starting global teardown...');
try {
// Get stats before cleanup
const statsBefore = await getTestDataStats();
console.log('📊 Test data before cleanup:', statsBefore);
// Clean up all test data
await cleanupTestData();
// Verify cleanup
const statsAfter = await getTestDataStats();
console.log('📊 Test data after cleanup:', statsAfter);
const totalRemaining = Object.values(statsAfter).reduce((sum, count) => sum + count, 0);
if (totalRemaining > 0) {
console.warn('⚠️ Some test data may not have been cleaned up properly');
} else {
console.log('✅ All test data cleaned up successfully');
}
console.log('✅ Global teardown complete');
} catch (error) {
console.error('❌ Global teardown failed:', error);
// Don't throw - we don't want to fail the test run because of cleanup issues
}
}
export default globalTeardown;