Coverage is not reported accurately when filename is similar to the folder name
Created by: MrHus
Description
When I run npm test -- --coverage
some files report zero coverage, even though they have tests.
Here is the output:
-------------------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-------------------------------------------|----------|----------|----------|----------|----------------|
All files | 91.94 | 71.43 | 93.02 | 92.43 | |
src/shared/Pager | 0 | 0 | 0 | 0 | |
Pager.js | 0 | 0 | 0 | 0 |... 40,41,46,47 |
-------------------------------------------|----------|----------|----------|----------|----------------|
It would seem that the Pager Component is not tested at all. However it is fully tested. Here is the strange thing, when I alter the Pager.js file in anyway, such as entering another blank line or leaving a comment, it will report the following:
-------------------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-------------------------------------------|----------|----------|----------|----------|----------------|
All files | 100 | 100 | 100 | 100 | |
src/shared/Pager | 100 | 100 | 100 | 100 | |
Pager.js | 100 | 100 | 100 | 100 | |
-------------------------------------------|----------|----------|----------|----------|----------------|
Things I've tried, without success:
- Removing the coverage folder.
- Commiting all changes in git so the staging is clear.
- Altering the
Pager.test.js
file.
So far the only solution is changing Pager.js.
Environment
Run these commands in the project folder and fill in their results:
-
npm ls react-scripts
(if you haven’t ejected): react-scripts@0.9.0 -
node -v
: 7.5.0 -
npm -v
: 4.1.2
Then, specify:
- Operating system: macOs Sierra 10.12.3
- Browser and version: Not applicable since it is ran inside the terminal
Here's the code for both files: https://gist.github.com/MrHus/add9acb6dee727a494897706570afe12