I use Webpack.
It has "resolve" config like this:
resolve: {
root: path.resolve('./src'),
extensions: ['', '.js', '.jsx', '.json'],
modulesDirectories: ['node_modules']
}
when I'm trying to require a relative module to the root path (with webpack it requires src/apps/foo/bar.js)
require('apps/foo/bar');
jest are falling with exception:
Cannot find module 'apps/foo/bar' from...
Do I must use "require" with the file-to-file relations only?
I created a repo with simple example of my issue: https://github.com/Poplava/jest-app
That won't work with jest -- it will assume that "app" or "modules" are in node_modules.
Why don't you use relative requires? In your example just do require('../../modules/sum').
Thanks a lot!
It is ugly for me to import module like common/foo/bar from the deep component with ../../../../.. :)
I thought it will be good to have option "resolve" (like in the WebPack) or something like that.