-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Describe the bug
When you call vi.restoreAllMocks(); or have restoreMocks set to true this restores functions in modules that are mocked like this vi.mock('./multiply');. to their original implementation.
That behavior is not documented here https://vitest.dev/guide/mocking.html#automocking-algorithm and is possibly not intended.
This certainly breaks compatibility with jest where restoring all mocks doesn't touch auto-generated modules.
Reproduction
https://stackblitz.com/edit/node-rnge8j?file=mock.test.ts
System Info
System:
OS: Windows 10 10.0.22621
CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor
Memory: 15.75 GB / 31.16 GB
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22621.1702.0), Chromium (113.0.1774.57)
Internet Explorer: 11.0.22621.1Used 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
No labels