Synchronization tsconfig paths with Jest (module name mapper)
npm install jest-module-name-mapper



Use this to avoid the declaration of the same module path aliases in tsconfig.json and jest.config.js.
The package allows synchronizing Jest path aliases (moduleNameMapper) with your tsconfig.json configuration.
npm i jest-module-name-mapper -D
Set configuration in jest.config.js:
```
module.exports = {
...
moduleNameMapper: require('jest-module-name-mapper')(),
};
If your tsconfig.json file is located in other directory then root, then you can set your own path to the file.
```
module.exports = {
...
moduleNameMapper: require('jest-module-name-mapper')('/src/tsconfig.json'),
};
![]() | Sebastian Musiał |