I'm Kent C. Dodds. I help people make the world better through quality software. Ask me anything!

View other answers to this thread
Alan Zhang's photo

Hi Kent,

I'm a big fan of yours and will be attending your React Suspense workshop at Reactathon SF this year!

I was wondering how you decide what UI components to test? Currently, the project that i'm working on has almost a 1:1 component : test file mapping, where each file is enzyme shallow mounted and unit tested in its separate test file.

To avoid testing implementation details, one of the first pieces of advice you give is to fully mount your components instead of shallow mounting them. However, if I do this in all my test the way they are currently structured, it seems we test many components multiple times in a way that feels redundant.

I was wondering if this redundancy is actually okay, and if not, how you decided what components to test in what way?

Kent C. Dodds's photo

Hi Alan!

That's great! I look forward to meeting you at the workshop :)

This is a great question. Your intuition is correct that there are many components that are useless to test (especially when they're being covered by higher-level tests). This blog post may help: How to know what to test. Good luck!