Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage for empty lines and multiline statements show as green #1020

Open
ffMathy opened this issue Apr 13, 2023 · 2 comments
Open

Coverage for empty lines and multiline statements show as green #1020

ffMathy opened this issue Apr 13, 2023 · 2 comments
Labels
need sample repo needs a sample repo to further investigate stage: awaiting response

Comments

@ffMathy
Copy link

ffMathy commented Apr 13, 2023

Environment

  1. vscode-jest version: v5.2.3
  2. node -v: v18.15.0
  3. npm -v or yarn --version: 9.5.0
  4. npm ls jest or npm ls react-scripts (if you haven’t ejected):
├── [email protected]
└─┬ [email protected]
  └── [email protected] deduped
  1. your vscode-jest settings if customized:
    • jest.jestCommandLine? N/A
    • jest.autoRun? { "watch": true, "onStartup": [ "all-tests" ] }
    • anything else that you think might be relevant? { "jest.showCoverageOnLoad": true, "jest.coverageFormatter": "GutterFormatter" }
  2. Operating system: Mac M1

Prerequisite

  • are you able to run jest test from the command line? yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) jest

Steps to Reproduce

Try making a call to a function with multiple lines:

myFunctionCall( //this line shows as covered
   "foo", //this does not
   "bar"); //this does not

I would expect all those lines to show as covered.

In addition, empty lines show as covered as well. It would be nice if they were excluded and didn't have a gutter.

Example:

myFunctionCall(); //shows as covered
//empty line shows as covered - should not show gutter at all
myFunctionCall(); //shows as covered

The problem with this is that it shows a lot of green and red next to each other. It would be much more useful if it didn't show any green (for empty lines) in the code that isn't covered.

@connectdotz
Copy link
Collaborator

hi, regarding the 2 issues you mentioned:

  1. "function with multiple lines": I tried it in our own repo but could not reproduce it. Do you have a sample repo we can look?
  2. "empty lines show as covere": that was by design for the GutterFormatter, so it will appear as a continuous solid green bar. I can see valid points either way, therefore not sure there is a strong point to change the current behavior. Rest assured, it is not a bug per se.

@connectdotz connectdotz added stage: awaiting response need sample repo needs a sample repo to further investigate labels Jun 11, 2023
@bmcallis
Copy link

Regarding the second issue.

It throws me off when I open a file that has no or low coverage but a lot of the lines show as covered. I think I'd prefer no highlight over green, but I might change my mind if I actually saw it 🙂

What about continuing the color from the line above? That would provide the continuous solid green bar when code is covered and a solid red bar would make it more obvious when a big block of code isn't covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need sample repo needs a sample repo to further investigate stage: awaiting response
Projects
None yet
Development

No branches or pull requests

3 participants