# 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…

- URL: https://graffino.com/til/how-to-configure-path-aliases-in-jest
- Author: Denisa Halmaghi
- Channel: testing
- Published: 2022-02-28
- Updated: 2024-08-21

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:
```js
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](https://graffino.com/til/FRXaL59FzW-folder-aliases-using-webpack)
