Skip to content

Commit

Permalink
Improve TypeScript Jest config
Browse files Browse the repository at this point in the history
Use the preset and `satisfies` to have less custom config and more type
safety.
  • Loading branch information
hugo committed Aug 21, 2023
1 parent fba1f18 commit 3f05a0a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import type {Config} from 'jest'
import {defaultsESM} from 'ts-jest/presets'

module.exports = {
preset: 'ts-jest',
verbose: true,
bail: 1,
setupFilesAfterEnv: ['@testing-library/jest-dom'],
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy',
},
transform: {
'^.+\\.tsx$': 'ts-jest',
'^.+\\.ts$': 'ts-jest',
...defaultsESM.transform,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/tests/fileTransformer.js',
},
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/'],
}
} satisfies Config

0 comments on commit 3f05a0a

Please sign in to comment.