{"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install redux-saga-test-plan"],"cli":null},"imports":["import { expectSaga } from 'redux-saga-test-plan';","import { testSaga } from 'redux-saga-test-plan';","import { call, select, put } from 'redux-saga-test-plan/providers';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}