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 report doesn't report correct paths #691

Closed
6 tasks done
wight554 opened this issue Feb 7, 2022 · 0 comments · Fixed by #692
Closed
6 tasks done

Coverage report doesn't report correct paths #691

wight554 opened this issue Feb 7, 2022 · 0 comments · Fixed by #692
Assignees

Comments

@wight554
Copy link

wight554 commented Feb 7, 2022

Describe the bug

I've got the following preact project structure

src/
  app.tsx
server/
test/
  src/
    app.tsx.test
  server/

For some reason test report always strips src from src folder tests, test report structure:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files                              |   90.53 |      100 |   87.23 |   90.53 |                   
 project                         |     100 |      100 |     100 |     100 |                   
  app.tsx                              |     100 |      100 |     100 |     100 |                                  
 project/server                  |     100 |      100 |     100 |     100 |                   
  constants.ts                         |     100 |      100 |     100 |     100 |                   
----------|---------|----------|---------|---------|-------------------

I've tried manually running c8 with config from https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/integrations/coverage.ts - it worked fine, src was under src, not in root folder

I've also tried debugging the code in reportCoverage, it's somehow related with source maps, url has correct mapping, while map has stripped src, probably issue inctx.vitenode.fetchCache.entries(), but that's just assumption

Reproduction

https://github.com/wight554/blog-template

System Info

System:
    OS: macOS 12.2
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 1.26 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
    Watchman: 2021.10.04.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 98.0.4758.80
    Edge: 97.0.1072.76
    Safari: 15.3
  npmPackages:
    vite: ^2.7.2 => 2.7.13 
    vitest: ^0.2.7 => 0.2.7

Used Package Manager

npm

Validations

@Demivan Demivan self-assigned this Feb 7, 2022
@Demivan Demivan added the bug label Feb 7, 2022
wight554 added a commit to wight554/blog-template that referenced this issue Feb 7, 2022
@antfu antfu closed this as completed in #692 Feb 8, 2022
chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants