Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between testSaga and expectSaga in redux-saga-test-plan

Is it correct to say that expectSaga is for integration testing and testSaga is for general assertions?

In reality, I can actually use them interchangeably for all my tests, so I am a bit confused about when to use which.

like image 844
PhoenixPan Avatar asked Sep 17 '19 00:09

PhoenixPan


1 Answers

I think the subheading line from the README under Unit Testing [1] is the most concise explanation of when you would use testSaga vs expectSaga:

If you want to ensure that your saga yields specific types of effects in a particular order, then you can use the testSaga function.

If you don't care about this level of detail, especially the ordering bit, then expectSaga is less rigid and therefore less brittle to future changes in your sagas. But in some cases you need to be very specific about exactly which effects in which order, in which case you should use testSaga.

[1] https://github.com/jfairbank/redux-saga-test-plan#unit-testing

like image 154
azundo Avatar answered Sep 30 '22 13:09

azundo