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-c8 includes generated __vite_ssr_exports__ helper in coverage #3237

Closed
6 tasks done
AriPerkkio opened this issue Apr 23, 2023 · 0 comments · Fixed by #3241
Closed
6 tasks done

@vitest/coverage-c8 includes generated __vite_ssr_exports__ helper in coverage #3237

AriPerkkio opened this issue Apr 23, 2023 · 0 comments · Fixed by #3241
Labels
feat: coverage Issues and PRs related to the coverage feature

Comments

@AriPerkkio
Copy link
Member

AriPerkkio commented Apr 23, 2023

Describe the bug

When a source file declares named export that is transformed into __vite_ssr_exports__ by Vite, the @vitest/coverage-c8 coverage reports increase function count by 1 and consider the Object.defineProperty(__vite_ssr_exports__, ... as part of source code. This is due to Object.defineProperty(__vite_ssr_exports__, ... being included in the source maps.

image

Reproduction

This can be reproduced in Vitest repository's test/coverage-test when c8 is used. All files have function counts that do not match. (#3226 (comment))

This is also seen when adding an unused export. The line that is marked as uncovered contains the Object.defineProperty(__vite_ssr_exports__, ... where get() is not executed since no one imports that file. This get() {} also increases function count by one.

System Info

System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M2
    Memory: 56.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.0 - ~/.nvm/versions/node/v18.14.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.3.1 - ~/.nvm/versions/node/v18.14.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.137
    Safari: 16.4
  npmPackages:
    @vitejs/plugin-vue: latest => 4.1.0 
    @vitest/browser: workspace:* => 0.30.1 
    vite: latest => 4.2.1 
    vitest: workspace:* => 0.30.1

Used Package Manager

pnpm

Validations

@AriPerkkio AriPerkkio changed the title @vitest/coverage-c8 includes generated named exports (__vite_ssr_exports__) in coverage @vitest/coverage-c8 includes generated __vite_ssr_exports__ helper in coverage Apr 23, 2023
@AriPerkkio AriPerkkio added bug feat: coverage Issues and PRs related to the coverage feature labels Apr 23, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant