PROBLEM: 10/26 integration test suites hanging (API tests) - Tests import app but don't connect required databases - Tractatus uses TWO separate DB connections (native + Mongoose) - Tests only connected one, causing hangs when routes accessed User model INVESTIGATION: - Created minimal.test.js - diagnostic test (passes) - Identified root cause: dual database architecture - Updated api.auth.test.js with both connections (still investigating hang) CREATED: - tests/helpers/db-test-helper.js - Unified database setup helper Exports setupDatabases() and cleanupDatabases() Connects both native MongoDB driver AND Mongoose Ready for use in all integration tests PARTIAL FIX: - tests/integration/api.auth.test.js - Updated to connect both DBs - Still investigating why tests hang (likely response field mismatch) NEXT SESSION: 1. Apply db-test-helper to all 7 API integration tests 2. Fix response field mismatches (accessToken vs token) 3. Verify all tests pass IMPACT: Test helper provides pattern for fixing all integration tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
/**
|
|
* Minimal Integration Test - Diagnostic
|
|
*/
|
|
|
|
const request = require('supertest');
|
|
const mongoose = require('mongoose');
|
|
const config = require('../../src/config/app.config');
|
|
|
|
console.log('1. Test file loading...');
|
|
|
|
describe('Minimal Test', () => {
|
|
beforeAll(async () => {
|
|
console.log('2. beforeAll starting...');
|
|
if (mongoose.connection.readyState === 0) {
|
|
console.log('3. Connecting to MongoDB...', config.mongodb.uri);
|
|
await mongoose.connect(config.mongodb.uri);
|
|
console.log('4. MongoDB connected');
|
|
}
|
|
});
|
|
|
|
afterAll(async () => {
|
|
console.log('5. afterAll - disconnecting...');
|
|
await mongoose.disconnect();
|
|
console.log('6. Disconnected');
|
|
});
|
|
|
|
test('should connect to database', () => {
|
|
console.log('7. Running test...');
|
|
expect(mongoose.connection.readyState).toBe(1);
|
|
console.log('8. Test complete');
|
|
});
|
|
|
|
test('should make a simple request', async () => {
|
|
console.log('9. Importing app...');
|
|
const app = require('../../src/server');
|
|
console.log('10. App imported');
|
|
|
|
console.log('11. Making request...');
|
|
const response = await request(app)
|
|
.get('/api/health')
|
|
.timeout(5000);
|
|
console.log('12. Response received:', response.status);
|
|
|
|
expect(response.status).toBe(404);
|
|
});
|
|
});
|