Skip to content

Commit 119649b

Browse files
fehmerMiodec
andauthored
test: don't use globals for vitest (@fehmer) (monkeytypegame#6871)
- **test: support to run/watch all tests in vscode (@fehmer)** - **packages/contracts** - **move schema tests to schema package** - **packages/funbox** - **packages/utils** - **frontend** - **backend** --------- Co-authored-by: Miodec <[email protected]>
1 parent 8fe0e65 commit 119649b

File tree

88 files changed

+131
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+131
-39
lines changed

backend/__tests__/__integration__/__migration__/testActivity.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import * as Migration from "../../../__migration__/testActivity";
23
import * as UserTestData from "../../__testData__/users";
34
import * as UserDal from "../../../src/dal/user";

backend/__tests__/__integration__/dal/admin-uids.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { ObjectId } from "mongodb";
23
import * as AdminUidsDal from "../../../src/dal/admin-uids";
34

backend/__tests__/__integration__/dal/ape-keys.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { ObjectId } from "mongodb";
23
import { addApeKey } from "../../../src/dal/ape-keys";
34

backend/__tests__/__integration__/dal/blocklist.spec.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import {
2+
describe,
3+
it,
4+
expect,
5+
beforeAll,
6+
beforeEach,
7+
afterEach,
8+
vi,
9+
} from "vitest";
110
import { ObjectId } from "mongodb";
211
import * as BlacklistDal from "../../../src/dal/blocklist";
312

@@ -7,15 +16,15 @@ describe("BlocklistDal", () => {
716
});
817
describe("add", () => {
918
beforeEach(() => {
10-
vitest.useFakeTimers();
19+
vi.useFakeTimers();
1120
});
1221
afterEach(() => {
13-
vitest.useRealTimers();
22+
vi.useRealTimers();
1423
});
1524
it("adds user", async () => {
1625
//GIVEN
1726
const now = 1715082588;
18-
vitest.setSystemTime(now);
27+
vi.setSystemTime(now);
1928

2029
const name = "user" + new ObjectId().toHexString();
2130
const email = `${name}@example.com`;
@@ -45,7 +54,7 @@ describe("BlocklistDal", () => {
4554
it("adds user with discordId", async () => {
4655
//GIVEN
4756
const now = 1715082588;
48-
vitest.setSystemTime(now);
57+
vi.setSystemTime(now);
4958

5059
const name = "user" + new ObjectId().toHexString();
5160
const email = `${name}@example.com`;
@@ -67,7 +76,7 @@ describe("BlocklistDal", () => {
6776
it("adds user should not create duplicate name", async () => {
6877
//GIVEN
6978
const now = 1715082588;
70-
vitest.setSystemTime(now);
79+
vi.setSystemTime(now);
7180

7281
const name = "user" + new ObjectId().toHexString();
7382
const email = `${name}@example.com`;
@@ -103,7 +112,7 @@ describe("BlocklistDal", () => {
103112
it("adds user should not create duplicate email", async () => {
104113
//GIVEN
105114
const now = 1715082588;
106-
vitest.setSystemTime(now);
115+
vi.setSystemTime(now);
107116

108117
const name = "user" + new ObjectId().toHexString();
109118
const email = `${name}@example.com`;
@@ -125,7 +134,7 @@ describe("BlocklistDal", () => {
125134
it("adds user should not create duplicate discordId", async () => {
126135
//GIVEN
127136
const now = 1715082588;
128-
vitest.setSystemTime(now);
137+
vi.setSystemTime(now);
129138

130139
const name = "user" + new ObjectId().toHexString();
131140
const name2 = "user" + new ObjectId().toHexString();

backend/__tests__/__integration__/dal/leaderboards.isolated.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, afterEach, vi } from "vitest";
12
import _ from "lodash";
23
import { ObjectId } from "mongodb";
34
import * as UserDal from "../../../src/dal/user";

backend/__tests__/__integration__/dal/preset.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import { ObjectId } from "mongodb";
23
import * as PresetDal from "../../../src/dal/preset";
34
import _ from "lodash";

backend/__tests__/__integration__/dal/public.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect } from "vitest";
12
import * as PublicDAL from "../../../src/dal/public";
23

34
describe("PublicDAL", function () {

backend/__tests__/__integration__/dal/result.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
12
import * as ResultDal from "../../../src/dal/result";
23
import { ObjectId } from "mongodb";
34
import * as UserDal from "../../../src/dal/user";

backend/__tests__/__integration__/dal/user.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, vi } from "vitest";
12
import _ from "lodash";
23
import * as UserDAL from "../../../src/dal/user";
34
import * as UserTestData from "../../__testData__/users";

backend/__tests__/__integration__/services/weekly-xp-leaderboard.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeAll, afterEach } from "vitest";
12
import * as WeeklyXpLeaderboard from "../../../src/services/weekly-xp-leaderboard";
23
import { Configuration } from "@monkeytype/schemas/configuration";
34
import { ObjectId } from "mongodb";

0 commit comments

Comments
 (0)