-
Notifications
You must be signed in to change notification settings - Fork 13
/
jest.config.ts
56 lines (52 loc) · 1.72 KB
/
jest.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
46
47
48
49
50
51
52
53
54
55
56
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
import nextJest from "next/jest.js";
import { pathsToModuleNameMapper } from "ts-jest";
import type { Config } from "jest";
import { compilerOptions } from "./tsconfig.json";
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});
const customJestConfig: Config = {
workerIdleMemoryLimit: "1G",
testPathIgnorePatterns: [
"<rootDir>/cypress/",
"<rootDir>/public/static/scripts/",
"<rootDir>/.next/",
"<rootDir>/node_modules/",
"<rootDir>/__utils__/",
"<rootDir>/__fixtures__/",
"<rootDir>/__tests__/",
"<rootDir>/lib/vitests/",
],
testMatch: ["/**/*.test.+(ts|tsx|js|jsx)"],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: "<rootDir>/",
}),
"^next-auth(/?.*)$": "<rootDir>/__utils__/mocks/next-auth",
"^lib/auth/nextAuth$": "<rootDir>/__utils__/mocks/nextAuth",
"^file-type$": "<rootDir>/__utils__/mocks/file-type",
},
moduleDirectories: ["node_modules", "<rootDir>"],
clearMocks: true,
setupFiles: [
"<rootDir>/__utils__/jestShim.ts",
"<rootDir>/__utils__/mocks/server-actions/index.ts",
"<rootDir>/__utils__/mocks/redis/index.ts",
],
setupFilesAfterEnv: [
"<rootDir>/__utils__/setupTests.ts",
"<rootDir>/__utils__/prismaConnector.ts",
],
testEnvironment: "node",
preset: "ts-jest",
};
const jestConfig = async () => ({
...(await createJestConfig(customJestConfig)()),
transformIgnorePatterns: ["/node_modules/(?!(next-auth|@auth)/)"],
});
export default jestConfig;