Vitest spyOn has different behaviour than jest's
See original GitHub issueDescribe the bug
Hey! It seems the vitest spyOn doesn’t have the same behaviour as the jest’s (see reproduction)
Reproduction
vitest project reproduction: https://stackblitz.com/edit/vitest-dev-vitest-ne8pti?file=src%2Fexample.ts,test%2Fbasic.test.ts,package.json&initialPath=__vitest__
jest project reproduction: https://github.com/galkatz373/jest-example
System Info
macOS 12.0.1, node 16.6.0
Used 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.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Using Jest, how do I spyon an extended component's method ...
However, I tried changing this around and didn't have any success or different behavior. So my question is, how do I spy on...
Read more >Jest Full and Partial Mock/Spy of CommonJS and ES6 Module ...
This post goes through how to achieve different types of module mocking scenarios with Jest. From simple Import interception, ...
Read more >Mock Functions or Spies Demystified - How Does jest.fn() Work?
This mock function has an implementation, which is called internally. The act of passing a mock function to greetWorld allows us to spy...
Read more >Timer Mocks - Jest
... implementation of setTimeout() and other timer functions. Timers can be restored to their normal behavior with jest.useRealTimers() .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you store methods on an object or class, you can spy on them without problem:
Yes, it works.