-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.cjs
More file actions
70 lines (58 loc) · 1.79 KB
/
jest.config.cjs
File metadata and controls
70 lines (58 loc) · 1.79 KB
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
67
68
69
70
/** @type {import('jest').Config} */
module.exports = {
testEnvironment: 'node',
// Test files location
testMatch: ['**/tests/**/*.test.[jt]s?(x)'],
// Test setup file (for env and DB)
setupFilesAfterEnv: ['<rootDir>/tests/setup.js'],
// Performance optimizations
maxWorkers: '50%', // Use 50% of available CPU cores for better performance
testTimeout: 30000, // 30 second timeout (reduced from default 5s for integration tests)
// Cache to speed up subsequent runs
cache: true,
cacheDirectory: '<rootDir>/.jest-cache',
// Coverage settings
collectCoverage: true,
collectCoverageFrom: [
// Backend source code paths
'controllers/**/*.js',
'services/**/*.js',
'middleware/**/*.js',
'models/**/*.js',
'routes/**/*.js',
'utils/**/*.js',
'config/**/*.js',
// Exclude test files and certain config files
'!config/seedData.js',
'!**/*.test.js',
'!**/tests/**'
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html'],
coverageThreshold: {
global: {
statements: 80,
branches: 80,
functions: 80,
lines: 80
}
},
// ESM support for Node 18 with "type": "module"
// Note: extensionsToTreatAsEsm is not needed when package.json has "type": "module"
// No transforms needed for plain JS ESM in Node 18
transform: {},
// Ignore patterns
testPathIgnorePatterns: ['/node_modules/'],
coveragePathIgnorePatterns: ['/node_modules/', '/tests/'],
// Optimize output
verbose: false,
silent: true,
// Bail early on failures in CI (optional, comment out for local dev)
bail: 1,
// Clear mocks automatically between tests
clearMocks: true,
resetMocks: false,
restoreMocks: true,
// Detect open handles (helps identify connection leaks)
// detectOpenHandles: true
};