silvenon / silvenon.com

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

Mocking with Jest: Taking Advantage of the Module System #335

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Mocking with Jest: Taking Advantage of the Module System

Using Jest to reimplement certain modules when you don't want their usual behavior during testing.

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

zhao-li commented 2 years ago

Thank you again for writing this up. This and the first article is a life-saver for someone who got mocks to work but never quite understood when to use which method of mocking.

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:

Also, your explanation of how mocks are hoisted was super helpful. I ran into that error and conflated it with a bunch of other things. Your explanation clarified everything up.

Thank you again for writing all of this out so simply and succinctly. 🙏

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!