-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
78 lines (66 loc) · 2.27 KB
/
jest.config.js
File metadata and controls
78 lines (66 loc) · 2.27 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
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: './apps/player',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// Test environment
testEnvironment: 'jsdom', // Use jsdom for component tests (default)
// Module path mapping for TypeScript imports
moduleNameMapper: {
'^next/image$': '<rootDir>/__mocks__/next-image.js',
'^@/(.*)$': '<rootDir>/apps/player/src/$1',
'^@tests/(.*)$': '<rootDir>/tests/$1',
'^@matchday/(.*)$': '<rootDir>/packages/$1/src',
},
// Test file patterns - now looking in the organized tests directory
testMatch: [
'<rootDir>/tests/**/*.{test,spec}.{js,jsx,ts,tsx}',
'<rootDir>/apps/**/src/**/*.{test,spec}.{js,jsx,ts,tsx}', // Keep for any remaining inline tests
],
// Coverage settings
collectCoverageFrom: [
'apps/player/src/**/*.{js,jsx,ts,tsx}',
'apps/admin/src/**/*.{js,jsx,ts,tsx}',
'packages/*/src/**/*.{js,jsx,ts,tsx}',
'!**/*.d.ts',
'!**/app/**/layout.tsx',
'!**/app/**/loading.tsx',
'!**/app/**/error.tsx',
'!**/app/**/not-found.tsx',
'!**/*.test.{js,jsx,ts,tsx}',
'!**/*.spec.{js,jsx,ts,tsx}',
'!**/node_modules/**',
'!**/dist/**',
'!**/.next/**',
],
// Coverage reporters - HTML for dashboard + text for console
coverageReporters: ['html', 'text', 'lcov', 'json-summary'],
// Coverage directory
coverageDirectory: '<rootDir>/coverage',
// Coverage thresholds - enforce minimum coverage
coverageThreshold: {
global: {
branches: 60,
functions: 60,
lines: 70,
statements: 70,
},
// Higher thresholds for critical code
'./packages/services/src/**/*.ts': {
branches: 70,
functions: 75,
lines: 80,
statements: 80,
},
},
// Module file extensions
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
// Increase test timeout for integration tests
testTimeout: 30000,
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)