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

0.29.8 seems to have broken C8 unit test coverage reporting #3118

Closed
6 tasks done
USA-RedDragon opened this issue Apr 2, 2023 · 4 comments
Closed
6 tasks done

0.29.8 seems to have broken C8 unit test coverage reporting #3118

USA-RedDragon opened this issue Apr 2, 2023 · 4 comments

Comments

@USA-RedDragon
Copy link

USA-RedDragon commented Apr 2, 2023

Describe the bug

After upgrading to vitest 0.29.8, my workflows utilizing C8 as a coverage provide have started erroring with

$ vitest run --coverage

vite:istanbul> Sourcemaps was automatically enabled for code coverage to be accurate.
 To hide this message set build.sourcemap to true, 'inline' or 'hidden'.
TypeError: coverageModule.getProvider is not a function
    at getCoverageProvider (file:///home/user/project/node_modules/vitest/dist/chunk-integrations-coverage.e0a6acd2.js:26:27)
    at async Vitest.initCoverageProvider (file:///home/user/project/node_modules/vitest/dist/chunk-node-pkg.4e9b4238.js:11669:29)
    at async Vitest.start (file:///home/user/project/node_modules/vitest/dist/chunk-node-pkg.4e9b4238.js:11753:7)
    at async startVitest (file:///home/user/project/node_modules/vitest/dist/chunk-node-pkg.4e9b4238.js:19004:5)
    at async start (file:///home/user/project/node_modules/vitest/dist/cli.js:104:17)
    at async CAC.run (file:///home/user/project/node_modules/vitest/dist/cli.js:77:3)

I noticed this change was added, and it seems related: #3040

Reproduction

https://github.com/USA-RedDragon/vite-bug-repro-c8-coverage is pulled and stripped from a bigger project which had been previously set up with coverage via this guide: https://vitest.dev/guide/coverage.html

To reproduce with that repo:

npm ci # the package-lock.json is present and appropriate
npm run test:unit # equivalent to npx vitest run --coverage

System Info

Binaries:
  Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
  Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.0/bin/yarn
  npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
Browsers:
  Chromium: 111.0.5563.146
  Firefox: 111.0.1
npmPackages:
  @vitejs/plugin-vue: ^4.1.0 => 4.1.0
  @vitest/coverage-c8: ^0.29.8 => 0.29.8
  @vitest/ui: ^0.29.8 => 0.29.8
  vite: ^4.2.1 => 4.2.1

Used Package Manager

npm

Validations

@USA-RedDragon USA-RedDragon changed the title 0.29.8 seems to have broken unit tests 0.29.8 seems to have broken C8 unit test coverage reporting Apr 2, 2023
USA-RedDragon added a commit to USA-RedDragon/DMRHub that referenced this issue Apr 2, 2023
renovate bot pushed a commit to USA-RedDragon/DMRHub that referenced this issue Apr 2, 2023
@TiagoDiass
Copy link

I am facing the same problem here.
Just installed @vitest/coverage-c8 in order to get coverage of my files but when I run vitest run --coverage it throws the same error as described in the issue.

image

@AriPerkkio
Copy link
Member

After upgrading to vitest 0.29.8

The reproduction case is not using vitest@0.29.8. Try updating your vitest to latest version. https://github.com/USA-RedDragon/vite-bug-repro-c8-coverage/blob/main/package-lock.json#L3803-L3804

@dteoh
Copy link

dteoh commented Apr 3, 2023

I also reported this issue in the local-pkg repo: antfu/local-pkg#7

@USA-RedDragon
Copy link
Author

@AriPerkkio was right. Since I didn't have vitest explicitly in my package.json, only @vitest/coverage-c8 and @vitest/ui one of my dependencies was resolving vitest 0.29.1. After explicitly installing vitest at 0.29.8, it started working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants