We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
spy.mockReset()
29.7.0
jest.spy(bModule, 'B').mockImplementation(...)
spy.mockRestore()
mockRestore()
Reproducible case: https://codesandbox.io/p/sandbox/jest-mock-reset-breaks-future-kk4kjr
Able to turn spy to mock implementation in subsequent test cases after test case with mockRestore()
Unable to get re-mock spy
No response
The text was updated successfully, but these errors were encountered:
Ok, I found out that re-creating spy itself after calling .mockRestore() helps. e.g.
.mockRestore()
test("calls real sum", () => { sumSpy.mockRestore(); expect(callSum(1, 2)).toBe(3); sumSpy = jest.spyOn(sumModule, "sum").mockImplementation(() => 5); });
I wonder if this is an expected behaviour or is there a way to keep the spy reference "alive" so that it could be re-mocked without being re-created?
Sorry, something went wrong.
No branches or pull requests
Version
29.7.0
Steps to reproduce
jest.spy(bModule, 'B').mockImplementation(...)
by defaultspy.mockRestore()
to get real implementationmockRestore()
restored it real hard.Reproducible case:
https://codesandbox.io/p/sandbox/jest-mock-reset-breaks-future-kk4kjr
Expected behavior
Able to turn spy to mock implementation in subsequent test cases after test case with
mockRestore()
Actual behavior
Unable to get re-mock spy
Additional context
No response
The text was updated successfully, but these errors were encountered: