mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-27 15:47:09 -05:00
feat: Implement Playwright testing setup
This commit is contained in:
39
tests/setup/global-teardown.ts
Normal file
39
tests/setup/global-teardown.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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;
|
||||
Reference in New Issue
Block a user