-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
66 lines (53 loc) · 1.64 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module.exports = {
// Indicates that this is a TypeScript project
preset: 'ts-jest',
// Sets the test environment. 'node' is appropriate for backend projects
testEnvironment: 'node',
// Defines where Jest should look for files
roots: ['<rootDir>/src', '<rootDir>/tests'],
// Defines the pattern for test files
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/?(*.)+(spec|test).+(ts|tsx|js)'
],
// Configures the TypeScript transformer
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
// Sets up module name mapping for easier imports
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
// Configures coverage collection
collectCoverageFrom: [
'src/**/*.{js,ts}',
'!src/**/*.d.ts',
'!src/index.ts',
],
// Sets the coverage threshold
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
// Defines where to output coverage reports
coverageDirectory: 'coverage',
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// Files to run before tests are executed
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
// Sets the maximum number of workers to 4
maxWorkers: 4,
// Allows for use of modern ECMAScript features
globals: {
'ts-jest': {
useESM: true,
},
},
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
};