I am using WebPack + React + Jest for my application and I have set resolve.alias = { app: "/path/to/app" }
in my configuration file.
In React, I can use this path to do require("app/component") and obtain the file at "/path/to/app/component.js" correctly.
When running JEST tests this alias is not recognized, neither in the tests, nor for the imported modules. All of this works when running the app but not the tests with jest-cli.
jest-cli
lives in a world separate from Webpack so it cannot work that way.
Use babel-plugin-module-resolver to handle aliasing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With