-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: spy.mockRevert
#6378
feat: spy.mockRevert
#6378
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
5415791
to
ffb7945
Compare
`restore`, `reset`, `clear`
ffb7945
to
d8566d8
Compare
Hey, I'd appreciate some input on the CI failing - |
It's just flaky, don't worry |
The team thinks it's better to restore the implementation in |
Wouldn't that be a breaking change with respect to the Jest compatibility layer? I am imagining like: import { expect, it, vi } from "vitest"
// this test passes with jest
// it would not pass in vitest with the proposed changes to `mockReset`
it("should reset", () => {
const value = 0
const fn = vi.fn(() => {
value++
})
fn()
expect(value).toBe(1)
fn.mockReset()
fn()
expect(value).toBe(1)
}) Please let me know if I have misunderstood anything ❤️ Sorry, I am happy to help, I just want to make sure the discussion was rigorous before proceeding 😅 |
Yes and yes |
Alright - I think I will close this for now, then, and open a new PR for that |
Description
Adds a new method
mockRevert
to spies. It's in the same vein asmockClear
,mockReset
,mockRestore
- it is most similar tomockRestore
, with the key difference being that it does not 'un-spy' mocks created withvi.spyOn()
.See #6308 for discussion.
PR Checklist
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
. (I am waiting forplaywright
to install)Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.