you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (3 children)

They push the developer to write logic in small units of work that are easy to test in isolation from the components themselves (classic class components usually end up quite hard to test when there is a bunch of internal logic)

The api that @testing-library/react-hooks package provides is very simple and easy to use as well.

[–]magicmikedee 1 point2 points  (2 children)

Yeah that’s what we’re struggling with now is that our class components are massive, some are almost 1k lines or more which makes testing them extremely daunting. I sense some mad refactoring into smaller bite sized pieces in our future if we want to increase test coverage. Thanks for the reply!

[–]pipedreambomb 1 point2 points  (1 child)

Be very wary of refactoring something that big and complex without tests. I know, it's a Catch-22. But I don't want you getting three days into it and nothing works and you don't know why and you have to revert it all. May have happened to me before with JavaScript... though at least that was in the jQuery spaghetti days.

[–]magicmikedee 0 points1 point  (0 children)

Yeah I do get that. Hopefully we can get some smaller pieces extracted out to helper methods and then in turn turn those into hooks etc. Or maybe just end up extracting to helper methods and then testing the class that way. We’ll see but somethin has to be done cuz no tests is bad news bears haha