Skip to content

Commit

Permalink
feat: await disconnect when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphclue committed Feb 3, 2024
1 parent 642da20 commit 51708d5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/backend/src/utils/mongo-util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {MongooseModule, MongooseModuleOptions} from '@nestjs/mongoose';
import {MongoMemoryServer} from 'mongodb-memory-server';
import {disconnect} from 'mongoose';

let mongoMemoryServer: MongoMemoryServer;

Expand All @@ -15,6 +16,7 @@ export const rootMongooseTestModule = (options: MongooseModuleOptions = {}) => M
});

export const closeMongoConnection = async () => {
await disconnect();
if (mongoMemoryServer) {
await mongoMemoryServer.stop();
}
Expand Down

0 comments on commit 51708d5

Please sign in to comment.