Skip to content

feat: add reproduction for vi.mock({ spy: true }) coverage issue#9292

Closed
Copilot wants to merge 8 commits intomainfrom
copilot/create-repro-for-issue-9290
Closed

feat: add reproduction for vi.mock({ spy: true }) coverage issue#9292
Copilot wants to merge 8 commits intomainfrom
copilot/create-repro-for-issue-9290

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 18, 2025

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/:

  • src/module.ts: Simple module to be mocked
  • test/short.test.ts: Uses { spy: true } → Results in 0% coverage
  • test/verbose.test.ts: Uses manual spy → Results in 50% coverage
  • README.md: Comprehensive documentation with reproduction steps
  • vitest.config.ts: Configuration with v8 coverage
  • package.json: Scripts for easy testing

Verified Results

# Short approach (spy: true)
module.ts |       0 |      100 |       0 |       0 | 2-6

# Verbose approach (manual spy)  
module.ts |      50 |      100 |      50 |      50 | 6

How to reproduce

cd examples/repro-9290
pnpm run coverage:short    # Shows 0% coverage
pnpm run coverage:verbose  # Shows 50% coverage

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

create repro for #9290


💡 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.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 18, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit a5b671b
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6979c5e35476cf00087e19a8
😎 Deploy Preview https://deploy-preview-9292--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 3 commits December 18, 2025 03:09
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>
@hi-ogawa
Copy link
Copy Markdown
Collaborator

@copilot it's not in issue but in discussion #9290

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
Copilot AI requested a review from hi-ogawa December 18, 2025 03:22
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot it's not in issue but in discussion #9290

Fixed in 8507ab0 - updated the README title to reference "Discussion 9290" instead of "Issue 9290".

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa closed this Jan 29, 2026
@hi-ogawa hi-ogawa deleted the copilot/create-repro-for-issue-9290 branch January 29, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants