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 Reporting #136

Closed
gavinroderick opened this issue Feb 23, 2023 · 6 comments
Closed

Coverage Reporting #136

gavinroderick opened this issue Feb 23, 2023 · 6 comments
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@gavinroderick
Copy link

Is your feature request related to a problem? Please describe.
I run unit tests through the extension, and would like to also run coverage reports in it somehow. At the moment, I run vitest run --coverage in the terminal

Describe the solution you'd like
At first a button that will run the above terminal command for me.

Long term, I'd like to be able to show a panel/tab that has lines covered/uncovered, similar to other IDE's (Jetbrains example picture below).

Describe alternatives you've considered
None I can think of, this is just a nice to have really. Happy to continue with my current method if you want to keep the extension purely unit test based.

Additional context
I'm new to open source, but would be keen to give an implementation of this a shot! If you think it's worthwhile, I can look at submitting a PR.

In the first instance, I'd probably just try to have a button that checks to see if a coverage reporter is installed, and then run it in the terminal. If that goes well, then maybe look at getting fancier with displaying the output.

Jetbrains Coverage Reporter

thanks,

Gavin

@gavinroderick gavinroderick added the p2-nice-to-have Not breaking anything but nice to have (priority) label Feb 23, 2023
@MDUK0001
Copy link

Jest VS Code extension has this - if you're thinking of starting this it may be worth looking at their implementation for inspiration: https://github.com/jest-community/vscode-jest

@adueck
Copy link

adueck commented Apr 19, 2023

Yes +1 for this. I love using this Jest VS Code extension because of the code coverage feature. With the toggle coverage command you can see the coverage show up with lines red and yellow (or whatever color you set) over the uncovered and partially covered lines in the file. It's great!

From here:

image

@simonknittel
Copy link

simonknittel commented Nov 26, 2023

I'm able to achieve this using this extension: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters

You'll have to add "vitest.commandLine": "npx vitest --coverage" to your workspace settings and configure Vitest to use Instabul with the lcov reporter.

.vscode/extensions.json

{
  "recommendations": [
    "zixuanchen.vitest-explorer",
    "ryanluker.vscode-coverage-gutters"
  ]
}

.vscode/settings.json

{
  "vitest.enable": true,
  "vitest.commandLine": "npx vitest --coverage"
}

vitest.config.ts

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    coverage: {
      provider: "istanbul",
      reporter: [
        "text", // For the terminal
        "lcov", // For the VSCode extension and browser
      ],
    },
  },
});

@alvis
Copy link

alvis commented Jan 1, 2024

The jest one is way better than coverage gutters, and it also show the summary on the top of the target file.
It'd be perfect if we can port that to vitest. But at the meantime, coverage gutters does work for the purpose

@connor4312
Copy link

FYI VS Code has finalized an 'official' test coverage API: microsoft/vscode#123713

@sheremet-va
Copy link
Member

Coverage is now supported in https://github.com/vitest-dev/vscode/releases/tag/v0.5.14

This requires the latest Visual Studio Code 1.88.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

No branches or pull requests

7 participants