Issues with coverage and rewire
See original GitHub issueš Bug Report
Hi, I have a public repo that doesnāt produce coverage for file scraper.test.js. File is found in tests directory. I do have another test file that doesnāt have any issue.
However, the problematic file is using rewire
npm module, and I have seen some issues with it lately. I did try to completely remove it, but the problem still persists.
To Reproduce
In folder crawler
Run:
jest --coverage --bail --findRelatedTests ./__tests__/scraper.test.js
or:
jest --coverage
Expected behavior
I expect to see coverage report for scraper.js. Tests run successfully but I there is no coverage data.
Link to repl or repo
envinfo
System: OS: Linux 5.2 Fedora 30 (Workstation Edition) 30 (Workstation Edition) CPU: (4) x64 IntelĀ® Coreā¢ i7-7500U CPU @ 2.70GHz Binaries: Node: 12.8.1 - /usr/bin/node npm: 6.11.2 - ~/.npm-packages/bin/npm npmPackages: jest: ^24.9.0 => 24.9.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11
Top GitHub Comments
I doubt weāll add support for
rewire
(jest has builtin support for mocking modules viajest.mock
andjest.doMock
), but if anybody wanna send a PR thatās of course welcome@An-dz Thanks, Iāll be sure to take a look at it.
For my end I ended up using babel-plugin-rewire instead of rewire itself. I was able to use
__get__
and__set__
to mock the tested moduleās private functions and not rewire the whole module.