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.
npm install redux-saga-test-planVerified import paths — ran on the pinned version, not inferred.
Demonstrates an integration test for a Redux Saga using `expectSaga`, including effect assertions and dispatching actions within a test runner like Jest.
Upgrade Node.js to version 8 or higher.
Review your project's Babel configuration and ensure compatibility with Babel 7. Upgrade other Babel-related dependencies if necessary.
Ensure a global `Promise` polyfill (e.g., `core-js/es/promise`) is loaded before running tests if your environment does not provide one natively.
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.
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');`.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.
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.