Skip to content

Commit 7069630

Browse files
committed
🚧 testing woes
1 parent 82128f2 commit 7069630

File tree

8 files changed

+1302
-290
lines changed

8 files changed

+1302
-290
lines changed

‎apps/api/app/config/test-utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export async function setupForTest() {
2424
}
2525

2626
export async function teardownForTest() {
27-
server.close();
27+
server?.close();
28+
server = undefined;
2829
await mongoose.connection.db.dropDatabase();
2930
await mongoose.connection.close();
3031
}

‎apps/api/app/models/gamenotification.spec.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import mongoose, { Types } from "mongoose";
22
import { defaultKarma, Game, GameNotification, GamePreferences, maxKarma, User } from "./index";
33
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
4+
import { setupForTest, teardownForTest } from "../config/test-utils";
45

56
const { ObjectId } = Types;
67

78
describe("GameNotification", () => {
9+
beforeAll(async () => {
10+
await setupForTest();
11+
});
12+
afterAll(async () => {
13+
await teardownForTest();
14+
});
815
const userId = new ObjectId();
916
const userId2 = new ObjectId();
1017
const userId3 = new ObjectId();
@@ -13,8 +20,6 @@ describe("GameNotification", () => {
1320
describe("processGameEnded", () => {
1421
describe("karma", () => {
1522
beforeAll(async () => {
16-
await mongoose.connection.db.dropDatabase();
17-
1823
await User.create({ _id: userId, account: { username: "test", email: "[email protected]" } });
1924
await User.create({ _id: userId2, account: { username: "test2", email: "[email protected]" } });
2025
await Game.create({

‎apps/api/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"lodash": "^4.17.13",
2727
"mailgun-js": "^0.20.0",
2828
"mongo-locks": "^2.0.0",
29-
"mongoose": "6.0.3",
3029
"node-cache": "^5.1.0",
3130
"passport-discord": "^0.1.4",
3231
"passport-facebook": "^3.0.0",

‎apps/api/pnpm-lock.yaml

-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"eslint-config-prettier": "^9.0.0",
1616
"eslint-plugin-prettier": "^4.2.1",
1717
"eslint-plugin-svelte": "^2.30.0",
18+
"mongoose": "^6.1.0",
1819
"prettier": "^3.1.0",
1920
"prettier-plugin-svelte": "^3.1.2",
2021
"svelte": "^4.0.0",

‎packages/models/package.json

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
"name": "@bgs/models",
44
"dependencies": {
55
"@bgs/types": "workspace:*"
6-
},
7-
"peerDependencies": {
8-
"mongoose": "6.0.3"
96
}
107
}

‎packages/models/pnpm-lock.yaml

-184
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)