Test Simple and Complex Effects in Redux Saga

InstructorTyler Clark

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
~ 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
~ 6 years ago

^^^^

Benji
~ 5 years ago

What Kevin said

Tyler Clarkinstructor
~ 5 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
~ 4 years ago

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