Registry / testing / redux-test-store

redux-test-store

JSON →
library0.5.0jsnpmunverified

Redux Test Store is a utility library designed to simplify the unit testing of existing Redux stores, focusing on verifying state changes in response to dispatched actions. It allows developers to create a 'testStore' instance that wraps a standard Redux store, providing methods like `when` to assert state mutations and `dispatch` to trigger actions within a controlled testing environment. The package is currently at version 0.5.0, with its last update occurring over seven years ago. Consequently, it is no longer actively maintained and should be considered abandoned. Due to its age and lack of updates, it likely lacks compatibility with contemporary Redux versions (e.g., Redux Toolkit), modern JavaScript features, or current testing practices and tools. Developers should be cautious about using it in new projects or integrating it into modern React/Redux applications.

npm install redux-test-store
INSTALL
IMPORT
SIG · REDUX-TEST-STORE
R
redux-test-store
testingjavascriptv0.5.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createTestStore
import createTestStore from 'redux-test-store';
const createTestStore = require('redux-test-store');
The library primarily uses ES Module syntax. CommonJS require() is not supported.

This quickstart demonstrates how to use `redux-test-store` to test an asynchronous Redux action, asserting state changes upon successful dispatch using a `done` callback.

import createTestStore from 'redux-test-store'; import { createStore, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import assert from 'assert'; // Dummy Redux store setup for example const initialState = { auth: { sets: [] }, data: null }; const authReducer = (state = initialState.auth, action) => { switch (action.type) { case 'AUTH_SUCCESS': return { ...state, sets: action.payload }; case 'CHANGE': // For the example's assertion return { ...state, sets: action.payload }; default: return state; } }; const rootReducer = (state = initialState, action) => ({ auth: authReducer(state.auth, action), data: state.data }); const store = createStore(rootReducer, applyMiddleware(thunk)); const actionTypes = { CHANGE: 'CHANGE', AUTHENTICATE: 'AUTHENTICATE_REQUEST' }; const actions = { authenticate: ({ email, password }) => dispatch => { // Simulate an async auth action setTimeout(() => { const tokenSet = [{ token: 1 }, { token: 2 }]; dispatch({ type: actionTypes.CHANGE, payload: tokenSet }); }, 10); } }; describe('auth action creators', () => { it('should authenticate successfully', (done) => { let tokenSet = [{ token: 1 }, { token: 2 }]; const testStore = createTestStore(store, done); testStore.when(actionTypes.CHANGE, (state, action) => { assert.deepStrictEqual(state.auth.sets, tokenSet); }); testStore.dispatch(actions.authenticate({ email: 'foo@bar.com', password: 'goat' })); }); });
Debug
Known issues
breakingThe library is abandoned and has not been updated in over seven years. It is unlikely to be compatible with modern Redux versions (e.g., Redux Toolkit, Redux 4+), current JavaScript environments, or newer testing frameworks and practices.
fix
Consider migrating to actively maintained Redux testing libraries like `@reduxjs/toolkit/query/react/test-utils` or writing custom mocks/fixtures with standard testing tools (e.g., Jest, Vitest).
affects: >=0.5.0
gotchaTesting asynchronous actions with `redux-test-store` typically relies on `done()` callbacks, which is an older pattern. This can lead to brittle tests or difficulty in debugging async flows compared to modern `async/await` patterns with mock timers.
fix
Ensure that `done()` is called exactly once, typically after all assertions related to the async action are complete. For more complex async tests, consider using `jest.useFakeTimers()` or modern async testing utilities.
affects: >=0.1.0
gotchaLack of maintenance means potential security vulnerabilities in the package or its transitive dependencies may not be patched. Using abandoned software can expose projects to risks.
fix
Regularly audit your `node_modules` for known vulnerabilities. The most robust fix is to replace this library with a currently maintained alternative.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: (0 , _reduxTestStore.default) is not a function
Incorrect CommonJS `require()` syntax used for an ES Module default export, or attempting to access a non-existent default export.
fix
Use named import syntax: `import createTestStore from 'redux-test-store';`
Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
The `done()` callback was never called, usually because an asynchronous action or assertion failed to complete.
fix
Ensure `done()` is called at the appropriate point after all asynchronous operations and assertions are finished within your test. Check for unhandled promises or forgotten `setTimeout` calls.
assert.deepStrictEqual is not defined
The `assert` module is part of Node.js built-in modules and needs to be imported explicitly in a browser-like environment or specified in your testing configuration.
fix
Add `import assert from 'assert';` at the top of your test file, or use a testing framework's assertion library (e.g., `expect` from Jest/Vitest) which is globally available or imported from the framework.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
reduxrequiredCore dependency for Redux store interaction.
Agent activity
4 hits · last 30 days
node
4
Resources
redux-test-store — npm install redux-test-store · libregistry