{"library":"spy-middleware","title":"spy-middleware","type":"library","description":"spy-middleware is a Redux middleware for spying on dispatched actions in tests. Version 1.2.2 is the latest stable release. It provides methods to retrieve dispatched actions, query for specific actions, and await actions that have been dispatched or will be dispatched. Unlike simple action loggers, it supports promise-based waiting for actions (until/untilNext), which integrates well with async test patterns. Ideal for integration testing of Redux stores where you need to assert on action sequences or wait for asynchronous side effects.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install spy-middleware"],"cli":null},"imports":["import makeSpyMiddleware from 'spy-middleware'","import makeSpyMiddleware from 'spy-middleware'","const spyMiddleware = makeSpyMiddleware(); spyMiddleware.getActions(); spyMiddleware.untilNext(); etc."],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/drpicox/spy-middleware","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/spy-middleware","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport makeSpyMiddleware from 'spy-middleware';\n\nconst spyMiddleware = makeSpyMiddleware();\nconst reducer = (state = [], action) => [...state, action.type];\nconst store = createStore(reducer, applyMiddleware(spyMiddleware));\n\nstore.dispatch({ type: 'FIRST' });\nstore.dispatch({ type: 'SECOND' });\n\nconsole.log(spyMiddleware.getActions()); // [{ type: 'FIRST' }, { type: 'SECOND' }]\n\n// Wait for a specific action\nsetTimeout(() => store.dispatch({ type: 'THIRD' }), 10);\nspyMiddleware.untilNext('THIRD').then(action => console.log('Got:', action));","lang":"javascript","description":"Shows how to create spy middleware, apply to store, dispatch actions, get all actions, and wait for an action using untilNext.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}