Skip to content
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

Feature Request: Create spyReset to only reset spies, not other mocks #7348

Open
4 tasks done
NateRadebaugh opened this issue Jan 23, 2025 · 0 comments
Open
4 tasks done

Comments

@NateRadebaugh
Copy link

Clear and concise description of the problem

With the new 3.0 release, "vi.spyOn Reuses Mock if Method is Already Mocked" is a breaking change without a simple migration strategy.

https://vitest.dev/guide/migration.html#vi-spyon-reuses-mock-if-method-is-already-mocked

While we can configure "mockReset" in the vitest config, or explicitly call "mockRest" in the "beforeEach", this also blows away other mocks that may have been configured.

It would be great if we could have a new spyReset to only reset spies. Right now we have a number of tests verifying a spy was called N times, and explicitly cleaning up each spy manually using onTestFinished callback is klunky at best.

Suggested solution

Create new spyReset that can be configured in vitest config, or called manually, to only reset spyOn spies instead of all mocks.

Alternative

No response

Additional context

No response

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant