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

Getting this.coverageProvider?.generateCoverage is not a function with Vitest 2.0 #6343

Closed
6 tasks done
bildungsroman opened this issue Aug 14, 2024 · 4 comments
Closed
6 tasks done

Comments

@bildungsroman
Copy link

Describe the bug

I updated vitest from 1.3.1 to 2.0.5 and @vitest/coverage-v8 from 1.3.1 to 1.6.0. Now when I run tests, the tests are passing, but whenever I'm running with the --coverage flag I get the following error:

TypeError: this.coverageProvider?.generateCoverage is not a function
 ❯ node_modules/vitest/dist/chunks/cli-api.OKfd3qJ0.js:14947:53
 ❯ Vitest.runFiles node_modules/vitest/dist/chunks/cli-api.OKfd3qJ0.js:14955:12
 ❯ Vitest.start node_modules/vitest/dist/chunks/cli-api.OKfd3qJ0.js:14804:7
 ❯ startVitest node_modules/vitest/dist/chunks/cli-api.OKfd3qJ0.js:15893:7
 ❯ start node_modules/vitest/dist/chunks/cac.DGgmCKmU.js:1499:17
 ❯ CAC.run node_modules/vitest/dist/chunks/cac.DGgmCKmU.js:1479:3

This is my vitest.config.ts:

/// <reference types="vitest" />
import { defineConfig } from "vite";
import wasm from "vite-plugin-wasm";

export default defineConfig({
  plugins: [wasm()],
  test: {
    server: {
      deps: {
        inline: [],
      },
    },
    environment: "jsdom",
    coverage: {
      exclude: [
        "dist-package/",
        "src/__generated__/",
        "src/localDev.tsx",
        "src/_tests/",
      ],
      reporter: ["text", "cobertura", "html"],
    },
  },
});

Reproduction

Run vitest run --coverage with @vitest/coverage-v8 installed.

System Info

System:
    OS: macOS 14.6
    CPU: (8) arm64 Apple M1
    Memory: 248.81 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.7.0 - ~/.nvm/versions/node/v20.7.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.7.0/bin/npm
  Browsers:
    Chrome: 127.0.6533.119
    Edge: 127.0.2651.98
    Safari: 17.6
  npmPackages:
    @vitejs/plugin-react: ^4.0.0 => 4.3.1 
    @vitest/coverage-v8: ^1.6.0 => 1.6.0 
    vite: ^5.1.7 => 5.2.13 
    vitest: ^2.0.5 => 2.0.5

Used Package Manager

npm

Validations

@AriPerkkio
Copy link
Member

I updated vitest from 1.3.1 to 2.0.5 and @vitest/coverage-v8 from 1.3.1 to 1.6.0

Update your vitest and @vitest/coverage-* packages to same version.

@AriPerkkio
Copy link
Member

In future we'll print helpful warning in these cases: #6317

@bildungsroman
Copy link
Author

Hmmm, when I ran npm install @vitest/coverage-v8@latest the version I got was 1.6.0. I'll try again.

@bildungsroman
Copy link
Author

I was able to force it with npm install @vitest/coverage-v8@2. Not sure why @latest didn't give me the latest version.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 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