Jest transformation plugin to remove path extension.
🌟 Excellent if you use .js
in TypeScript files and Jest cannot find the module.
Add to jest.config.js
/ package.json
with files that you want to remove extensions from.
module.exports = {
transform: {
".(ts|tsx)": ["jest-remove-path-extension", [".js"]],
},
};
Of course, you can specify specific files for individual fixes.
Use jest-chain-transform, for example.
module.exports = {
transform: {
".(ts|tsx)": [
"jest-chain-transform",
{
transformers: [["jest-remove-path-extension", [".js"]], ["ts-jest"]],
},
],
},
};
Run this command before running tests: npx jest --clearCache