feat: add reproduction for vi.mock({ spy: true }) coverage issue#9292
Closed
feat: add reproduction for vi.mock({ spy: true }) coverage issue#9292
Conversation
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Collaborator
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create reproduction for discussion on issue 9290
feat: add reproduction for vi.mock({ spy: true }) coverage issue
Dec 18, 2025
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Contributor
Author
7 tasks
Collaborator
|
superseded by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reproduction for Discussion 9290 ✅ COMPLETE
Successfully created a reproduction example for GitHub discussion #9290 which demonstrates a coverage collection issue with
vi.mock('./module', { spy: true }).Discussion: #9290
The Problem
When using
vi.mock('./module', { spy: true }), coverage information is not collected for the mocked module, even though the actual code is executed. However, using the more verbose manual spy approach does collect coverage correctly.What was created
✅ New example in
/examples/repro-9290/:{ spy: true }→ Results in 0% coverage ❌Verified Results
How to reproduce
Both tests execute the same code and verify the same behavior, but only the verbose approach collects coverage.
Expected Behavior
Both approaches should collect coverage since they both execute the actual module code. The
{ spy: true }option should behave identically to the manual approach.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.