-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
jest.api.config.ts
45 lines (37 loc) · 926 Bytes
/
jest.api.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import type { JestConfigWithTsJest } from "ts-jest";
import nextJest from "next/jest.js";
const nextConfig = {
dir: "./", // Path to your Next.js app
};
const baseConfig: JestConfigWithTsJest = {
clearMocks: true,
coverageProvider: "v8",
preset: "ts-jest/presets/js-with-ts",
transform: {
"^.+\\.mjs$": "ts-jest",
},
};
const filesConfig = {
setupFiles: ["dotenv/config"],
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
};
const moduleConfig = {
moduleNameMapper: {
"^~/(.*)$": "<rootDir>/src/$1",
},
};
const testConfig = {
testMatch: [
"**/server/api/__tests__/**/*.test.ts",
"**/pages/api/__tests__/**/*.test.ts",
],
};
const jestConfig: JestConfigWithTsJest = {
...baseConfig,
...filesConfig,
...moduleConfig,
...testConfig,
};
const createJestConfig = nextJest(nextConfig);
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
export default createJestConfig(jestConfig as any);