Custom rendering in React Testing Library Done Right

This post is also available in my personal site:
https://matan.io/posts/custom-rendering-rtl

Browsing multiple projects, I encountered a recurring pattern when trying to write a custom render for components that use Providers (React-Redux’s Provider, React-Intl’s IntlProvider for example).
This pattern usually looks like this:

renderWithRedux example, it’s a bad practice

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matan Borenkraout

Matan Borenkraout

Frontend Engineer | Creating better software, one word at a time | Matan.io