dimanche 7 août 2016

How to properly unit test a React component?

When I test a react component, what are the best practices and what things should I test for? In normal tests I usually just test if the correct state+input leads to the correct state+output

But React components are a bit different. They have state+props+userInput which result in state+markup.

This can lead to many, many different potential scenarios. Do I need to test for the resulting state of all those scenarios? The markup can be huge. Should I test if the whole markup-tree is as expected? Or just part of it? How do I determine what part of the markup to test?

Aucun commentaire:

Enregistrer un commentaire