How to setup testing with Redux, React Router, and Apollo GraphQL

I recently had to write tests for a React app that used Redux, React Router and Apollo Graphql. I first tried using enzyme to render the components, but couldn’t get it to work as intended, so I opted for the react-testing-library.

I took the example from and modified it to use apollo graphql test provider only if the mocks option is provided.

code sample

And for testing the component:

code sample

Hope this helps!

Written on July 29, 2020