lundi 1 août 2016

When should you use render and shallow in enzyme?

prior to posting this question, I tried to search in sqa stackexchange but I found no post about shallow and render there, so I hope someone can help me out here.

When should I use shallow and render in testing react components? Based on the airbnb docs, I've made some opinions on the difference of the two:

  1. Since shallow is testing components as a unit, so it should be used for 'parent' components. (ex. Tables, Wrappers, etc.)

  2. Render is for child components.

The reason I asked this question, is that I'm having a hard time to figure out which one I should use (though the docs say that they're very similar)

So, how do I know which one to use in a specific scenario?

Aucun commentaire:

Enregistrer un commentaire