-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.config.ts
50 lines (39 loc) · 1.65 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
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/
import type { Config } from "jest";
import nextJest from "next/jest.js";
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 config: Config = {
setupFiles: ["./jest.polyfills.js"],
collectCoverage: true,
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "scripts/*.{mjs,js,jsx,ts,tsx}", "!<rootDir>/node_modules/", "!src/generatePrivateRoutes.ts"],
coverageDirectory: "coverage",
coveragePathIgnorePatterns: ["/node_modules/"],
coverageProvider: "v8",
moduleDirectories: ["node_modules"],
modulePathIgnorePatterns: [
// Testing auth with `next-auth` complains (consider switching to Vitest)
// Doesn't seem to have a proper solution. See https://github.com/nextauthjs/next-auth/issues/4198.
"src/auth.ts",
// Middleware can't be properly mocked to test.
"src/middleware.ts",
// No need to unit test types
"src/types.ts",
// The "_app.ts" runs on every page and can't be properly tested. There's no need to, regardless.
"src/pages/_app.ts",
// The `app` folder is only used to export the default handlers from `next-auth`.
"src/app",
],
moduleNameMapper: {
"next-auth/(.*)": "<rootDir>/node_modules/next-auth/$1",
"^uuid$": require.resolve("uuid"), // See https://github.com/uuidjs/uuid/issues/451#issuecomment-1377066303.
},
testEnvironment: "jsdom",
testPathIgnorePatterns: ["tests/e2e", "tests/unit/link-check.test.ts"],
};
export default createJestConfig(config);