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:
William Valentin
2025-11-03 12:11:10 -08:00
parent 5e872ef952
commit df245fff90
5 changed files with 255 additions and 79 deletions

View File

@@ -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");