-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjest.config.js
More file actions
29 lines (29 loc) · 806 Bytes
/
jest.config.js
File metadata and controls
29 lines (29 loc) · 806 Bytes
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
export default {
preset: 'ts-jest/presets/default-esm',
// 1. Add .tsx to ESM treatment
extensionsToTreatAsEsm: ['.ts', '.tsx'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
// 2. Update regex to include .tsx files
'^.+\\.tsx?$': ['ts-jest', {
useESM: true
}]
},
moduleDirectories: ['node_modules', 'src'],
// 3. Keep 'node' as default, but ensure your test file has
// the @jest-environment jsdom comment at the top
testEnvironment: 'node',
testMatch: [
// 4. Update match patterns to include .tsx
'<rootDir>/tests/**/*.test.(js|ts|tsx)',
'<rootDir>/tests/**/*.spec.(js|ts|tsx)'
],
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.test.{ts,tsx}',
'!src/**/*.spec.{ts,tsx}'
]
};