-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix!: rewrite spying implementation to make module mocking more intuitive #8363
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
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Description
TODO
vitest.mock()
#8345Fixes #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.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.