DEV Community

Discussion on: React Best Practices

pavermakov profile image
Pavel Ermakov

How do test components with hooks?

awedis profile image
awedis Author

Check Jest & Enzyme Libraries, Both are specifically designed to test React applications :)

jwhenry3 profile image
Justin Henry

There are some complex interactions that might be just outside of automated testing, so I personally use Storybook so I can manually test hard-to-reach edge cases.

This especially helps when you need a sandbox of real-world state (like connecting to apis and websockets to run through production scenarios without impacting deployments or full-blown application e2e)

lukeshiru profile image
Luke Shiru

If you want the 2021 answer: Jest and React Testing Library for unit testing, and Cypress for e2e!

For old/legacy projects, it might be useful to learn enzyme as well, but if you're creating something from scratch, use modern tools like those instead :D