Skip to content

Commit 17f2bd0

Browse files
committed
Enable setting dbName in useTestDatabase() utility
This enables separate dbs (on the same db-server) for parralel tests.
1 parent deb055f commit 17f2bd0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/util/useTestDatabase.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ async function dropAllCollections(): Promise<void> {
2727
}
2828
}
2929

30-
export default function setupTestDatabase(): void {
30+
export default function useTestDatabase(dbName: string): void {
31+
if (!dbName) dbName = "test";
32+
3133
// Connect to Mongoose
3234
beforeAll(async () => {
3335
const url = process.env.MONGO_URL || "";
3436
const mongooseOptions = {
3537
useNewUrlParser: true,
36-
useUnifiedTopology: true
38+
useUnifiedTopology: true,
39+
dbName
3740
};
3841
await mongoose.connect(url, mongooseOptions);
3942
});

0 commit comments

Comments
 (0)