Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewire seems to doesn't work with Jest config "moduleNameMapper" #175

Open
victorchapado opened this issue Jan 8, 2020 · 2 comments
Open

Comments

@victorchapado
Copy link

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
Copy link

Same issue here, with versions:
rewire: "5.0.0"
jest: "26.3.0"

@ppopth
Copy link

ppopth commented Aug 23, 2021

I also get the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants