@types/redux-mock-store
- Version 1.5.0
- Published
- 7.43 kB
- 1 dependency
- MIT license
Install
npm i @types/redux-mock-store
yarn add @types/redux-mock-store
pnpm add @types/redux-mock-store
Overview
TypeScript definitions for redux-mock-store
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable legacy_configureStore
const legacy_configureStore: <S, DispatchExts = {}>( middlewares?: Redux.Middleware[]) => MockStoreCreator<S, DispatchExts>;
Create Mock Store returns a function that will create a mock store from a state with the same set of set of middleware applied.
Parameter middlewares
The list of middleware to be applied. S The type of state to be held by the store. DispatchExts The additional Dispatch signatures for the middlewares applied.
Functions
function configureStore
configureStore: <S, DispatchExts = {}>( middlewares?: Redux.Middleware[]) => MockStoreCreator<S, DispatchExts>;
Deprecated
The Redux team does not recommend using this package for testing. Instead, check out our to learn more about testing Redux code.
Testing with a mock store leads to potentially confusing behaviour, such as state not updating when actions are dispatched. Additionally, it's a lot less useful to assert on the actions dispatched rather than the observable state changes.
You can test the entire combination of action creators, reducers, and selectors in a single test, for example:
it("should add a todo", () => {const store = makeStore(); // a user defined reusable store factorystore.dispatch(addTodo("Use Redux"));expect(selectTodos(store.getState())).toEqual([{ text: "Use Redux", completed: false }]);});This avoids common pitfalls of testing each of these in isolation, such as mocked state shape becoming out of sync with the actual application.
If you want to use
configureStore
without this visual deprecation warning, use thelegacy_configureStore
export instead.import { legacy_configureStore as configureStore } from 'redux-mock-store';
Interfaces
interface MockStore
interface MockStore<S = any, A extends Redux.Action = Redux.AnyAction> extends Redux.Store<S, A> {}
method clearActions
clearActions: () => void;
method getActions
getActions: () => any[];
Type Aliases
type MockGetState
type MockGetState<S = {}> = (actions: Redux.AnyAction[]) => S;
type MockStoreCreator
type MockStoreCreator<S = {}, DispatchExts = {}> = ( state?: S | MockGetState<S>) => MockStoreEnhanced<S, DispatchExts>;
type MockStoreEnhanced
type MockStoreEnhanced<S = {}, DispatchExts = {}> = MockStore<S> & { dispatch: DispatchExts;};
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/redux-mock-store
.
- Markdown[](https://www.jsdocs.io/package/@types/redux-mock-store)
- HTML<a href="https://www.jsdocs.io/package/@types/redux-mock-store"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1940 ms. - Missing or incorrect documentation? Open an issue for this package.