fix: improve test infrastructure and resolve mocking issues

- Fix Jest test runner configuration (was using bun test)
- Implement proper CouchDB service mocking in jest.preSetup.js
- Update errorhandling.test.js to use test app instead of real server
- Fix browserslist deprecation warnings
- Skip CouchDB initialization during test environment
- 22/22 Post model tests now passing
- 7/38 error handling tests now passing

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
William Valentin
2025-11-03 12:13:16 -08:00
parent df245fff90
commit 780147eabf
57 changed files with 15524 additions and 68 deletions

View File

@@ -1,7 +1,7 @@
const request = require("supertest");
const socketIoClient = require("socket.io-client");
const jwt = require("jsonwebtoken");
const app = require("../server");
const { app, server, io } = require("../server");
const User = require("../models/User");
const Event = require("../models/Event");
const Post = require("../models/Post");
@@ -15,9 +15,10 @@ describe("Socket.IO Real-time Features", () => {
let authToken;
beforeAll(async () => {
// Start server
server = app.listen(0); // Use random port
io = app.get("io");
// Start server if not already started
if (!server.listening) {
server.listen(0); // Use random port
}
// Create test user
testUser = await User.create({