Skip to content

Commit e16246d

Browse files
committed
feat(api): migrate tests from jest to vitest and update test setup
- replace jest with vitest in test files - update test setup to use global test app instance - add clearDatabase and fastifyInstance helper functions for testing - implement vitest configuration for testing environment
1 parent eaa5736 commit e16246d

File tree

63 files changed

+9225
-11462
lines changed

Some content is hidden

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

63 files changed

+9225
-11462
lines changed

package-lock.json

Lines changed: 8731 additions & 11123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/reva-api/eslint.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ export default defineConfig([
5252
2,
5353
{
5454
unusedExports: true,
55-
ignoreExports: ["eslint.config.mjs", "codegen.ts"],
55+
ignoreExports: [
56+
"eslint.config.mjs",
57+
"codegen.ts",
58+
"test/*.ts",
59+
"vitest.global-setup.ts",
60+
"vitest.setup.ts",
61+
"vitest.config.mts",
62+
],
5663
},
5764
],
5865

packages/reva-api/jest.config.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/reva-api/modules/candidacy/candidacy.canAccessCandidacy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createCertificationAuthorityHelper } from "@/test/helpers/entities/crea
99
import { createCertificationAuthorityLocalAccountHelper } from "@/test/helpers/entities/create-certification-authority-local-account-helper";
1010
import { createFeasibilityDematerializedHelper } from "@/test/helpers/entities/create-feasibility-dematerialized-helper";
1111
import { createOrganismHelper } from "@/test/helpers/entities/create-organism-helper";
12-
import { getGraphQLClient } from "@/test/jestGraphqlClient";
12+
import { getGraphQLClient } from "@/test/test-graphql-client";
1313

1414
import { graphql } from "../graphql/generated";
1515

packages/reva-api/modules/candidacy/candidacy.getCandidacies.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { authorizationHeaderForUser } from "@/test/helpers/authorization-helper"
44
import { createCandidacyHelper } from "@/test/helpers/entities/create-candidacy-helper";
55
import { createOrganismHelper } from "@/test/helpers/entities/create-organism-helper";
66
import { createCohorteVaeCollectiveHelper } from "@/test/helpers/entities/create-vae-collective-helper";
7-
import { getGraphQLClient } from "@/test/jestGraphqlClient";
7+
import { getGraphQLClient } from "@/test/test-graphql-client";
88

99
import { graphql } from "../graphql/generated";
1010

packages/reva-api/modules/candidacy/candidacy.status-count.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createCandidacyHelper } from "@/test/helpers/entities/create-candidacy-
77
import { createCandidateHelper } from "@/test/helpers/entities/create-candidate-helper";
88
import { createJuryHelper } from "@/test/helpers/entities/create-jury-helper";
99
import { createOrganismHelper } from "@/test/helpers/entities/create-organism-helper";
10-
import { getGraphQLClient } from "@/test/jestGraphqlClient";
10+
import { getGraphQLClient } from "@/test/test-graphql-client";
1111

1212
import { graphql } from "../graphql/generated";
1313

packages/reva-api/modules/candidacy/candidacy.take-over.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CandidacyStatusStep } from "@prisma/client";
22

33
import { authorizationHeaderForUser } from "@/test/helpers/authorization-helper";
44
import { createCandidacyHelper } from "@/test/helpers/entities/create-candidacy-helper";
5-
import { getGraphQLClient, getGraphQLError } from "@/test/jestGraphqlClient";
5+
import { getGraphQLClient, getGraphQLError } from "@/test/test-graphql-client";
66

77
import { graphql } from "../graphql/generated";
88

packages/reva-api/modules/candidacy/candidacy.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { prismaClient } from "@/prisma/client";
22
import { authorizationHeaderForUser } from "@/test/helpers/authorization-helper";
33
import { createCandidacyHelper } from "@/test/helpers/entities/create-candidacy-helper";
44
import { createCandidateHelper } from "@/test/helpers/entities/create-candidate-helper";
5-
import { getGraphQLClient, getGraphQLError } from "@/test/jestGraphqlClient";
5+
import { getGraphQLClient, getGraphQLError } from "@/test/test-graphql-client";
66

77
import { graphql } from "../graphql/generated";
88
import * as getKeycloakAdminModule from "../shared/auth/getKeycloakAdmin";
@@ -131,15 +131,13 @@ test("a candidate can modify all his account information", async () => {
131131
email: "updated@email.com",
132132
};
133133

134-
jest
135-
.spyOn(getKeycloakAdminModule, "getKeycloakAdmin")
136-
.mockImplementation(() =>
137-
Promise.resolve({
138-
users: {
139-
update: jest.fn().mockResolvedValue({}),
140-
},
141-
} as any),
142-
);
134+
vi.spyOn(getKeycloakAdminModule, "getKeycloakAdmin").mockImplementation(() =>
135+
Promise.resolve({
136+
users: {
137+
update: vi.fn().mockResolvedValue({}),
138+
},
139+
} as any),
140+
);
143141

144142
const graphqlClient = getGraphQLClient({
145143
headers: {

packages/reva-api/modules/candidacy/candidacy.type-accompagnement.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CandidacyStatusStep } from "@prisma/client";
22

33
import { authorizationHeaderForUser } from "@/test/helpers/authorization-helper";
44
import { createCandidacyHelper } from "@/test/helpers/entities/create-candidacy-helper";
5-
import { getGraphQLClient, getGraphQLError } from "@/test/jestGraphqlClient";
5+
import { getGraphQLClient, getGraphQLError } from "@/test/test-graphql-client";
66

77
import { graphql } from "../graphql/generated";
88

packages/reva-api/modules/candidacy/candidacy.updateCandidateCandidacyDropoutDecision.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { authorizationHeaderForUser } from "@/test/helpers/authorization-helper";
22
import { createCandidacyDropOutHelper } from "@/test/helpers/entities/create-candidacy-drop-out-helper";
3-
import { getGraphQLClient, getGraphQLError } from "@/test/jestGraphqlClient";
3+
import { getGraphQLClient, getGraphQLError } from "@/test/test-graphql-client";
44

55
import { graphql } from "../graphql/generated";
66

@@ -9,14 +9,14 @@ import * as SendCandidacyDropOutConfirmedEmailToCandidateModule from "./emails/s
99

1010
describe("candidate drop out decision", () => {
1111
test("should mark the drop out as confirmed when the candidate confirms it and sent an email to the aap", async () => {
12-
const sendCandidacyDropOutConfirmedEmailToAapSpy = jest
12+
const sendCandidacyDropOutConfirmedEmailToAapSpy = vi
1313
.spyOn(
1414
SendCandidacyDropOutConfirmedEmailToAapModule,
1515
"sendCandidacyDropOutConfirmedEmailToAap",
1616
)
1717
.mockImplementation(() => Promise.resolve());
1818

19-
const sendCandidacyDropOutConfirmedEmailToCandidateSpy = jest
19+
const sendCandidacyDropOutConfirmedEmailToCandidateSpy = vi
2020
.spyOn(
2121
SendCandidacyDropOutConfirmedEmailToCandidateModule,
2222
"sendCandidacyDropOutConfirmedEmailToCandidate",

0 commit comments

Comments
 (0)