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

@vitest/coverage-istanbul runs excluded files #6058

Closed
6 tasks done
MKhasib opened this issue Jul 8, 2024 · 5 comments
Closed
6 tasks done

@vitest/coverage-istanbul runs excluded files #6058

MKhasib opened this issue Jul 8, 2024 · 5 comments

Comments

@MKhasib
Copy link

MKhasib commented Jul 8, 2024

Describe the bug

I am migrating from jest to vitest in a private repo where I used the following config

defineConfig({
test:{
    exclude: ['**/*.vue'],
    coverage: {
      all: false,
      provider: 'istanbul',
      exclude: [
        '**/*.vue',
      ],
      include: [
        '**/*.js'
       ]

However, coverage-istanbul instrument picks up vue files used inside the .js test files and adds it to the total coverage report
Is there a way to exclude all vue files used inside .js tests from getting into the final coverage report?

Reproduction

import any .vue file inside a test .js file

System Info

    "@vitest/coverage-istanbul": "^1.6.0",
    "vitest": "^1.6.0",
    "vite": "^5.2.11",
    "vite-plugin-istanbul": "^5.0.0",

Used Package Manager

npm

Validations

@MKhasib
Copy link
Author

MKhasib commented Jul 8, 2024

@AriPerkkio Do you have any ideas on how to fix this issue? Thanks!
Ps: I read all vitest docs, debugged inside vitest instrumenting libs but with no luck

Copy link

github-actions bot commented Jul 9, 2024

Hello @MKhasib. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@AriPerkkio
Copy link
Member

The (partial) configuration shown in description is enough to solve this. Only **/*.js files should appear in coverage report. The exclude part is not needed, as include: ['**/*.js'] already excludes *.vue.

@AriPerkkio
Copy link
Member

What's vite-plugin-istanbul doing there? It's not a package that Vitest maintains. It's likely causing this issue as it doesn't use vitest.config.ts at all.

@MKhasib
Copy link
Author

MKhasib commented Jul 9, 2024

@AriPerkkio Thanks for the quick response, I tried creating a reproducible repo but it seemed vitest included in coverage is working as expected just in the new repo. I am investigating why it doesn't on the private repo(actually it does exclude some files but not all .vue files from coverage)

I will close this issue for now, thank you soo much for the help!

@MKhasib MKhasib closed this as completed Jul 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants