- Implemented real integration tests in `real-integration.test.ts` to validate the functionality of the DebrosFramework with IPFS and OrbitDB. - Created `RealTestUser` and `RealTestPost` models for testing user and post functionalities. - Developed setup and teardown lifecycle methods for managing the test environment. - Introduced `RealIPFSService` and `RealOrbitDBService` classes for managing IPFS and OrbitDB instances. - Added `PrivateSwarmSetup` for configuring a private IPFS network. - Implemented utility functions for creating and shutting down IPFS and OrbitDB networks. - Created a global test manager for managing test lifecycle and network state. - Updated TypeScript configuration to include test files and exclude them from the main build.
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
// Global teardown for real integration tests
|
|
module.exports = async () => {
|
|
console.log('🧹 Global teardown for real integration tests');
|
|
|
|
// Force cleanup any remaining processes
|
|
try {
|
|
// Kill any orphaned processes that might be hanging around
|
|
const { exec } = require('child_process');
|
|
const { promisify } = require('util');
|
|
const execAsync = promisify(exec);
|
|
|
|
// Clean up any leftover IPFS processes (be careful - only test processes)
|
|
try {
|
|
await execAsync('pkill -f "test.*ipfs" || true');
|
|
} catch (error) {
|
|
// Ignore errors - processes might not exist
|
|
}
|
|
|
|
// Clean up temporary directories
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
|
|
const tempDir = os.tmpdir();
|
|
const testDirs = fs.readdirSync(tempDir).filter(dir => dir.startsWith('debros-test-'));
|
|
|
|
for (const dir of testDirs) {
|
|
try {
|
|
const fullPath = path.join(tempDir, dir);
|
|
fs.rmSync(fullPath, { recursive: true, force: true });
|
|
console.log(`🗑️ Cleaned up: ${fullPath}`);
|
|
} catch (error) {
|
|
console.warn(`⚠️ Could not clean up ${dir}:`, error.message);
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.warn('⚠️ Error during global teardown:', error.message);
|
|
}
|
|
|
|
console.log('✅ Global teardown complete');
|
|
}; |