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
2
votes
1 answer

redux-saga-test-plan expectSaga- Testing reducer with state branch

I am having a bit of trouble properly testing my saga. The issue stems from the fact that when running the saga, the reducer is mounted at state: {...initialState} whereas my saga select effects are expecting the reducer mounted at state:…
2
votes
0 answers

tape/jest not recognizing test case

Created an app using create-react-app. I set up a test file with the suggested convention. But when I run npm test seems, my test case is not recognized. FAIL src\_tests_\saga.test.js ? Test suite failed to run Your test suite must contain…
NSN
  • 740
  • 3
  • 9
  • 26
1
vote
0 answers

redux-saga-test-plan partial assertion on put not matching

I have a Redux saga I am trying to test with redux-saga-test-plan. The saga SomeActions.someAction calls ToastActions.showToast and I am trying to assert on that call. However, it is not matching the output correctly. I don't really care about the…
etnguyen03
  • 580
  • 4
  • 19
1
vote
0 answers

How to mock generator functions in jest and redux-saga-test-plan?

I am new to redux-saga testing. I am trying to write tests for the following generator functions, using jest and redux-saga-test-plan: //saga.ts export function* chooseCorrectGenerator(action: {type: string, payload: { flag: boolean } }){ …
1
vote
0 answers

expectSaga() always times out - even with trivial/empty saga

I'm sure it is a newbie mistake, but I am surprised that the expectSaga() test below times out. -- advice appreciated! import { expectSaga, testSaga } from 'redux-saga-test-plan'; function* saga() {} // ✅ ...this passes it('should be testable with…
Eric
  • 935
  • 1
  • 8
  • 23
1
vote
1 answer

Redux Saga Test Plan - Stub different responses for provided calls

I've got a saga that has some error handling logic in it - I want to test that a call is made three times and provide a response for each invocation. The use case is that the saga retries on the first two errors before giving up, so I need a…
nbpeth
  • 2,967
  • 4
  • 24
  • 34
1
vote
1 answer

How to test all effect with redux-saga-test-plan. All effect do not match

I have a generator that I want to cover with unit-test export default function* gatawayFlow() { yield all([ takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), takeLatest(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow), …
1
vote
1 answer

redux-saga function dont send console log

I want to show on a generator function a console log statement but it doesnt work. Why? import { all, take } from 'redux-saga/effects'; function* authFetch() { console.log('HI'); } function* watcher() { while(true) { yield…
1
vote
0 answers

Redux Saga Test Plan - Integration Tests Fail To Run

I am having trouble getting started with redux-saga-test-plan. The goal that I'm trying to achieve is integration testing my sagas. I'm using create-react-app, so no unique setup. This is my only test and I cannot get it to run. CatActions import *…
Chasen Bettinger
  • 7,194
  • 2
  • 14
  • 30
1
vote
1 answer

take assertion with redux-saga-test-plan that takes a function as pattern gives 'take effects do not match' error

I want to test a saga that yields a take effect which takes a function as pattern, e.g. export function* mySaga(myAction: { type: string; }): Generator { const { type: actionType } = (yield take( …
lolero
  • 1,253
  • 2
  • 10
  • 18
1
vote
1 answer

How can I test yield delay(some_delay) located in a generator function inside a saga file (using jest file)?

in saga file. generator function looks like: function* handleCall(){ yield delay(1000); yield put(act.call()); } I would like to test delay(1000) in test.js file
1
vote
0 answers

Providing call for all returns @@redux-saga/IO

I'm trying to make a test using redux-test-saga-test-plan and describe but I'm having troubles on the yielded return. The target to being tested is the next slice of code: const { tenantDocuments, feedDocuments, historicalDocuments } = yield all({ …
jordivador
  • 1,016
  • 11
  • 26
1
vote
1 answer

Got an error while testing redux-saga with delay functions by using Redux Saga Test Plan library

I'm trying to test my redux-saga functions by using Redux Saga Test Plan library and I'm stuck due to delay functions in my saga. If I remove the line, yield delay(1000) all tests pass without any error. saga.js export function* addWorkoutSaga({…
TTCG
  • 8,805
  • 31
  • 93
  • 141
1
vote
1 answer

Test redux-saga delay amount using redux-saga-test-plan

Background I have a "gradual-backoff" built into a saga using Redux-saga's delay() effect. I am using expectSaga from redux-saga-test-plan to write the test. But in order to get the test to work I had to disable the delay. Question What is the…
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81
1
vote
1 answer

Put expectaion unmet in redux-saga-test plan

So I have a saga which shows fetches some data to show in a table. Action Creators are as follows export const fetchInstanceDataSetAssocSuccess = (records) => { return { type: actionTypes.FETCH_INSTANCE_DATASETS_ASSOC_SUCCESS, records:…
anuragb26
  • 1,467
  • 11
  • 14