vitest-dev / vitest

Next generation testing framework powered by Vite.
https://vitest.dev
MIT License
13.09k stars 1.18k forks source link

Code coverage is not working #259

Closed wtchnm closed 2 years ago

wtchnm commented 2 years ago

Describe the bug

The following error is thrown when executing vitest --coverage:

Error: Cannot find module '/home/wtchnm/Documents/Web/Vitamin/node_modules/.pnpm/vitest@0.0.105_1fa977ddae9488c8bb84401f982e9f7f/node_modules/dist/cli.js'.

If we change from ../../dist/cli.js to ../dist/cli.js in the following snippet, it will find the module: https://github.com/vitest-dev/vitest/blob/c6e3ad7da2193322fcce0d03706f959592e921fb/packages/vitest/vitest.mjs#L15

But unfortunately the coverage report will be empty:

image

Note: c8 vitest run will work just fine.

Reproduction

pnpx -y degit wtchnm/Vitamin#feat/vitest vitest-coverage-bug && cd vitest-coverage-bug && pnpm i && pnpm test:ci

System Info

System:
    OS: Linux 5.15 undefined
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 3.23 GB / 15.60 GB
    Container: Yes
    Shell: 3.3.1 - /usr/bin/fish
  Binaries:
    Node: 16.13.1 - /usr/bin/node
    Yarn: 1.22.15 - ~/.npm-global/bin/yarn
    npm: 8.3.0 - /usr/bin/npm
  Browsers:
    Brave Browser: 96.1.33.106
    Firefox: 95.0.2
  npmPackages:
    @vitejs/plugin-react: 1.1.3 => 1.1.3 
    vite: 2.7.4 => 2.7.4 
    vitest: 0.0.105 => 0.0.105

Used Package Manager

pnpm

Logs

No response

Validations

antfu commented 2 years ago

Thanks, fixed!

wtchnm commented 2 years ago

Thanks!