2017 is here. I hope you’ve had an enjoyable New Years? These last two weeks seem to have flown by, but then I guess they always do.
I’m going to keep this week’s update short and sweet, as I’m sure you will have had a bunch of accumulated emails to plow through after a two week break.
In the first two videos this week we covered testing the “happy”, and “unhappy” paths through the Request reducer. Writing the tests helped guide us through what should happen, and as your logic gets more complex, tests become ever more important in delivering working code on time, every time:
and
Testing reducers should be easy though. After all, they are pure functions. Where things get a little more involved is in functions that have side effects – calls to our API, and all the perils that entails.
As we’ve already covered, to handle these side effects we are using Redux Saga. But up until now, we haven’t tested these functions. When I first sat down to write a test for a Saga I have to admit, I found it daunting. Thankfully though, testing Redux Sagas is actually really, really easy.
We’re covering the “happy” path through our doLogin
generator function, and in the process we’ll see how easy it is to reliably test functions that contain calls to APIs, or other side effect generating (excuse the pun) activities.