Rewire seems to doesn't work with Jest config "moduleNameMapper"
Opened this issue · 2 comments
victorchapado commented
Hi,
I have the below configuration for the Jest test framework:
module.exports = Object.assign({}, jestBaseConfig, {
moduleNameMapper: {
moduleB: '<rootDir>/node_modules/moduleB/index.js',
},
});
I'm trying to test one module (ModuleA) that requires this one (ModuleB).
ModuleA
|__ requires --> ModuleB
When I use require
for ModuleA, ModuleB is resolved correctly but, if I try to rewire
ModuleA, ModuleB is not found. In particular, the message is:
Cannot find module 'ModuleB'
rewire: "version": "4.0.1"
jest: "version": "24.9.0"
Hoping that the explanation is pretty clear.
Thanks!
woodardj commented
Same issue here, with versions:
rewire: "5.0.0"
jest: "26.3.0"
ppopth commented
I also get the same issue