marchaos / jest-mock-extended

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

added mockClear and mockReset which also works with deep mocks #13

Closed marchaos closed 4 years ago

cgfrost commented 4 years ago

I've tested out commit #c8089a786743548bf1135b4ab5d9e12355b6d5ea Both mockClear and mockReset seem to be fine. I modified some tests to reset the mocks after setting return values and they started failing as expected so it's looking good to me.

Thanks for this, highly appreciated.

cgfrost commented 4 years ago

For what it's worth, the readme doesn't mention the MockProxy type. I initially typed my mock to the thing it was mocking and then I couldn't call the jest functions on the mocked methods. Typescript was complaining. Only took me a moment to look at the code and find the MockProxy type but could be worth a mention in the docs to help others.