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
spyOn(...).mockImplementation should return a SpyInstance rather than a Mock #17605
Comments
Add workaround for DefinitelyTyped/DefinitelyTyped#17605.
Add workaround for DefinitelyTyped/DefinitelyTyped#17605.
We need this! @alexjoverm @asvetliakov @NoHomey @orta Can we get an update, they types haven't been updated in over a month |
+1 on that |
Is this still an issue? I don't think so. The example from the first message in this thread is working without type errors. You can try it: https://github.com/vkrol/typescript-jest-spy-on-playground
|
Is this needed now that there's been some pretty massive refactoring in |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
@types/jest
package and had problems.While attempting to write a system to un-mock/un-spy on modules I came across what seems to be a problem with types returned by
mockImplementation
(andmockImplementationOnce
,mockReturnThis
,mockReturnValue
,mockReturnValueOnce
) as a result of callingspyOn
. This is that while the typings specify thatmockImplementation
returns aMock
, what actually comes back is aSpyInstance
with themockRestore
function available to call. It'd be great to get some feedback on this, and if you think it's a valid fix, I can get a PR put together reflecting this change.The type hack version below works, even though the current types specify that it shouldn't
The text was updated successfully, but these errors were encountered: