Skip to content

Commit 8d788ff

Browse files
committed
fix: resolve hanging jest tests by closing redis connection
- Added redis.quit() to afterAll hook in backend/tests/auth.test.js to ensure proper teardown - Fixes issue where Jest would not exit after tests completed
1 parent a69c500 commit 8d788ff

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

backend/tests/auth.test.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ const request = require('supertest');
22
const mongoose = require('mongoose');
33

44
const JWT_SECRET =
5-
process.env.JWT_SECRET ||
6-
(process.env.NODE_ENV === "test" ? "ci_test_jwt_secret" : null);
5+
process.env.JWT_SECRET ||
6+
(process.env.NODE_ENV === "test" ? "ci_test_jwt_secret" : null);
77

88
if (!JWT_SECRET) {
9-
throw new Error("JWT_SECRET is not defined");
9+
throw new Error("JWT_SECRET is not defined");
1010
}
1111

1212

@@ -43,8 +43,11 @@ beforeAll(async () => {
4343
await mongoose.connect(uri);
4444
});
4545

46+
const redis = require('../config/redis'); // Import redis client
47+
4648
afterAll(async () => {
4749
await mongoose.connection.close();
50+
await redis.quit(); // Close Redis connection
4851
});
4952

5053
describe('Auth API Security', () => {

0 commit comments

Comments
 (0)