{"id":13930,"library":"redux-saga-test-plan","title":"Redux Saga Test Plan","description":"Redux Saga Test Plan is a JavaScript/TypeScript library designed to streamline the testing of Redux Sagas. Currently at version 4.0.6, it provides robust APIs for both integration and unit testing methodologies. The library allows developers to test sagas either by asserting the exact order and type of yielded effects (unit testing with `testSaga`, though not in this excerpt) or by focusing on the overall behavior and side effects, such as dispatched actions, when the saga runs with a mock Redux store (`expectSaga`). It features a chainable API and a powerful provider system for mocking dependencies like `call` effects, allowing for isolated and predictable tests. Releases for major versions are carefully planned, often preceded by release candidates, while minor and patch versions address bugs and introduce features within the stable major release. Key differentiators include its dual-approach to testing (unit and integration) and its comprehensive mocking capabilities via providers.","status":"active","version":"4.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/jfairbank/redux-saga-test-plan","tags":["javascript","redux","saga","redux-saga","test","testing","tdd","bdd","typescript"],"install":[{"cmd":"npm install redux-saga-test-plan","lang":"bash","label":"npm"},{"cmd":"yarn add redux-saga-test-plan","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-saga-test-plan","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for Redux Saga functionality","package":"redux-saga","optional":false},{"reason":"Internal Redux Saga utility","package":"@redux-saga/is","optional":false},{"reason":"Internal Redux Saga utility","package":"@redux-saga/symbols","optional":false}],"imports":[{"note":"Primary named export for integration testing. CommonJS `require` is not officially supported and may lead to issues without proper transpilation.","wrong":"const expectSaga = require('redux-saga-test-plan').expectSaga;","symbol":"expectSaga","correct":"import { expectSaga } from 'redux-saga-test-plan';"},{"note":"Named export for unit testing sagas. Do not use default import.","wrong":"import testSaga from 'redux-saga-test-plan';","symbol":"testSaga","correct":"import { testSaga } from 'redux-saga-test-plan';"},{"note":"Providers for mocking Redux Saga effects are imported from the 'redux-saga-test-plan/providers' subpath, not the main package entry point. The 'P' alias is a common convention for these providers.","wrong":"import { P } from 'redux-saga-test-plan';","symbol":"P (providers)","correct":"import { call, select, put } from 'redux-saga-test-plan/providers';"}],"quickstart":{"code":"import { call, put, take } from 'redux-saga/effects';\nimport { expectSaga } from 'redux-saga-test-plan';\n\nfunction* userSaga(api) {\n  const action = yield take('REQUEST_USER');\n  const user = yield call(api.fetchUser, action.payload);\n\n  yield put({ type: 'RECEIVE_USER', payload: user });\n}\n\nit('just works!', () => {\n  const api = {\n    fetchUser: id => ({ id, name: 'Tucker' }),\n  };\n\n  return expectSaga(userSaga, api)\n    // Assert that the `put` will eventually happen.\n    .put({\n      type: 'RECEIVE_USER',\n      payload: { id: 42, name: 'Tucker' },\n    })\n\n    // Dispatch any actions that the saga will `take`.\n    .dispatch({ type: 'REQUEST_USER', payload: 42 })\n\n    // Start the test. Returns a Promise.\n    .run();\n});","lang":"typescript","description":"Demonstrates an integration test for a Redux Saga using `expectSaga`, including effect assertions and dispatching actions within a test runner like Jest."},"warnings":[{"fix":"Upgrade Node.js to version 8 or higher.","message":"Version 4.0.0 dropped support for Node.js versions under 8. Users on older Node.js environments must upgrade their Node.js runtime.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Review your project's Babel configuration and ensure compatibility with Babel 7. Upgrade other Babel-related dependencies if necessary.","message":"Version 4.0.0 updated its internal Babel version to 7. This change might affect projects with specific Babel configurations or older Babel versions, potentially requiring adjustments to build processes.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure a global `Promise` polyfill (e.g., `core-js/es/promise`) is loaded before running tests if your environment does not provide one natively.","message":"Integration testing with `expectSaga` requires a global `Promise` object to be available in the environment. In environments lacking this, such as older browsers or specific test runners, a polyfill might be necessary.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure `redux-saga` is updated to a compatible version (e.g., ^1.1.1 or newer). Review and adjust any custom TypeScript types or interfaces that interact with `redux-saga-test-plan`'s APIs.","message":"TypeScript type definitions received significant fixes and updates in version 4.0.0 and subsequent RCs, particularly concerning compatibility with `redux-saga` v1.1.1. Users upgrading from pre-4.x versions may encounter type errors, especially if using older `redux-saga` versions or complex type inference.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'4.0.6':24 'action':76 'address':126 'allow':38,103 'api':28,91 'approach':142 'assert':45 'bdd':164 'behavior':69 'bug':127 'call':101 'candid':120 'capabl':152 'care':114 'chainabl':90 'comprehens':150 'current':21 'depend':99 'design':13 'develop':39 'differenti':137 'dispatch':75 'dual':141 'dual-approach':140 'effect':53,72,102 'either':43 'exact':47 'excerpt':62 'expectsaga':86 'featur':88,130 'focus':65 'includ':138 'integr':31,147 'introduc':129 'isol':105 'javascript':155 'javascript/typescript':11 'key':136 'librari':12,37 'like':100 'major':111,134 'methodolog':35 'minor':122 'mock':83,98,151 'often':116 'order':48 'overal':68 'patch':124 'plan':4,8,115 'power':94 'preced':117 'predict':107 'provid':26,95,154 'redux':1,5,19,84,156,159 'redux-saga':158 'releas':109,119,135 'robust':27 'run':80 'saga':2,6,20,42,79,157,160 'side':71 'stabl':133 'store':85 'streamlin':15 'system':96 'tdd':163 'test':3,7,17,34,41,55,108,144,161,162 'testsaga':57 'though':58 'type':50 'typescript':165 'unit':33,54,145 'version':23,112,125 'via':153 'within':131 'yield':52","created_at":"2026-04-20T01:57:03.377520+00:00","updated_at":"2026-04-20T01:57:03.377520+00:00","problems":[{"fix":"For ESM, use `import { expectSaga } from 'redux-saga-test-plan';`. For CommonJS (if transpiling or using older Node), ensure named destructuring: `const { expectSaga } = require('redux-saga-test-plan');`.","cause":"Attempting to import `expectSaga` using CommonJS `require` without proper destructuring, or using a default import in ESM where a named import is expected.","error":"TypeError: expectSaga is not a function"},{"fix":"Verify `redux-saga-test-plan` is correctly installed. Ensure `tsconfig.json` has `moduleResolution` set to 'node' and that `redux-saga` (a peer dependency) is also installed and compatible with the installed `redux-saga-test-plan` version.","cause":"TypeScript compiler cannot locate the package's type definitions, possibly due to incorrect installation, `tsconfig.json` misconfiguration, or incompatible `redux-saga` peer dependency version.","error":"TS2307: Cannot find module 'redux-saga-test-plan' or its corresponding type declarations."},{"fix":"Examine the saga's logic for potential infinite loops or missing `yield take` effects. Ensure all necessary actions are dispatched via `.dispatch()` in your test plan. Increase the timeout if the saga is genuinely long-running, but this often indicates a logical issue in the saga or test setup.","cause":"The saga under test either entered an infinite loop, waited indefinitely for an action that was never dispatched, or encountered an unhandled error causing it to halt without resolution.","error":"Saga test timed out. Saga did not complete within the allotted time."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://redux-saga-test-plan.jeremyfairbank.com","github":"https://github.com/jfairbank/redux-saga-test-plan","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/redux-saga-test-plan","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}