question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

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

Repo - develop branch

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:open
  • Created 4 years ago
  • Reactions:3
  • Comments:11

github_iconTop GitHub Comments

3reactions
SimenBcommented, Jan 14, 2020

I doubt weā€™ll add support for rewire (jest has builtin support for mocking modules via jest.mock and jest.doMock), but if anybody wanna send a PR thatā€™s of course welcome

1reaction
JNBourratcommented, Jan 16, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error getting the coverage report with rewire / cross-env
The issue is that I need to set the env variable in order to use the rewire plugin that allows me to run...
Read more >
11 Signs You Should Think About Rewiring Your Home
11 signs you should think about rewiring your home. Over half of home electrical fires are related to wiring problems. Is your home...
Read more >
Does Homeowners Insurance Cover Electrical Wiring?
You may have to make some changes for your new coverage to go live. When homes have old electrical wiring types like knob...
Read more >
Family Protection Coverage - Rewire
Look after your loved ones in the Philippines with 4 coverages: Covid-19, Personal Accident, Dengue Fever and Home Care Assistance. Protect your family...
Read more >
Does Homeowners Insurance Cover Electrical Wiring?
Updated wiring allows homeowners insurance company underwriters to price the premium for your policy at a better rate. Outdated wiringĀ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found