silvenon / silvenon.com

My overengineered personal website
https://silvenon.com
MIT License
22 stars 2 forks source link

Mocking with Jest: Spying on Functions and Changing their Implementation #334

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Mocking with Jest: Spying on Functions and Changing their Implementation

Using Jest to record calls of particular methods and even change their implementation.

https://silvenon.com/blog/mocking-with-jest/functions

zhao-li commented 2 years ago

Thank you for writing this up. I had the hardest time figuring out how to use Jest's mocking features. Your article helped me understand how mocks and spies are supposed to be used which then led me to figure out that I did not need to use manual mocks because spies worked sufficiently well.

I went through your article in great detail and wanted to share some issues I ran in to, in case it can help the next person reading your article:

Sorry, I might have just missed some points and the above might not actually be typo's. Sorry in advance for my mistake.

silvenon commented 2 years ago

Thank you so much for you generous feedback! I updated my posts based on what you said 🚀 hopefully I covered everything that you had trouble with, and I'm so happy my posts helped you understand these features!