Closed supersime closed 4 years ago
No responses. Never mind. Closing. And no, I never got to resolve it. I think the issue is to do with referencing. Once the module is "rewired" then the "spy" has to spy on the rewired module, not the original module... or something like that.
I've just introduced babel-plugin-rewire into my repo so I can test my non-exported functions. Sounds great.
But I have lots of jest tests broken because of the following test scenario, which i've dumbed down to reproduce the problem.
module1.js
module2.js
What I want to do in my test, is:
./__tests__/module2.test.js
If I run the test without babel-plugin-rewire, I get this:
If I run the test with babel-plugin-rewire, I get this:
I have tried so many workarounds but I just can't find one that works, and I wonder if this is a bug with babel-plugin-rewire.