'What is Babel's purpose in relation to Jest?
I have an API project where I've been successfully using Jest (v26.x because code coverage doesn't work with v27.x on Windows 10 for me) for unit testing. I've run into a situation where I'm trying to achieve sufficient code coverage on a module I'm testing, but not all functions in that module have been exported, so this is impeding my ability to achieve this.
I came across the NPM package rewire, which worked beautifully, as it allowed me to mock any functions I wanted. The only problem is that code coverage doesn't acknowledge the lines tested via rewire and the devs in the Jest GitHub said they don't plan to support this.
So then I saw a couple of posts that people were successfully using babel-plugin-rewire to achieve the same thing as rewire, but that code coverage lines were successfully being acknowledged with this package. However, I cannot get this setup to work.
I think I understand the basics of Babel, as it pertains to browsers. It will take newer JS code and transpile/polyfill so that older JS code is generated that will work with older browsers of your choice.
But then I started seeing stuff about babel-jest and Babel being integrated into Jest and so on. Aside from the fact that I can't get babel-plugin-rewire to work, I feel like I don't even understand the basics of how Babel and Jest work together, or why Jest needs Babel.
What is the relationship between Babel and Jest?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
