Open EYHN opened 6 years ago
Hi @EYHN , the best way to test it would be with expectSaga
like:
it('test', () => {
const changeLocaleAction = {
type: CHANGE_LOCALE,
};
return expectSaga(yourSagaFn)
.put(changeLocaleAction(navigator.language))
.put(whateverYouWantToTest)
.dispatch(changeLocaleAction)
.run();
});
I don't know what happened. Maybe some error messages will be helpful.
Hi, @EYHN.
I'd recommend using expectSaga
like @samuelcastro suggested.
If you want to use testSaga
, then make sure you're using the correct assertion method.
Are you using the takeLatest
effect creator (not the helper)? That is, are you importing takeLatest
like this?
import { takeLatest } from 'redux-saga/effects'
If so, then you need to use takeLatestEffect
in your test after calling next()
, which is documented here.
describe('language Saga', () => {
it('should start task to watch for CHANGE_LOCALE action', () => {
testSaga(language)
.next()
.takeLatest(CHANGE_LOCALE, changeLocale);
});
});
Hope that helps.
Any update? I have the same error
Same issue: SagaTestError: Assertion 2 failed: actual takeLatest did not take a pattern
any update?
saga.js
test.js
error message: