diff --git a/backend/__tests__/global-setup.ts b/backend/__tests__/global-setup.ts index 573bff62c..64c96042a 100644 --- a/backend/__tests__/global-setup.ts +++ b/backend/__tests__/global-setup.ts @@ -1,15 +1,17 @@ import * as MongoDbMock from "vitest-mongodb"; export async function setup(): Promise { process.env.TZ = "UTC"; - await MongoDbMock.setup({ - serverOptions: { - binary: { - version: "6.0.12", - }, - }, - }); + await MongoDbMock.setup(MongoDbMockConfig); } export async function teardown(): Promise { await MongoDbMock.teardown(); } + +export const MongoDbMockConfig = { + serverOptions: { + binary: { + version: "6.0.12", + }, + }, +}; diff --git a/backend/__tests__/setup-tests.ts b/backend/__tests__/setup-tests.ts index 5d267700c..0a1f16757 100644 --- a/backend/__tests__/setup-tests.ts +++ b/backend/__tests__/setup-tests.ts @@ -1,6 +1,7 @@ import { Collection, Db, MongoClient, WithId } from "mongodb"; import { afterAll, beforeAll, afterEach } from "vitest"; import * as MongoDbMock from "vitest-mongodb"; +import { MongoDbMockConfig } from "./global-setup"; process.env["MODE"] = "dev"; //process.env["MONGOMS_DISTRO"] = "ubuntu-22.04"; @@ -15,9 +16,8 @@ let client: MongoClient; const collectionsForCleanUp = ["users"]; beforeAll(async () => { - await MongoDbMock.setup({ - //don't add any configuration here, add to global-setup.ts instead. - }); + //don't add any configuration here, add to global-setup.ts instead. + await MongoDbMock.setup(MongoDbMockConfig); client = new MongoClient(globalThis.__MONGO_URI__); await client.connect();