npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

redux-logic-test

v2.0.0

Published

redux-logic test utilities to facilitate the testing of logic. Create mock store

Readme

redux-logic-test - redux-logic test utilities

"Simplifying testing with redux-logic"

Utilities:

  • createMockStore - create a redux-logic middleware and a redux store, attaching the middleware and providing a mechanism to verify the dispatched actions

Build Status Known Vulnerabilities NPM Version Badge

Installation

redux-logic-test has peerDependencies of redux and redux-logic (which also needs rxjs)

npm install rxjs --save
npm install redux-logic --save
npm install redux --save
npm install redux-logic-test --save-dev

ES6 module import

import { createMockStore } from 'redux-logic-test';

Commonjs

const createMockStore = require('redux-logic-test').default.createMockStore;

UMD/CDN use from script tags

The UMD build is mainly used for using in online playgrounds like jsfiddle.

<script src="https://npmcdn.com/redux@%5E3.6.0/dist/redux.min.js"></script>
<script src="https://unpkg.com/redux-logic@%5E0.11.6/dist/redux-logic.min.js"></script>
<script src="https://unpkg.com/redux-logic-test@%5E1.0.1/dist/redux-logic-test.min.js"></script>
<script type="text/javascript">
  const { createLogic } = ReduxLogic;
  const { createMockStore } = ReduxLogicTest;
  // ready to use createMockStore
</script>

Usage

  import { createMockStore } from 'redux-logic-test';

  // specify as much as necessary for your particular test
  const store = createMockStore({
    initialState: optionalObject,
    reducer: optionalFn, // default: identity reducer
    logic: optionalLogic, // default: []
    injectedDeps: optionalObject, // default {}
    middleware: optionalArr // other mw, exclude logicMiddleware
  });

  store.dispatch(...) // use as necessary for your test

  // when all inflight logic has all completed calls fn + returns promise
  store.whenComplete(fn) - shorthand for store.logicMiddleware.whenComplete(fn)

  store.actions - the actions dispatched, use store.resetActions() to clear
  store.resetActions() - clear store.actions

  // access the logicMiddleware created for logic/injectedDeps props
  // use addLogic, mergeNewLogic, replaceLogic, whenComplete, monitor$
  store.logicMiddleware

Goals

  • simplify the creation of a testing redux store with logicMiddleware attached
  • add built-in middleware to track actions that are dispatched
  • make it easy to verify the actions that were dispatched

Quick example

import { createMockStore } from 'redux-logic-test';
import { createLogic } from 'redux-logic';

const fooLogic = createLogic({
  type: 'FOO',
  process({ API, getState, action }, dispatch, done) {
    API.get(...)
      .then(results => {
        dispatch({ type: 'FOO_SUCCESS', payload: results });
        done();
      });
  }
});

const logic = [fooLogic]; // array of logic to use/test
const injectedDeps = { // include what is needed for logic
  API: api // could include mocked API for easy testing
};

const initialState = {}; // optionally set
const reducer = (state, action) => { return state; }; // optional

const store = createMockStore({
  initialState,
  reducer,
  logic,
  injectedDeps
});

store.dispatch({ type: 'FOO' }); // kick off fetching
store.dispatch({ type: 'BAR' }); // other dispatches
store.whenComplete(() => { // runs this fn when all logic is complete
  expect(store.getState()).toEqual({...});
  expect(store.actions).toEqual([
    { type: 'FOO' },
    { type: 'BAR' },
    { type: 'FOO_SUCCESS', payload: [...] }
  ]);
  // if desired, can reset the actions for more tests
  // store.resetActions(); // clear for more tests

  // be sure to return the whenComplete promise to your test
  // or if using a done cb, call it to indicate that your async
  // test is finished
});

Examples

Live examples

  • basic usage - simple use or createMockStore to test actions that were dispatched (jsfiddle)
  • async search - async search using createMockStore to setup a test store (jsfiddle)

Full examples

  • browser-basic - basic example of using createMockStore to test logic
  • nodejs-basic - simple Node.js example using createMockStore via Commonjs to test logic

Get involved

If you have input or ideas or would like to get involved, you may:

Supporters

This project is supported by CodeWinds Training

License - MIT