jambit ToiletPaper 111

Testing a saga made easy


You are currently working on a single page application with React? You use Redux for state management? You even managed to encapsulate your asynchronous work steps and side effects (API calls, access to browser caches etc.) with redux-saga? In this case, it might look like that:

Testing a saga made easy

Now, all you need is one further step to achieve mastery: how do you test the paths/cases to make sure that the thing does what it's supposed to do?


Uncle Jeremy Fairbank offers something nice – and it's called a redux-saga-test-plan. Using this toy, you can test your saga integration. I.e. within a test run, it is possible to control the saga via mock Redux actions and special providers so that it takes a certain course (and hopefully triggers an expected Redux action). Using the above saga, a special success test might look like this:


  • Testing a saga made easy
  • .dispatch controls which of the "observed" actions (FETCH_USER_CONFIRMATION_START) is being reacted to.
  • Within .provide, everything that affects the saga is mocked – i.e. any selections from the Redux Application State or calls of other functions.
  • .put specifies which Redux action is expected. The test only turns green if it is actually triggered.

Further Aspects


Author: Robert Gruner / Software Engineer / Office Leipzig

Download Toilet Paper #111: Testing a saga made easy (pdf)

Testing a saga made easy

Cookie Settings

This website uses cookies to personalize content and ads, provide social media features, and analyze website traffic. In addition, information about your use of the website is shared with social media, advertising, and analytics partners. These partners may merge the information with other data that you have provided to them or that they have collected from you using the services.

For more information, please refer to our privacy policy. There you can also change your cookie settings later on.

contact icon

Contact us now