To get 100% coverage of my Saga files, I learn how to test observers.
I was looking for search queries, there are several answers on HOW to test observers. That is a saga that does takeEvery or takeLatest .
However, all testing methods seem to basically copy the implementation. So, what's the point of writing a test if it's the same?
Example:
Test Method 1:
import { takeEvery } from 'redux-saga/effects' import { watchFetchResults, fetchResults } from '../sagas' import { FETCH_RESULTS } from '../actions' describe('watchFetchResults()', () => { const gen = watchFetchResults()
Test Method 2: with an assistant, such as the Redaga Saga Test Plan
This is a different way of writing, but again, we basically do the same thing as the implementation.
import testSaga from 'redux-saga-test-plan' import { watchFetchResults, fetchResults } from '../sagas' import { FETCH_RESULTS } from '../actions' it('fire on FETCH_RESULTS', () => { testSaga(watchFetchResults) .next() .takeEvery(FETCH_RESULTS, fetchResults) .finish() .isDone() })
Instead, I would just like to know if watchFestchResults all FETCH_RESULTS. Or even if it fires takeEvery() . No matter how it should be.
Or is this really a way to do this?
unit-testing redux-saga
publicJorn
source share