How to configure path aliases in Jest
If you use webpack aliases for your imports you need to let Jest know about them before you can test your code.
You can do this in a jest configuration file - jest.config.js
for instance:
module.exports = {
moduleNameMapper: {
//an import like: '@/interfaces/Foo.ts'
//becomes '[your-root]/src/interfaces/Foo.ts'
'@/(.*)$': '<rootDir>/src/$1',
},
...
};
If you want to learn how to configure webpack aliases you can read this post