Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
130 lines (107 loc) · 3 KB
/
Copy pathjest.config.js
File metadata and controls
130 lines (107 loc) · 3 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
module.exports = {
displayName: 'StrellerMinds Backend',
preset: 'ts-jest',
testEnvironment: 'node',
// Root directory
rootDir: '.',
// Test file patterns
testMatch: [
'<rootDir>/src/**/*.spec.ts',
'<rootDir>/src/**/*.test.ts',
'<rootDir>/test/**/*.spec.ts',
'<rootDir>/test/**/*.test.ts',
'<rootDir>/test/integration/**/*.spec.ts',
'<rootDir>/test/integration/**/*.test.ts',
],
// Ignore patterns
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/dist/', '<rootDir>/test/e2e/', '<rootDir>/cypress/'],
// Module name mapping for path aliases
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@test/(.*)$': '<rootDir>/test/$1',
'^src/(.*)$': '<rootDir>/src/$1',
'^uuid$': '<rootDir>/node_modules/uuid/dist/index.js',
'^uuid/(.*)$': '<rootDir>/node_modules/uuid/dist/$1',
},
// Setup files
setupFilesAfterEnv: ['<rootDir>/test/jest.setup.ts'],
// Transform configuration
transform: {
'^.+\\.ts$': [
'ts-jest',
{
tsconfig: 'tsconfig.spec.json',
isolatedModules: false,
},
],
// Transform ESM .js files from node_modules that need CJS conversion
'^.+\\.js$': [
'ts-jest',
{
tsconfig: 'tsconfig.spec.json',
isolatedModules: true,
},
],
},
// Transform ignore patterns — un-ignore ESM-only packages in node_modules
transformIgnorePatterns: [
'node_modules/(?!(@nestjs/typeorm|typeorm|uuid|@nestjs/axios|axios|ioredis|@nestjs-modules/ioredis))',
],
// Coverage configuration
collectCoverage: false, // Enable with --coverage flag
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.spec.ts',
'!src/**/*.test.ts',
'!src/**/*.interface.ts',
'!src/**/*.dto.ts',
'!src/**/*.entity.ts',
'!src/**/*.enum.ts',
'!src/**/*.constant.ts',
'!src/**/*.config.ts',
'!src/main.ts',
'!src/**/*.module.ts',
'!src/migrations/**',
'!src/seeds/**',
],
coverageDirectory: '<rootDir>/coverage',
coverageReporters: ['text', 'text-summary', 'html', 'lcov', 'json', 'json-summary', 'cobertura'],
// Coverage thresholds
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
// Test timeout
testTimeout: 10000,
// Force exit after all tests complete
forceExit: true,
// Detect open handles
detectOpenHandles: true,
// Parallel execution
maxWorkers: '50%',
// Cache configuration
cache: true,
cacheDirectory: '<rootDir>/.jest-cache',
// Clear mocks between tests
clearMocks: true,
restoreMocks: true,
resetMocks: false,
// Verbose output
verbose: false,
// Error handling
bail: false,
// Module file extensions
moduleFileExtensions: ['js', 'json', 'ts'],
// Test environment options
testEnvironmentOptions: {
NODE_ENV: 'test',
},
// Reporters
reporters: ['default'],
// Watch mode configuration
watchPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/dist/', '<rootDir>/coverage/'],
};