-
Notifications
You must be signed in to change notification settings - Fork 56
/
jest.config.js
43 lines (39 loc) · 1.14 KB
/
jest.config.js
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
// jest.config.js
const nextJest = require("next/jest");
const createJestConfig = nextJest({
dir: "./",
});
const customJestConfig = {
collectCoverage: false,
coverageDirectory: "coverage",
moduleDirectories: ["node_modules", "<rootDir>/"],
moduleNameMapper: { "^@/(.*)$": "<rootDir>/src/$1" },
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/e2e/"],
testEnvironment: "jest-environment-jsdom",
setupFilesAfterEnv: ["./jest.setup.ts"],
reporters: [
"default",
[
"jest-html-reporters",
{
publicPath: "__reports__",
filename: "jest.html",
},
],
],
};
// FYI: https://github.com/vercel/next.js/issues/36230
// FYI: https://github.com/vercel/next.js/issues/35634#issuecomment-1080942525
async function jestConfig() {
const nextJestConfig = await createJestConfig(customJestConfig)();
return {
...nextJestConfig,
transformIgnorePatterns: [`/node_modules/(?!${["uuid"].join("|")})`],
moduleNameMapper: {
"\\.(gif|ttf|eot|svg)$": "<rootDir>/jest.fileMock.js",
...nextJestConfig.moduleNameMapper,
},
};
}
module.exports = jestConfig;