/** * 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;