This repository has been archived on 2025-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
network-orbit/tests/real/jest.setup.ts
anonpenguin 8d3ccdc80c Add real integration tests for IPFS and OrbitDB
- 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.
2025-06-19 21:29:50 +03:00

63 lines
1.7 KiB
TypeScript

// Jest setup for real integration tests
import { jest } from '@jest/globals';
// Increase timeout for all tests
jest.setTimeout(180000); // 3 minutes
// Disable console logs in tests unless in debug mode
const originalConsole = console;
const debugMode = process.env.REAL_TEST_DEBUG === 'true';
if (!debugMode) {
// Silence routine logs but keep errors and important messages
console.log = (...args: any[]) => {
const message = args.join(' ');
if (message.includes('❌') || message.includes('✅') || message.includes('🚀') || message.includes('🧹')) {
originalConsole.log(...args);
}
};
console.info = () => {}; // Silence info
console.debug = () => {}; // Silence debug
// Keep warnings and errors
console.warn = originalConsole.warn;
console.error = originalConsole.error;
}
// Global error handlers
process.on('unhandledRejection', (reason, promise) => {
console.error('❌ Unhandled Rejection at:', promise, 'reason:', reason);
});
process.on('uncaughtException', (error) => {
console.error('❌ Uncaught Exception:', error);
});
// Environment setup
process.env.NODE_ENV = 'test';
process.env.DEBROS_TEST_MODE = 'real';
// Global test utilities
declare global {
namespace NodeJS {
interface Global {
REAL_TEST_CONFIG: {
timeout: number;
nodeCount: number;
debugMode: boolean;
};
}
}
}
(global as any).REAL_TEST_CONFIG = {
timeout: 180000,
nodeCount: parseInt(process.env.REAL_TEST_NODE_COUNT || '3'),
debugMode: debugMode
};
console.log('🔧 Real test environment configured');
console.log(` Debug mode: ${debugMode}`);
console.log(` Node count: ${(global as any).REAL_TEST_CONFIG.nodeCount}`);
console.log(` Timeout: ${(global as any).REAL_TEST_CONFIG.timeout}ms`);