{"library":"redux-logic-test","title":"Redux Logic Test Utilities","description":"redux-logic-test provides testing utilities specifically designed to simplify the integration and unit testing of Redux Logic modules. It offers a `createMockStore` function that sets up a Redux store with a `redux-logic` middleware instance, allowing developers to easily inject logic, initial state, and mocked dependencies (like an API service) for isolated testing. The utility also includes built-in action tracking and a `whenComplete` helper to ensure all asynchronous logic operations have finished before assertions are made. The current stable version is 2.0.0, which primarily relaxed peer dependency constraints for Redux and Redux Logic without introducing API breaking changes. Release cadence is tied to updates in its core dependencies, `redux` and `redux-logic`, aiming for compatibility rather than frequent feature additions. Its key differentiator is its direct integration with `redux-logic`'s specific patterns, offering a more tailored testing experience than generic Redux testing utilities.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install redux-logic-test"],"cli":null},"imports":["import { createMockStore } from 'redux-logic-test';","const { createMockStore } = require('redux-logic-test');","import type { MockStore } from 'redux-logic-test';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createMockStore } from 'redux-logic-test';\nimport { createLogic } from 'redux-logic';\n\nconst API = {\n  get: (url) => Promise.resolve({ data: `Fetched data from ${url}` })\n};\n\nconst fooLogic = createLogic({\n  type: 'FOO',\n  process({ API, getState, action }, dispatch, done) {\n    API.get(`/api/${action.payload}`)\n      .then(results => {\n        dispatch({ type: 'FOO_SUCCESS', payload: results.data });\n      })\n      .catch(error => {\n        dispatch({ type: 'FOO_FAILURE', payload: error.message });\n      })\n      .finally(() => done());\n  }\n});\n\nconst logic = [fooLogic];\nconst injectedDeps = { API };\n\nconst initialState = { some: 'state' };\nconst reducer = (state = initialState, action) => {\n  switch(action.type) {\n    case 'FOO_SUCCESS': return { ...state, lastFetch: action.payload };\n    default: return state;\n  }\n};\n\nasync function runTest() {\n  const store = createMockStore({\n    initialState,\n    reducer,\n    logic,\n    injectedDeps\n  });\n\n  store.dispatch({ type: 'FOO', payload: 'item123' });\n  store.dispatch({ type: 'BAR' }); // Will be tracked but not processed by logic\n\n  await store.whenComplete(); // Wait for fooLogic to finish\n\n  console.log('Final State:', store.getState());\n  console.log('Dispatched Actions:', store.actions);\n\n  // Example assertions (in a real test framework like Jest)\n  // expect(store.getState().lastFetch).toBe('Fetched data from /api/item123');\n  // expect(store.actions).toEqual([\n  //   { type: 'FOO', payload: 'item123' },\n  //   { type: 'BAR' },\n  //   { type: 'FOO_SUCCESS', payload: 'Fetched data from /api/item123' }\n  // ]);\n}\n\nrunTest();","lang":"javascript","description":"This example demonstrates setting up a mock Redux store with `redux-logic-test`, including a sample logic, mocked dependencies, initial state, and reducer. It dispatches actions, waits for logic completion, and logs the resulting state and dispatched actions for verification.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}