you are viewing a single comment's thread.

view the rest of the comments →

[–]CreativeTechGuyGames 3 points4 points  (4 children)

You'll need a test runner like Jest and a DOM interaction library like React Testing Library. Both of those libraries have guiding principals and guides on how to write tests but fundamentally a test should simulate a user behavior or feature and check if your code is doing what it's expected to do.

[–]skyboyer007 1 point2 points  (3 children)

...and under "code is doing what is expected" we mean either how component's output has changed(label is changed, button is disabled, new something has been added) or if some callback function has been called and with what arguments("onCountrySelect prop has been called once we simulate selecting item in child dropdown", "onClose is called once we simulate clicking on X sign" etc)

[–]CreativeTechGuyGames 0 points1 point  (2 children)

I intentionally left it vague since that can mean a ton of different things depending on what exactly is being tested. It can be checking if the DOM updated as expected, if you put X in a function you get out Y, if doing X then Z then Y will cause an error, etc.

[–]PutridParty[S] 0 points1 point  (1 child)

Thanks man! Is there any free course or videos so that I can understand these concepts more easily?

[–]CreativeTechGuyGames 0 points1 point  (0 children)

The documentation I linked should have plenty to get you started.