Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

316
Views
Cómo probar todos los efectos con redux-saga-test-plan. Todos los efectos no coinciden

Tengo un generador que quiero cubrir con unit-test

 export default function* gatawayFlow() { yield all([ takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), takeLatest(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow), ]); }

Escribí una prueba simple con redux-sag-test-plan

 import {expectSaga, testSaga} from 'redux-saga-test-plan'; import gatawayFlow, {getGatewaysFlow, selectGatewayFlow} from '../logic/sagas'; import * as actions from '../logic/actions'; import * as actionTypes from '../logic/actionTypes'; import {takeEvery, takeLatest} from '@redux-saga/core/effects'; // Unit-test describe('Unit tests', () => { test('Test all effect', () => { const saga = testSaga(gatawayFlow); saga .next() .all({ [actionTypes.GET_GATEWAYS_REQUEST]: takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), [actionTypes.SELECT_GATEWAY_REQUEST]: takeLatest(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow) }) .next() .isDone(); // expect(gatawayFlow().next().value).toEqual(all([ // takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), // takeEvery(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow), // ])); ---> THIS TEST WORKS CORRECT }); });

Y mi prueba no pasó. Tengo este error en mi terminal. ¿Alguna idea de cómo puedo solucionarlo?

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe usar all([...effects]) - efectos paralelos en lugar de un objeto de diccionario de la forma {label: effect, ...}

saga.ts :

 import { all, takeEvery, takeLatest } from 'redux-saga/effects'; export const actionTypes = { GET_GATEWAYS_REQUEST: 'GET_GATEWAYS_REQUEST', SELECT_GATEWAY_REQUEST: 'SELECT_GATEWAY_REQUEST', }; export function* getGatewaysFlow() {} export function* selectGatewayFlow() {} export default function* gatawayFlow() { yield all([ takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), takeLatest(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow), ]); }

saga.test.ts :

 import { expectSaga, testSaga } from 'redux-saga-test-plan'; import gatawayFlow, { actionTypes, getGatewaysFlow, selectGatewayFlow } from './saga'; import { takeEvery, takeLatest } from '@redux-saga/core/effects'; describe('Unit tests', () => { test('Test all effect', () => { const saga = testSaga(gatawayFlow); saga .next() .all([ takeEvery(actionTypes.GET_GATEWAYS_REQUEST, getGatewaysFlow), takeLatest(actionTypes.SELECT_GATEWAY_REQUEST, selectGatewayFlow), ]) .next() .isDone(); }); });

resultado de la prueba:

 PASS redux-saga-examples packages/redux-saga-examples/src/stackoverflow/69252089/saga.test.ts Unit tests ✓ Test all effect (2 ms) ----------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------|---------|----------|---------|---------|------------------- All files | 75 | 100 | 20 | 100 | saga.ts | 75 | 100 | 20 | 100 | ----------|---------|----------|---------|---------|------------------- Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 3.553 s Ran all test suites related to changed files.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!