JSPM

redux-action-logging

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 530
  • Score
    100M100P100Q107874F
  • License MIT

Redux testing utility middleware to log actions received by a store without mocking that store.

Package Exports

  • redux-action-logging

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-action-logging) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

redux-action-logging

Redux testing utility middlware to log actions received by a store without mocking that store.

Installation

npm install redux-action-logging

Add redux-action-logging to your middleware chain. You likely only want to do this in your test suite and not in production

import { createStore, applyMiddleware } from "redux"
import reducer from "./reducer"

import {
  storeActionsMiddleware,
  storeActions
} from "redux-action-logging"

const middlewares = [storeActionsMiddleware]
store = applyMiddleware(...middlewares)(createStore)(reducer)

Usage

// Given these actions sent to your store:
store.dispatch({ type: FOO })
store.dispatch({ type: BAR })
store.dispatch({ type: BAZ, value: 10 })
store.dispatch((dispatch, getState) => dispatch({type: QUX }))

// These return true:
storeActions.has(FOO)
storeActions.has(FOO, BAR)
storeActions.has(BAZ, BAR)
storeActions.has({ type: BAZ, value: 10 })
storeActions.has(QUX)
storeActions.has(
  BAR,
  { type: BAZ, value: 10}
)

// These return false:
storeActions.has(XYZZY)
storeActions.has(FOO, XYZZY)
storeActions.has({ type: BAZ, value: 5 })
storeActions.has(
  BAR,
  { type: BAZ, value: 5}
)


storeActions.actions() // returns array of all actions received by your store
storeActions.clear()   // clears array

License

MIT