Skip to content
Andrew Wood edited this page Oct 21, 2018 · 1 revision

When we wanted to add additional screens to our app, we then needed to be able to pass data between those screens. This was not possible with vanilla React and the AppNavigator we are using. Bring on Redux.

Redux is a state management tool. "Actions" are dispatched to "reducers" that update the "store" of state data.

First I refactored the code to achieve the same functionality as we had before on the Homescreen. I ran the test suite to ensure our tests were still passing. Some refactoring here was needed too as to follow the same testing pattern I would need to connect the component to the store, actions and reducers.

I decided that this was starting to become a bad unit test as there was heavy coupling now between different parts of the code. I replaced the redux components with Mocks and ensured that they were being called. I then added separate action and reducer test suites.

This blog post was helpful in deciding the best way to isolate the tests:
https://hackernoon.com/unit-testing-redux-connected-components-692fa3c4441c

Clone this wiki locally