Redux Saga Testing
by @anivar
Write tests for Redux Sagas using redux-saga-test-plan, runSaga, and manual generator testing. Covers expectSaga (integration), testSaga (unit), providers, p...
1. Prefer expectSaga over testSaga β integration tests don't break on refactors
2. Use matchers.call.fn() for partial matching β don't couple to exact args unless necessary
3. Use throwError() from providers β not throw new Error() in the provider
4. Test with reducer using .withReducer() + .hasFinalState() to verify state
5. Dispatch actions with .dispatch() to simulate user flows in tests
6. Return the promise (Jest) or await it (Vitest) β don't forget async
7. Use .not.put() to assert actions are NOT dispatched (negative tests)
8. Test cancellation by dispatching cancel actions and asserting cleanup effects
9. Use .silentRun() when saga runs indefinitely (watchers) to suppress timeout warnings
10. Don't test implementation β test behavior (what actions are dispatched, what state results)
clawhub install redux-saga-testing