Test Simple and Complex Effects in Redux Saga

Share this video with your friends

Send Tweet

In this lesson we will utilize generator functions and effect objects to test our sagas. We’ll walk through different scenarios and how to test each case with Jest.

Kevin Pinny
Kevin Pinny
~ 6 years ago

I like Saga's but I hate testing them. It feels they are testing implementation. Aside from that, if you'd comment out your first "it", the second "it" would fail, because the second assume the first one ran already, no? If so that's not great imo. Re-arranging the tests would break them = bad.

Mason Goetz
Mason Goetz
~ 6 years ago

^^^^

Benji
Benji
~ 6 years ago

What Kevin said

Tyler Clark
Tyler Clark(instructor)
~ 6 years ago

That is a great point Kevin... I have seen others create a wrapper function that takes the saga generator and the second parameter the number of "next()" that's needed to get to the step you are actually testing. So it's a new generator instance for each test. That way you can move the tests around and it still works. Still not very pretty but solves that issue.

BTW it does give you some sort of testing ability compared to not being able to test at all if you used Redux Thunk.

Loren
Loren
~ 4 years ago

Does anyone have an alternative to createMockTask? redux-saga/utils is no longer a part of redux-saga.