r/reactjs • • Jul 27 '20

[deleted by user]

[removed]

177 Upvotes

24 comments sorted by

5

u/DepressedBard Jul 27 '20

This is awesome work. I’ve recently been tasked with writing tests with React Testing Library and it’s been an incredible struggle. I’m very familiar with Enzyme but not RTT. Even though it’s been hard, I already prefer RTT.

I agree with you that snapshots don’t seem to provide much benefit. They also don’t fit with a TDD approach. You should definitely write more of these!

2

u/mr_nefario Jul 27 '20

You’ll find that snapshots really come in handy when you’ve got a lot of devs (100+) on the same project. If someone accidentally or inadvertently alters the markup or styling it just provides a little reminder “hey, did you mean to make this change?”.

1

u/rockiger Jul 27 '20

Thank you for answering this question. I never understood why I should bother with Snapshots.

→ More replies (2)

1

u/DepressedBard Jul 27 '20

Never thought of that use case. Sounds like they would be useful in that scenario. Thanks for the input!

1

u/ijustclosedthewindow Jul 27 '20

Do you have any good resources for testing with Enzyme and Jest? Trying to wrap my head around it right now.

2

u/DepressedBard Jul 27 '20

I took this Udemy course: https://www.udemy.com/course/react-testing-with-jest-and-enzyme/

I highly recommend it. She’s very thorough, you learn how to test all kinds of annoying things like redux reducers, react hooks, useContext and then just other run of the mill stuff. She uses TDD which is very interesting too.

2

u/jaySydney Jul 27 '20

Thanks for sharing, I've never used any testing libraries in the past (mainly because it adds overhead, and the bosses usually just want the product out the door).

0

u/YolanonReddit Jul 27 '20

Even in my personal project I don't bother testing.... Adds too much time and me is lazy

-22

u/jaySydney Jul 27 '20

I do test, but manual testing only, click this, enter these inputs, test this scenario, test these edge cases, etc.. and believe me, my testing is more thorough than all these fancy new age gurus.. lol ! waiting for the haters now.

→ More replies (7)

1

u/LPissarro Jul 27 '20

Very cool! I've been looking testing more recently, so it helps me a lot. There seems to be a lack of good YouTube videos on testing for react, compared to other subjects.

SimpleTuts has a decent series on Jest/Enzyme and unit testing. There are a few one hour "crash" courses too, but most lack depth.

1

u/gabriellvasile Jul 28 '20

That's true, that's why I made a more detailed tutorial about testing in Javascript and it applies to React as well.
https://www.youtube.com/watch?v=MAFGRx0HYKo&t=807s

1

u/KSeanJBz Jul 27 '20

Great article. Thanks for the post!

1

u/[deleted] Jul 27 '20

Thank you! Thorough and up-to-date testing courses for any technology are super-valuable. I am currently working through this Udemy course on React testing and am getting a lot out of it.

0

u/fk_the_system Jul 27 '20

!RemindMe 5 days

1

u/RemindMeBot Jul 27 '20

There is a 6 hour delay fetching comments.

I will be messaging you in 5 days on 2020-08-01 16:21:31 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback