redux-saga-test-engine is a testing utility designed to simplify the process of testing Redux Saga generator functions. It provides a structured API for collecting specific Redux Saga effects (like `PUT` and `CALL`) and mapping yielded effects to predefined return values, eliminating the need for manual iteration over generator steps. The current stable version is 3.0.0. While no explicit release cadence is stated, major versions introduce breaking changes to the top-level API, with minor versions providing feature enhancements and bug fixes. It differentiates itself from alternatives like `redux-saga-test` and `redux-saga-test-plan` by offering a distinct approach to effect collection and environment stubbing, aiming for a more direct and less verbose testing experience, particularly when focusing on the effects a saga produces rather than its step-by-step execution.
npm install redux-saga-test-engineVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of `createSagaTestEngine` to test a Redux Saga, including how to collect specific effect types and provide mock responses for `select` and `call` effects, effectively isolating the saga logic.
Review the README for the current API (v3.0.0) and refactor test setup to use `createSagaTestEngine` or the `collectPuts` helper, adapting environment mappings to the new array-of-arrays format for yielded values.
Use `stub()` with a generator function or an object that correctly simulates the expected return value, including any methods. For example, `[call(apiCall), stub(function* () { yield { json: () => ({ data: 'mock' }) } })]`.Carefully review your saga and ensure every `select` and `call` (or any other effect you're not collecting) has an entry in the `envMapping` array, providing the exact value the saga should receive from that yielded effect.
Ensure the stub for the `call` effect returns an object that accurately mimics the expected API response, including any methods like `json()` that the saga will invoke. Example: `[call(API.fetch), { json: () => ({}) }]` or using `stub()` with a generator that yields such an object.Inspect the saga under test and the `envMapping` to confirm that every `select` and `call` effect is explicitly mapped to a return value. Ensure the effect object passed as the key in the mapping exactly matches the effect yielded by the saga.
No dependency data recorded yet.