adding monkeytype
Some checks failed
Mark Stale PRs / stale (push) Has been cancelled

This commit is contained in:
Benjamin Falch
2026-04-23 13:53:44 +02:00
parent e214a2fd35
commit 2bc741fb78
1930 changed files with 7590652 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import { afterAll, beforeAll, afterEach, vi } from "vitest";
import { Collection, Db, MongoClient, WithId } from "mongodb";
import { setupCommonMocks } from "../setup-common-mocks";
import { getConnection } from "../../src/init/redis";
process.env["MODE"] = "dev";
let db: Db;
let client: MongoClient;
beforeAll(async () => {
client = new MongoClient(process.env["TEST_DB_URL"] as string);
await client.connect();
db = client.db();
vi.mock("../../src/init/db", () => ({
__esModule: true,
getDb: (): Db => db,
collection: <T>(name: string): Collection<WithId<T>> =>
db.collection<WithId<T>>(name),
close: () => {
//
},
}));
setupCommonMocks();
//we compare the time in mongodb to calculate premium status, so we have to use real time here
vi.useRealTimers();
});
afterEach(async () => {
//nothing
});
afterAll(async () => {
await client?.close();
// @ts-ignore
db = undefined;
//@ts-ignore
client = undefined;
await getConnection()?.quit();
vi.resetAllMocks();
});