My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How do you test react components?

slim's photo
slim
·Apr 16, 2019

Today, I read a lot of different articles about testing react component. Everyone propose a different test framework and library such as jest, enzyme, etc... They mentioned different things to test a react component such:

  • using snapshot.
  • Testing props and state.
  • Mocking the apis and functions when they will be used in the component.
  • Testing the behaviour of a component alone. And so on. I want to know acvording to your experiences in testing react components; -Do you test all the components you designed or you choose some of them?
  • What are the important things to test ?
  • How do you test container components ( when you use redux)
  • Do you respect TDD and write the test before implementing the the component?
  • What are the best practices to be token into consideration when writing tests in an application?
  • What is the test coverage in an application or it is relative?