-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
134 lines (113 loc) · 3.28 KB
/
Copy pathjest.config.js
File metadata and controls
134 lines (113 loc) · 3.28 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
const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
// Test environment
testEnvironment: 'jsdom',
// Setup files
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// Test patterns
testMatch: [
'**/__tests__/**/*.(ts|tsx|js)',
'**/*.(test|spec).(ts|tsx|js)',
'**/tests/**/*.(test|spec).(ts|tsx|js)'
],
// Exclude Playwright E2E tests from Jest
testPathIgnorePatterns: [
'<rootDir>/.next/',
'<rootDir>/node_modules/',
'<rootDir>/e2e/',
'<rootDir>/test-results/',
'<rootDir>/playwright-report/'
],
// Module name mapping for absolute imports
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
// Coverage configuration - Enhanced
collectCoverageFrom: [
'app/**/*.{js,ts,tsx}',
'components/**/*.{js,ts,tsx}',
'lib/**/*.{js,ts,tsx}',
'hooks/**/*.{js,ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!**/.next/**',
'!**/coverage/**',
'!**/*.config.{js,ts}',
'!**/middleware.ts',
'!app/layout.tsx',
'!app/page.tsx',
'!app/globals.css',
'!**/*.stories.{js,ts,tsx}',
'!**/storybook/**',
'!**/dist/**',
'!**/build/**',
'!**/.vscode/**',
'!**/.github/**',
],
// Enhanced coverage thresholds with realistic progression levels - TEMPORARILY DISABLED FOR CI/CD
// TODO: Re-enable with achievable thresholds after test coverage is improved
// coverageThreshold: {
// global: {
// branches: 20,
// functions: 25,
// lines: 25,
// statements: 25,
// },
// // Higher thresholds for critical utilities that already have tests
// 'lib/utils/ticket-utils.ts': {
// branches: 75,
// functions: 85,
// lines: 85,
// statements: 85,
// },
// 'lib/utils/eventFilters.ts': {
// branches: 60,
// functions: 65,
// lines: 70,
// statements: 70,
// },
// },
// Enhanced coverage reporters with detailed outputs
coverageReporters: [
'text',
'text-summary',
'lcov',
'html',
'json-summary',
'json',
'cobertura', // For CI/CD integration
'clover', // For historical tracking
['lcov', { projectRoot: process.cwd() }]
],
// Coverage directory structure
coverageDirectory: 'coverage',
// Test timeout
testTimeout: 10000,
// Transform ignore patterns
transformIgnorePatterns: [
'/node_modules/',
'^.+\\.module\\.(css|sass|scss)$',
],
// Module file extensions
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
// Verbose output for detailed test information
verbose: true,
// Clear mocks between tests
clearMocks: true,
// Restore mocks after each test
restoreMocks: true,
// Enhanced test result processing - removed processor file during cleanup
// Report slow tests
slowTestThreshold: 5,
// Maximum number of workers
maxWorkers: '50%',
// Fail tests on console errors (optional - can be disabled if too strict)
// silent: false,
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)