Questions tagged [redux-saga-test-plan]

redux-saga-test-plan is a library for unit testing and integration testing code written with redux-saga, which is a front-end library for application state management written in JavaScript, commonly used with React. This tag should be used for question related to writing tests with this library.

The library redux-saga-test-plan is for unit testing and integration testing code written with redux-saga, which is a front-end library for application state management written in JavaScript, commonly used with React.

This tag should be used for question related to writing tests with this library.

The official documentation for redux-saga-test-plan can be found at http://redux-saga-test-plan.jeremyfairbank.com/

The source can be found at https://github.com/jfairbank/redux-saga-test-plan

48 questions
8
votes
1 answer

Difference between testSaga and expectSaga in redux-saga-test-plan

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.
PhoenixPan
  • 536
  • 7
  • 19
8
votes
1 answer

redux-saga-test-plan put effects do not match, but payload of actual and expected are equal

I'm testing this saga export function* foo() { yield put(actions.start()); yield put(actions.bar({ onSuccess: () => { // do something }, onFailed: () => { // do something else } })); yield…
Reza Erami
  • 153
  • 2
  • 6
5
votes
0 answers

Jest - testing eventChannel Redux-saga

I have one sagas file with 2 functions, one is the saga itself, and the other is the function that is called by my saga, which uses the eventChannel from redux-saga library. export const hardwareBackChannel = () => eventChannel((emit): {} => { …
Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
4
votes
1 answer

How to handle errors in saga testing?

I am trying to test the below saga, but it keeps failing, I think my main issue is mocking up the result, error msg & token status in race effect. Saga export function* handleFetchUser(action) { const token = yield select(getToken); try{ …
Ahmed Imam
  • 1,315
  • 2
  • 19
  • 42
4
votes
1 answer

Cannot figure out how to test redux-saga function with redux-saga-test-plan

I'm teaching myself how to use redux-saga, while at the same time teaching myself unit testing, specifically Jest. I took a sample saga from redux-saga's documentation,…
hairbo
  • 3,113
  • 2
  • 27
  • 34
3
votes
1 answer

How to test selector function with redux-saga-test-plan

I am testing my redux-saga-flow, and I have an issue with testing selector method with select. Selector const selector = (state) => { console.log("selector"); return data; } Redux saga flow export function* testedSagaFlow() { const data =…
Elli Zorro
  • 463
  • 3
  • 19
3
votes
1 answer

ExpectSaga put assertion failes with multiple put effects

The saga has multiple puts. export function* changeItemsSaga(action) { const prerequisite1 = yield select(prerequisite1Selector); // some processing yield put(actions.myAction1(payload1)); // some more processing const…
Jonas Arcangel
  • 2,085
  • 11
  • 55
  • 85
3
votes
1 answer

redux-saga-test-plan: use expectSaga to simulate an thrown exception

Inside my saga, I call an api request. function* sendRequestSaga(): SagaIterator { yield takeEvery(Actions.sendRequest.type, sendApiRequest); } function* sendApiRequest(action: Action) { try { yield call(/*args for calling…
Tera Mind
  • 263
  • 4
  • 17
3
votes
1 answer

Can not provide/test saga when using a reselect selector

I've been writing some redux-saga tests using redux-saga-test-plan but having some issues when trying to provide some selects to fake some values to the expectSaga test. It seems as though the provider isn't replacing our reselect function call with…
3
votes
2 answers

Testing redux-saga takeEvery

I have the following super simple Redux-Saga that I want to test with Jest. function* nextApi() { yield* takeEvery( (action) => !!(action.meta && action.meta.next), nextApiSaga ) } I've looked at Redux-Sagas-Test-Plan, but that only…
David Bradshaw
  • 11,859
  • 3
  • 41
  • 70
2
votes
2 answers

Redux-saga-test-plan expectSaga seems to retain state between independent tests

I have the below two tests import {put, select, takeEvery} from 'redux-saga/effects'; import {combineReducers} from 'redux'; export default class SessionReducer { public static readonly _initialState: any = { disconnectCounts: {}, …
2
votes
1 answer

Testing redux saga with a while loop and delay with redux-saga-test-plan

I have a saga that delays increments a progress from 0 to 100 over 2 seconds. After 2 seconds, the saga will dispatch an action to submit an error. I am at a loss on how to test this using redux-saga-test-plan. import { put, delay, takeLatest } from…
2
votes
1 answer

redux saga is returning SagaTestError: put expectation unmet when checking api call

I'm testing a simple redux saga function using redux test plan, the get posts test is returning a failure SagaTestError: put expectation unmet: Expected -------- { '@@redux-saga/IO': true, combinator: false, type: 'PUT', payload: { channel:…
BARNOWL
  • 3,326
  • 10
  • 44
  • 80
2
votes
2 answers

How to test sagas when there are functions not using 'yield' or an effect like 'call' or 'put'?

In all the examples I've found everyone is using yield call(), yield put(), etc. on their sagas. Right now I have a saga that just executes a function without using yield call(). This function is executed after a select effect and before a call…
Ostos
  • 134
  • 1
  • 8
2
votes
0 answers

How to mock function (not just return value of the function) in "redux-saga-test-plan"?

I can only mock the return value of the generator function expectSaga(func1) .provide({ call: ({ fn }, next) => (fn === api) ? "this is mock return value" : next() }) .dispatch({ type: "TEST_ACTION" }) .run() Is there anyway to mock…
1
2 3 4