fix!: rewrite spying implementation to make mocking more intuitive#8363
Merged
sheremet-va merged 30 commits intovitest-dev:mainfrom Aug 1, 2025
Merged
fix!: rewrite spying implementation to make mocking more intuitive#8363sheremet-va merged 30 commits intovitest-dev:mainfrom
sheremet-va merged 30 commits intovitest-dev:mainfrom
Conversation
@vitest/browser
@vitest/coverage-istanbul
@vitest/coverage-v8
@vitest/expect
@vitest/mocker
@vitest/pretty-format
@vitest/runner
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vite-node
vitest
@vitest/web-worker
@vitest/ws-client
commit: |
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
sheremet-va
commented
Jul 30, 2025
4 tasks
There was a problem hiding this comment.
Pull Request Overview
This PR implements a significant rewrite of the spying/mocking implementation to make module mocking more logical and address multiple long-standing issues. The changes focus on creating a custom mock implementation to replace the reliance on tinyspy, improving consistency between different execution environments, and providing better module mocking behavior.
Key changes include:
- Complete rewrite of the spy implementation with a custom mock system
- Improved module mocking behavior with better instance/prototype state management
- Enhanced constructor support and class mocking capabilities
Reviewed Changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spy/src/index.ts | Complete rewrite implementing custom mock system replacing tinyspy |
| packages/spy/src/types.ts | New type definitions for the mock system |
| packages/spy/package.json | Removed tinyspy dependency |
| packages/mocker/src/automocker.ts | Updated to use new createMockInstance API |
| packages/vitest/src/integrations/vi.ts | Updated to use new mock clearing/resetting functions |
| test/core/test/spy.test.ts | Added test for ignoring nodejs promisify symbol |
| docs/guide/module-mocking.md | New comprehensive module mocking guide |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
sheremet-va
commented
Aug 1, 2025
This was referenced Aug 4, 2025
This was referenced Oct 24, 2025
1 task
This was referenced Nov 3, 2025
1 task
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.
Description
Fixes #8319
Fixes #8307
Fixes #6948
Fixes #8331
Fixes #8134
Fixes #8345
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.