How do you test react components?

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?

Comments (2)

Ajinkya Borade's photo

Im just using React Jest Enzyme. Even with Hooks

Luis Henrique's photo

Front-end Web Developer

Enzyme supports hooks?