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

View other answers to this thread
Saravanan Shanmugam's photo

Hi Kent, I have tweeted this question: How to deal with testing UI components where styles have to be verified? I'm completely against checking classes of a DOM node. Would you recommend checking styles instead?

Say a button component is to be tested. Like bootstrap, lets say, there are N variants of button based on the props passed viz. primary, alert, info... How about testing this? Can you please more insights on this?

Kent C. Dodds's photo

Hi Saravanan,

Styles are all about the way the component looks. You can't test that reliably without visual regression testing tools. So if you need confidence that the look of your components remains unchanged, I recommend you take a look Applitools or Percy. Good luck!

Saravanan Shanmugam's photo

Kent C. Dodds Thank you Kent for the recommendation. May I know how different it is from snapshot testing?