anyone knows a solution to get rid of my errors?
import {createApp} from "@/app";
import mongoose from "@/database/mongoose";
describe("GET /api/user", () => {
beforeAll(async () => {
await mongoose.run()
const con = await mongoose.connection()
const app = createApp(con);
})
//
afterAll(async () => {
//Problem here!
await mongoose.stop()
// server.close();
})
it("should return a user", async () => {
// const res = await supertest(app).get("/api/user");
// expect(res.statusCode).toBe(200);
expect(1).toBeGreaterThan(0);
});
});
if I dont use the await mongose.stop(); i get this error
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● TCPWRAP
8 | try {
9 | if (process.env.NODE_ENV === "test") {
> 10 | return await connect(process.env.MONGO_URI_TEST)
| ^
11 |
12 | }
13 | return await connect(process.env.MONGO_DASHBOARD_URI)
