I found this utility called tsconfig-paths-jest, that will do that automatically for you. To use this, you will need to set up a jest.config.js file so that you can assign values dynamically at test runtime, and if you have jest configuration info in package.json you should remove that when you set up your jest.config.js file. Please see the tsconfig-paths-jest project for full instructions.
One other pointer there - be careful if like me you have copied the tsconfig.json file from somewhere on the internet. The utility uses JSON.parse, and the implementation is strict and doesn't like trailing commas at the end of arrays and objects.
So something like this:
"paths": {
"@assets/*": [ "src/assets/*" ],
"@source/*": [ "src/*" ],
}
Should be changed to:
"paths": {
"@assets/*": [ "src/assets/*" ],
"@source/*": [ "src/*" ]
}
No comments:
Post a Comment