-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(spy)!: reset existing spy on repeated spyOn
#7359
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
sheremet-va
left a comment
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.
Why do we need to restore it? I would expect we can just reset the state
|
|
This reverts commit b229a85.
|
Or probably 346794b is what you meant? |
spyOn
|
Latest looks like it should do the trick. I'd be happy to test this once it's released. |
@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: |
|
@NateRadebaugh Feel free to try the package on pkg-pr-new #7359 (comment) |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
So creating a new spy will reset the old spy? |
|
@dskloetd Can you try out the package to see if it works for you? #7359 (comment) If it doesn't, can you provide a reproduction? |
|
I wasn't sure how to try the package from the branch so I just added the Here's an example of something that breaks as a result: Imagine that in realistic tests the default return value is defined in Here's another example of something that breaks: |
|
@dskloetd thanks for testing this. I also ran into issues with the latest once I ran it against my codebase but I haven't found time to investigate myself. I think your use case is more complete than I had originally reported. |
|
Thanks for testing it out. The use case sounds valid (namely calling |
|
Thanks, the new PR looks even more targeted solution of the original bug and should resolve the new issues we're seeing. |
|
@dskloetd @NateRadebaugh Hey folks, if anyone interested, please try it out #7499 (comment). This brings back Vitest v2 behavior of |
|
Thanks yeah I've already reviewed the other PR and it seems to fit my needs, effectively reverting the breaking change and restoring my tests to passing. In the meantime I've used patch-package to unblock my team's upgrade, looking forward to an official release with it, thanks! |
|
Superseded by #7499 |
Description
Is this a breaking change again? 🤔
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:.