Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/redux-mock-store

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/redux-mock-store

TypeScript definitions for Redux Mock Store

  • 1.0.3
  • ts3.6
  • ts3.7
  • ts3.8
  • ts3.9
  • ts4.0
  • ts4.1
  • ts4.2
  • ts4.3
  • ts4.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
652K
decreased by-5.2%
Maintainers
1
Weekly downloads
 
Created

What is @types/redux-mock-store?

@types/redux-mock-store provides TypeScript definitions for the redux-mock-store package, which is used for testing Redux async action creators and middleware. It allows developers to create a mock store for testing purposes, ensuring that dispatched actions and resulting state changes can be easily verified.

What are @types/redux-mock-store's main functionalities?

Creating a Mock Store

This feature allows you to create a mock store with specified middlewares. In this example, redux-thunk is used as middleware.

const configureMockStore = require('redux-mock-store').default;
const thunk = require('redux-thunk').default;
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
const store = mockStore({});

Dispatching Actions

This feature allows you to dispatch actions to the mock store and then retrieve the list of dispatched actions for verification.

store.dispatch({ type: 'ACTION_TYPE' });
const actions = store.getActions();
console.log(actions);

Testing Async Actions

This feature allows you to test async actions by dispatching them to the mock store and then verifying the resulting actions.

const myAsyncAction = () => {
  return (dispatch) => {
    return fetch('/endpoint')
      .then(response => response.json())
      .then(data => dispatch({ type: 'SUCCESS', payload: data }))
      .catch(error => dispatch({ type: 'FAILURE', error }));
  };
};

store.dispatch(myAsyncAction()).then(() => {
  const actions = store.getActions();
  expect(actions[0]).toEqual({ type: 'SUCCESS', payload: { /* expected data */ } });
});

Other packages similar to @types/redux-mock-store

FAQs

Package last updated on 09 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc