forked from Divineifed1/StrellerMinds-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
153 lines (133 loc) · 3.05 KB
/
jest.config.js
File metadata and controls
153 lines (133 loc) · 3.05 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const { pathsToModuleNameMapper } = require('ts-jest');
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/unit/**/*.spec.ts',
'<rootDir>/test/integration/**/*.spec.ts',
'<rootDir>/apps/backend/tests/contract/**/*.test.ts',
],
// Ignore patterns
testPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/dist/',
'<rootDir>/test/e2e/',
],
// Module name mapping for path aliases
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@test/(.*)$': '<rootDir>/test/$1',
'^src/(.*)$': '<rootDir>/src/$1',
},
// Setup files
setupFilesAfterEnv: [
'<rootDir>/test/setup/jest.setup.ts',
],
// Transform configuration
transform: {
'^.+\\.(t|j)s$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
isolatedModules: true,
},
],
},
// 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: 30000,
// 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,
errorOnDeprecated: true,
// Module file extensions
moduleFileExtensions: ['js', 'json', 'ts'],
// Test environment options
testEnvironmentOptions: {
NODE_ENV: 'test',
},
// Reporters
reporters: [
'default',
[
'jest-html-reporters',
{
publicPath: './coverage/html-report',
filename: 'test-report.html',
expand: true,
hideIcon: false,
pageTitle: 'StrellerMinds Test Report',
inlineSource: false,
},
],
[
'jest-junit',
{
outputDirectory: './coverage',
outputName: 'junit.xml',
ancestorSeparator: ' › ',
uniqueOutputName: 'false',
suiteNameTemplate: '{filepath}',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
},
],
],
// Watch mode configuration
watchPathIgnorePatterns: [
'<rootDir>/node_modules/',
'<rootDir>/dist/',
'<rootDir>/coverage/',
],
};