-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
83 lines (80 loc) · 2.2 KB
/
jest.config.js
File metadata and controls
83 lines (80 loc) · 2.2 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
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 = {
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
testEnvironment: 'jsdom',
testMatch: [
'<rootDir>/tests/**/*.test.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.test.{js,jsx,ts,tsx}',
],
testPathIgnorePatterns: [
'<rootDir>/.next/',
'<rootDir>/node_modules/',
'<rootDir>/out/',
],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.stories.{js,jsx,ts,tsx}',
'!src/**/__tests__/**',
'!src/**/__mocks__/**',
],
coverageThreshold: {
global: {
branches: 75,
functions: 80,
lines: 80,
statements: 80,
},
},
coverageReporters: [
'text',
'lcov',
'html',
'json-summary',
],
transform: {
// Use SWC to transform TypeScript and JavaScript files
'^.+\\.(js|jsx|ts|tsx)$': ['@swc/jest', {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
}],
},
transformIgnorePatterns: [
'/node_modules/(?!(framer-motion|@react-three|three)/)/',
],
testTimeout: 10000,
globals: {
'ts-jest': {
useESM: true,
},
},
extensionsToTreatAsEsm: ['.ts', '.tsx'],
// Performance optimization
maxWorkers: '50%',
// Module mapping for aliases and mocks
moduleNameMapping: {
// Handle module aliases (if you're using them in your app)
'^@/(.*)$': '<rootDir>/src/$1',
'^@/lib/(.*)$': '<rootDir>/src/lib/$1',
'^@/components/(.*)$': '<rootDir>/src/components/$1',
// Mock Three.js and related modules for tests
'^three$': '<rootDir>/tests/__mocks__/three.js',
'^@react-three/fiber$': '<rootDir>/tests/__mocks__/react-three-fiber.js',
},
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)