reported uncovered lines that actually have been covered
See original GitHub issueLink to bug demonstration repository
https://github.com/lichader/nyc-demo
Expected Behavior
Expected 100% coverage
Observed Behavior
Reporting Branch coverage as 50%.
I made a basic repo to show what the problem is. I have a simple js file here that just prints something in the log. From console output I pasted below, you can see that the code inside the if block is hit. But nyc reported lines 8-16 are uncovered, which is quite strange. Not sure where I did wrong or it is a bug.
This is the output here:
π nyc-poc master ✗ ❯ npm run cover:unit
> unit@1.0.0 cover:unit /Users/me802707/work/rpeng/nyc-poc
> nyc --all npm run test
> unit@1.0.0 test /Users/me802707/work/rpeng/nyc-poc
> mocha tests/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=./test-results/test-results.xml
found bar: user1
found bar: user2
bar is found
ERROR: Coverage for branches (50%) does not meet global threshold (90%)
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 50 | 100 | 100 |
foo.js | 100 | 50 | 100 | 100 | 8-16
----------|---------|----------|---------|---------|-------------------
Troubleshooting steps
run command: npm install && npm run cover:unit
Environment Information
System:
OS: macOS 11.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 51.58 MB / 16.00 GB
Binaries:
Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
npm: 6.14.10 - ~/.nvm/versions/node/v14.15.4/bin/npm
npmPackages:
nyc: 15.1.0 => 15.1.0
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Jest Uncovered Lines - How do I test these lines..?
If the 'uncovered lines' are in yellow, it means they're partially covered. You can find out what specific attributes are not covered by ......
Read more >Why does JaCoCo report uncovered lines which are in fact ...
I created a project on GitHub [1] and integrated it with coveralls.io using the JaCoCo Maven plugin to generate the coverage report. The...
Read more >How do I see what lines are not covered?
I have a simple trigger that works in the sandbox, does exactly what I want it to do. Cannot get code coverage above...
Read more >Total coverage won't increase even after exclusions
What I have noticed after exclusions was, after exclusions the number of Lines to cover and Uncovered Lines both got reduced. So lo…...
Read more >Read the coverage report | IntelliJ IDEA Documentation
The report shows the percentage of the code that has been executed or covered by tests. You can see the coverage result for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same problem on if statements, however, I wrote console.log statements into these ifs and they are properly displayed in the console
Hi dhensby,
Makes sense for actual branches, but these are mocked Constructor arguments, how exactly does your example relate to that use-case?
Either way, once we cover the remaining branches I’ll let you know if that fixed it. But seems silly, it should instead state which lines are partially tested when less than 100% of branches were tested. There’s no way it can know which constructor arguments are used in untested branches without knowing which lines those are. So indicating those lines as untested or (a new feature) as partially tested would have actual use while indicating constructor arguments says very little.