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

redux-mock-store

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-mock-store - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

dist/index-cjs.js

37

package.json
{
"name": "redux-mock-store",
"version": "1.5.4",
"version": "1.5.5",
"description": "A mock store for testing your redux async action creators and middleware",
"main": "lib/index.js",
"main": "dist/index-cjs.js",
"module": "dist/index-es.js",
"js:next": "dist/index-es.js",
"browser": "dist/index-umd.min.js",
"scripts": {
"prepublish": "rimraf lib && babel src --out-dir lib",
"prepublish": "rimraf lib && rimraf dist && npm run build",
"build:cjs": "babel src --out-file dist/index-cjs.js",
"build:umd": "cross-env BABEL_ENV=es NODE_ENV=development rollup -f umd -c -i src/index.js -o dist/index-umd.js",
"build:umd:min": "cross-env BABEL_ENV=es NODE_ENV=production rollup -f umd -c -i src/index.js -o dist/index-umd.min.js",
"build:es": "cross-env BABEL_ENV=es NODE_ENV=development rollup -f es -c -i src/index.js -o dist/index-es.js",
"build": "npm run build:umd && npm run build:umd:min && npm run build:es && npm run build:cjs",
"lint": "standard src/*.js test/*.js",
"pretest": "npm run lint",
"test": "mocha --compilers js:babel-core/register --reporter spec test/*.js"
"test": "npm run build && npm run test:unit && npm run test:cjs && npm run test:es",
"test:unit": "mocha --compilers js:babel-core/register --reporter spec test/*.js",
"test:cjs": "mocha --reporter spec test/builds/cjs.js",
"test:es": "mocha --compilers js:babel-core/register --reporter spec test/builds/es.js"
},

@@ -25,3 +36,5 @@ "repository": {

"babel-core": "^6.13.2",
"babel-preset-es2015": "^6.13.2",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.0.1",
"expect": "^1.12.2",

@@ -32,2 +45,8 @@ "mocha": "^2.3.3",

"rimraf": "^2.4.3",
"rollup": "^0.45.1",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.2.6",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-plugin-uglify": "^2.0.1",
"sinon": "^1.17.2",

@@ -38,3 +57,11 @@ "standard": "^7.1.2"

"lodash.isplainobject": "^4.0.6"
},
"peerDependencies": {
"redux": "*"
},
"prettier": {
"singleQuote": true,
"semi": false,
"trailingComma": "none"
}
}

@@ -0,4 +1,25 @@

# Deprecation notice
The Redux team does not recommend testing using this library. Instead, see our [docs](https://redux.js.org/usage/writing-tests) for recommended practices, using a real store.
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:
```js
it('should add a todo', () => {
const store = makeStore() // a user defined reusable store factory
store.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.
# redux-mock-store [![Circle CI](https://circleci.com/gh/arnaudbenard/redux-mock-store/tree/master.svg?style=svg)](https://circleci.com/gh/arnaudbenard/redux-mock-store/tree/master)
![npm](https://nodei.co/npm/redux-mock-store.png?downloads=true&downloadRank=true&stars=true)

@@ -39,3 +60,2 @@

it('should dispatch action', () => {
// Initialize mockstore with empty state

@@ -73,7 +93,7 @@ const initialState = {}

function fetchData () {
return dispatch => {
function fetchData() {
return (dispatch) => {
return fetch('/users.json') // Some async action with promise
.then(() => dispatch(success()))
};
}
}

@@ -85,7 +105,6 @@

// Return the promise
return store.dispatch(fetchData())
.then(() => {
const actions = store.getActions()
expect(actions[0]).toEqual(success())
})
return store.dispatch(fetchData()).then(() => {
const actions = store.getActions()
expect(actions[0]).toEqual(success())
})
})

@@ -99,2 +118,3 @@ ```

```
Configure mock store by applying the middlewares.

@@ -105,2 +125,3 @@

```
Returns an instance of the configured mock store. If you want to reset your store after every test, you should call this function.

@@ -111,2 +132,3 @@

```
Dispatches an action through the mock store. The action will be stored in an array inside the instance and executed.

@@ -117,2 +139,3 @@

```
Returns the state of the mock store.

@@ -123,2 +146,3 @@

```
Returns the actions of the mock store.

@@ -129,2 +153,3 @@

```
Clears the stored actions.

@@ -135,2 +160,3 @@

```
Subscribe to the store.

@@ -141,2 +167,3 @@

```
Follows the Redux API.

@@ -148,4 +175,12 @@

### Versions
The following versions are exposed by redux-mock-store from the `package.json`:
- `main`: commonJS Version
- `module`/`js:next`: ES Module Version
- `browser` : UMD version
## License
The MIT License
The MIT License
lib/index.js
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