/** * Global teardown for real API integration tests * Cleanup resources and generate final reports */ import { writeFileSync } from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export default async function globalTeardown() { console.log('🧹 Starting global teardown for integration tests...'); try { // Generate final test report const testReport = { testRun: { timestamp: new Date().toISOString(), type: 'integration', environment: 'development' }, setup: global.__INTEGRATION_SETUP__ || {}, summary: { message: 'Integration test run completed', backend: 'http://localhost:8000', frontend: 'http://localhost:3001', sshTunnel: 'managed externally' } }; // Write final report const reportPath = path.join(__dirname, '../../test-results/integration-summary.json'); try { writeFileSync(reportPath, JSON.stringify(testReport, null, 2)); console.log(`📊 Integration test summary written to: ${reportPath}`); } catch (error) { console.warn('âš ī¸ Could not write integration test summary:', error.message); } // Log cleanup completion console.log('✅ Global teardown completed'); console.log('â„šī¸ SSH tunnel and services left running for continued development'); console.log('â„šī¸ Use ./ssh_tunnel.sh stop to manually stop the SSH tunnel if needed'); } catch (error) { console.error('❌ Global teardown encountered errors:', error.message); // Don't fail teardown on non-critical errors } }