-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
52 lines (49 loc) · 1.72 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
44
45
46
47
48
49
50
51
52
const nextJest = require("next/jest");
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});
// Add any custom config to be passed to Jest
const customJestConfig = {
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
moduleNameMapper: {
// Handle module aliases (this will be automatically configured for you soon)
"^@/components(.*)$": "<rootDir>/components/$1",
"^@/data": "<rootDir>/data/$1",
"^@/lib(.*)$": "<rootDir>/lib/$1",
"^@/hooks": "<rootDir>/hooks/index.ts",
"^@/themes": "<rootDir>/themes/index.ts",
"^@/utils(.*)$": "<rootDir>/utils/$1",
"^@/test-utils": "<rootDir>/test-utils/index.ts",
"^@/interfaces": "<rootDir>/interfaces/index.ts",
"^@/pages(.*)$": "<rootDir>/pages/$1",
"^@/config": "<rootDir>/config/index.ts",
},
testEnvironment: "jest-environment-jsdom",
// Esperamos cobertura de todos los archivos js, jsx, ts y tsx.
// Excluimos la cobertura de los mocks de MSW (opcional) y de los índices.
collectCoverageFrom: [
"**/*.{ts,tsx}",
"!themes",
"!node_modules",
"!.next",
"!**/index.ts",
"!**/styles.ts",
],
// Imponemos un mínimo del 70% de cobertura en las diferentes categorías de prueba.
coverageThreshold: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70,
},
"./components/ui/Header/": {
functions: 66,
},
},
// Esperamos recibir el resultado como texto en el terminal.
coverageReporters: ["text"],
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig);