Last active
June 4, 2024 09:24
-
-
Save wojtekKrol/1556f4ba5e00b9a581ca8377845c828e to your computer and use it in GitHub Desktop.
Jest + TS + Path Aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pathsToModuleNameMapper } from 'ts-jest' | |
import { compilerOptions } from './tsconfig.json' | |
import type { JestConfigWithTsJest } from 'ts-jest' | |
const config: JestConfigWithTsJest = { | |
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { | |
prefix: '<rootDir>/', | |
}), | |
preset: 'ts-jest', | |
resolver: 'jest-ts-webcompat-resolver', | |
} | |
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
..., | |
"test": "jest", | |
}, | |
"devDependencies": { | |
..., | |
"@types/jest": "29.5.12", | |
"jest": "29.7.0", | |
"jest-ts-webcompat-resolver": "1.0.0", | |
"ts-jest": "29.1.4", | |
"ts-node": "10.9.2", | |
"typescript": "5.4.5" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"paths": { | |
"~*": ["./*"], | |
... | |
}, | |
"resolveJsonModule": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment