-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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.
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.1Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.


