-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathjest.config.js
More file actions
121 lines (99 loc) · 2.75 KB
/
jest.config.js
File metadata and controls
121 lines (99 loc) · 2.75 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
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/', '<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',
},
// Setup files
setupFilesAfterEnv: ['<rootDir>/test/setup/jest.setup.ts'],
// Transform configuration
transform: {
'^.+\\.ts$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
isolatedModules: false,
},
],
},
// Transform ignore patterns
transformIgnorePatterns: [
'node_modules/(?!(@nestjs/typeorm|typeorm|uuid))',
],
// 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
// Temporarily disable coverage thresholds until tests are stable
// 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,
errorOnDeprecated: true,
// 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/'],
};