marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
828 stars 57 forks source link

Add generics to mockReturnValue and mockResolvedValue #47

Closed moltar closed 3 years ago

moltar commented 4 years ago

It would be good to be able to override the return types via generic param to the mockReturnValue and mockResolvedValue.

The use case is that I am mocking a third party library (aws-sdk), which has a very complicated return type, and I don't actually care about all of the meta return values. I only need to mock the value that I care about in my application.

Thanks.

marchaos commented 3 years ago

They are not really part of the API - we just proxy those on to jest, so would be difficult without replicating the jest API.

paroxyzm commented 2 years ago

Would it be possible to create additional generic methods alongside mockReturnValue? Something like extendedMockReturnValue?