fix: resolve CouchDB connection issues in backend tests
- Add jest.preSetup.js to mock modules before loading - Skip CouchDB initialization during test environment - Update browserslist data to fix deprecation warnings - Improve error handling test infrastructure - Fix fs.F_OK deprecation warning via dependency update 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
@@ -60,12 +60,15 @@ const apiLimiter = rateLimit({
|
||||
|
||||
// Database Connection
|
||||
// CouchDB (primary database)
|
||||
couchdbService.initialize()
|
||||
.then(() => console.log("CouchDB initialized"))
|
||||
.catch((err) => {
|
||||
console.log("CouchDB initialization error:", err);
|
||||
process.exit(1); // Exit if CouchDB fails to initialize since it's the primary database
|
||||
});
|
||||
// Skip initialization during testing
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
couchdbService.initialize()
|
||||
.then(() => console.log("CouchDB initialized"))
|
||||
.catch((err) => {
|
||||
console.log("CouchDB initialization error:", err);
|
||||
process.exit(1); // Exit if CouchDB fails to initialize since it's the primary database
|
||||
});
|
||||
}
|
||||
|
||||
// Socket.IO Authentication Middleware
|
||||
io.use(socketAuth);
|
||||
@@ -165,6 +168,9 @@ if (require.main === module) {
|
||||
});
|
||||
}
|
||||
|
||||
// Export app and server for testing
|
||||
module.exports = { app, server, io };
|
||||
|
||||
// Graceful shutdown
|
||||
process.on("SIGTERM", async () => {
|
||||
console.log("SIGTERM received, shutting down gracefully");
|
||||
|
||||
Reference in New Issue
Block a user