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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With