-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Labels
feat: module mockingIssues related to code with vi.mockIssues related to code with vi.mockpending triage
Description
Describe the bug
Before v3.2.0, mixing and matching vitest.spyOn() and automocking (vitest.mock()) worked as expected. Ever since v3.2.0 however, calling mockRestore() on a spy on an automocked method restores the unmocked method. This broke some of our tests when we tried to update to v3.2.x.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-shhybrk7?file=test%2Fbasic.test.ts
System Info
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Pro
Memory: 167.75 MB / 48.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.1 - ~/.nvm/versions/node/v22.17.1/bin/node
Yarn: 1.22.22 - ~/Programming/Airfordable/ohare/node_modules/.bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v22.17.1/bin/npm
Watchman: 2025.04.21.00 - /run/current-system/sw/bin/watchman
Browsers:
Safari: 18.5
npmPackages:
@vitejs/plugin-react: 4.6.0 => 4.6.0
@vitest/ui: 3.2.4 => 3.2.4
vitest: 3.2.4 => 3.2.4Used Package Manager
npm
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feat: module mockingIssues related to code with vi.mockIssues related to code with vi.mockpending triage