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.

Coverage Overlay not highlighting the same as coverage/index.html

See original GitHub issue

Environment

node -v: v8.11.3 npm -v: 5.6.0 Operating system: windows10

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line?
yarn run testjest:watch --coverage --runTestsByPath src/app/game/game-a.service.spec.ts

Steps to Reproduce

a sample repo branch with the problem https://github.com/nasreddineskandrani/full-example-angular/tree/jest-playaround

commands:

yarn install yarn run testjest:watch – --coverage

for the same test run if i remove the test in my spec file for the false branch in game-a.service.spec.ts

index.html coverage: image

overlay coverage: image


you can see that the true branch is still highlighed by the overlay in vscode => when index.html coverage is not highlihgting this branch.

Relevant Debug Info

i did not debug it yet.

Expected Behavior

coverage/index.html and coverage overlay in vscode are the same

Actual Behavior

covergae/index.html and coverage overlay in vscode are NOT the same

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
connectdotzcommented, May 10, 2020

@nasreddineskandrani in your sample repo, you have tested the if path by evaluating

expect(gameAService.play(heroes)).toEqual(true);

but you didn’t evaluate the hidden else path, which should returns false. Therefore you have only partially tested your branch. The E marker in the index.html means missing coverage on Else path; it will put a marker I for missing Ifpath, you can play with it to see that effect.

you can do exactly what is done in index.html this is the standard for most testing coverage tools it’s highlighted in red when not covered

Just to be sure, the index.html (Istanbul report) is telling you the branch is not fully covered, it just didn’t use the red marker but the E. Actually there are many more types of “missing coverage” the report uses: How do I rea an Istanbul Coverage Report?.

I think your suggestion to adopt the same report scheme is good, we can certainly use the same color scheme, provided they look right in vscode editor (lite/dark mode). However, we probably won’t use the E or I marker, as they will interfere with code formating since we are dealing with text editors here, unlink the report is a read-only HTML page… That is why I am thinking of using different colors to represent them, I am all ears if you have other suggestions…

1reaction
connectdotzcommented, May 9, 2020

Hi, I looked at the sample repo today, this is an interesting use case since this branch is “partially” covered, i.e. the “invisible” else path is not tested thus not covered. It is true that we do not distinguish “fully not cover” or “partially not cover” in our default coverage display today… it is either fully covered or not. The index.html does provide more useful information stating it is either “else” or the “if” path that is not covered…

We could mark the partially uncovered branch with different visuals… and could possibly take it further by providing different colors for if-vs-else coverage 🤔 …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling Jest Code Coverage Overlay in VS Code - YouTube
This video guides you through enabling Jest code coverage overlay in VS Code. This include specific instructions for Lightning Web ...
Read more >
Viewing code coverage results - IBM
You can view your code coverage results in either a Workbench , HTML or PDF report or within the editor. By default, Workbench...
Read more >
Clearing coverage highlighting in Eclipse - java - Stack Overflow
For people who are not able to find the coverage view , follow these steps : Go to Windows Menu bar > Show...
Read more >
Full code-coverage with Jest - tsmx
A guided tour on how to achieve the most complete code-coverage with Jest in your NodeJS projects and an some thoughts on why...
Read more >
Health Insurance Coverage in the United States: 2020
More information is available at <www.medicaid.gov/state-overviews/index.html>. Note: The estimates by type of coverage are not mutually exclusive: people ...
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