Migrating from shallow rendering react components to explicit component mocks

preview_player
Показать описание
Testing React using shallow rendering has a bunch of problems with regards to testing implementation details. Let's see how we can use Jest mocking instead to avoid these issues.

Рекомендации по теме
Комментарии
Автор

I am not really sold on the idea of not using shallow. You say you're tests are what users see in the browser, yet you mock a lot of code. Users don't run mock code, so you're tests are only as good as those mocks. I am afraid the only way to be sure is to use end to end testing.
Also the cases you mention with making typos in props would be easily caught by using types - no need to run tests for that.

BartekKozera
Автор

I am glad you are making smaller focused videos :) thanks for it. And good topics too !!!

Rajibahmed
Автор

Hi Kent,
Thanks for sharing.
Question: can we run single jest file instead of running all and keeping filter?

afsarzan
Автор

Hey Kent, awesome videos!
At my job, we have a coverage threshold that is pretty hight and I was wondering, how do you mock or test arrow functions in that class? For example if the toggle function would have more logic. Thanks!

anythingforweb
Автор

That's a good video, but do you know Enzyme does have "mount" function, which does the exact same thing (with better API for event and searching elements) and jest mocks work with it

ChibiBlasphem
Автор

Thank you so much for your effort! Could you please share with me what is your theme that you using and the font-family of it, look so fancy! Thank you so much!

ChauGiangVEVO
Автор

Thanks for the video 👍
Please tell which theme and font do you use it's awesome!

kalach
Автор

I came late but will raise my hand for being using Enzyme ✋

humantrailmachine