Code coverage tool (jest --coverage) not recognizing coverage for rewired functions (jest @23.4.2, rewire @4.0.1)
See original GitHub issueHello !
So, first of all, I love rewire. Being able to just test specific functions without having to export them all is great. Thank you !
On to the issue. We recently migrated from mocha to Jest, and it seems that when it comes to coverage jest has an issue with rewire, or rewire an issue with jest.
Trying to get a specific function, like this
const myModule = rewire("./path/to/module"); const myFunction = myModule.__get__("myFunction");
Then testing it, like so
`describe(“Simple function test”, function () { let input = “hey !”; let expectedResult = “hello !”; let result = () => myFunction(input);
it("should not throw an error", () => {
return expect(result).not.toThrow();
});
it("should return the expected result", () => {
return expect(result()).toStrictEqual(expectedResult);
});
});`
Ends up running the tests properly (checked with breakpoints that everything passed where it should), but the function is not considered as covered in the coverage report 😢
I’ll put together a minimal repo to demonstrate it, either this evening or by the end of next week.
A great week-end to all of those who read this ! 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:26
- Comments:20
Top GitHub Comments
Also in my case, any new? or some kind of a workaround?
Any movement on this issue? I’ve got the same problem as well
jest: 24.5.0
andrewire: 4.0.1