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.
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
testSaga
. It's often just a bit more tedious if you have some effects you don't care about testing explicitly. And if you add steps in your saga you will have to update all affected tests so everything is a bit more brittle. –
Carlsen © 2022 - 2024 — McMap. All rights reserved.
testSaga
is stricter thanexpectSaga
, does that mean we could usetestSaga
regardless? – Dahlia