speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
843 stars 90 forks source link

Not working with jest, Invalid variable access: _get__ #223

Open cwagner22 opened 5 years ago

cwagner22 commented 5 years ago

babel-plugin-rewire is not working with jest for me, because of babel-plugin-jest-hoist.

babel-plugin-jest-hoist: The module factory of `jest.mock()` is not allowed to reference any out-of-scope variables.
    Invalid variable access: _get__

To Reproduce

Check out this repo. Run npm run jest

I know there is already a similar issue open but I don't understand why not more people are having this issue since the app is downloaded 70k+ times per week. Since babel-plugin-jest-hoist is included in babel-jest I believe it should affect many people...

bhovhannes commented 5 years ago

Seems to be similar to #183

cwagner22 commented 5 years ago

@bhovhannes Yes, unfortunately no solution worked for me, I had to patch babel-plugin-jest-hoist to whitelist _get__...

VandalPaulius commented 5 years ago

I think I have similar problem, but it say TypeError: _get__(...) is not a function.

sergio-domingues commented 2 years ago

Did anyone discover a solution for this issue?

nGoline commented 1 year ago

I'm having the same issue. Does anyone know how to overcome this? @cwagner22 Can you share how you patched it?

lancemarks commented 1 year ago

I am having this issue. It is holding up an important PR.