Skip to content

Instantly share code, notes, and snippets.

@mustafadalga
Created November 5, 2023 09:11
Show Gist options
  • Save mustafadalga/c1602df648b60b8758db9a74045a476d to your computer and use it in GitHub Desktop.
Save mustafadalga/c1602df648b60b8758db9a74045a476d to your computer and use it in GitHub Desktop.
Summarizes the behavior of mockClear, mockReset, and mockRestore in Jest/Vitest
Function Clears Call History Resets Implementations Restores Original Implementation Scope of Use
mockClear() Clear usage data of the mock function but keep its implementation and return values.
mockReset() Reset the mock function to its initial state, removing any custom behavior or return values.
mockRestore() Restore the original function, removing the mock (only applicable with jest.spyOn).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment