generated from truonghungit/react-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
50 lines (41 loc) · 1.88 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
module.exports = {
// A list of paths to directories that Jest should use to search for files in
// https://jestjs.io/docs/configuration#roots-arraystring
roots: ["<rootDir>/src/"],
// The test environment that will be used for testing, jsdom for browser environment
// https://jestjs.io/docs/configuration#testenvironment-string
testEnvironment: "jsdom",
// Jest transformations
// https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object
transform: {
"^.+\\.tsx?$": "ts-jest", // Transform TypeScript files using ts-jest
},
// A list of paths to modules that run some code to configure or set up the testing framework before each test file in the suite is executed
// https://jestjs.io/docs/configuration#setupfilesafterenv-array
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
// Code coverage config
// https://jestjs.io/docs/configuration#collectcoveragefrom-array
coverageDirectory: "<rootDir>/coverage/",
collectCoverageFrom: [
"<rootDir>/src/**/*.{ts,tsx}",
"!**/__mocks__/**",
"!**/node_modules/**",
"!**/*.d.ts",
],
// Important: order matters, specific rules should be defined first
// https://jestjs.io/fr/docs/configuration#modulenamemapper-objectstring-string--arraystring
moduleNameMapper: {
// Handle CSS imports (with CSS modules)
// https://jestjs.io/docs/webpack#mocking-css-modules
"^.+\\.module\\.(css|sass|scss|less)$": "identity-obj-proxy",
// Handle CSS imports (without CSS modules)
"^.+\\.(css|sass|scss|less)$": "<rootDir>/__mocks__/styleMock.js",
// Handle static assets
// https://jestjs.io/docs/webpack#handling-static-assets
"^.+\\.(jpg|jpeg|png|gif|webp|avif|svg|ttf|woff|woff2)$": `<rootDir>/__mocks__/fileMock.js`,
// Handle TypeScript path aliases
"^@/(.*)$": "<rootDir>/src/$1",
},
verbose: true,
testTimeout: 30000,
};