-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.cjs
46 lines (38 loc) · 1.31 KB
/
jest.config.cjs
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
module.exports = {
// Specify the environment for testing
testEnvironment: "jest-environment-jsdom",
// Automatically setup testing library after each test environment is set up
// setupFilesAfterEnv: ["<rootDir>/src/setupTests.js"],
// Enable code coverage collection
collectCoverage: true,
// Specify directories and files to ignore for coverage
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts", // Ignore TypeScript declaration files
"!src/index.tsx", // Ignore main entry file
"!src/serviceWorker.ts", // Ignore service worker setup
"!src/setupTests.js", // Ignore setupTests file
],
// Output directory for coverage reports
coverageDirectory: "coverage",
// Coverage thresholds (optional but recommended for Codecov)
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
// Module file extensions for importing
moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
// Module name mapper for CSS modules and static assets
moduleNameMapper: {
"\\.(css|scss)$": "identity-obj-proxy",
"\\.(jpg|jpeg|png|gif|svg)$": "<rootDir>/src/__mocks__/fileMock.js",
},
// Paths to transform with Babel or ts-jest for TypeScript
transform: {
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
},
};