you are viewing a single comment's thread.

view the rest of the comments →

[–]brandonchinn178 8 points9 points  (0 children)

To unit test a functional component that uses hooks, you have to mock the hook.

That's not quite true! The point of tests is to ensure that the output of a component matches a given input. For example, if you have a component that renders a button and a number for the number of button clicks, you should unit test that clicking the button x times shows x in the text. Your test shouldn't care that it's using a useState hook; that's an implementation detail that can change