Home

Awesome

Redux DevTools Test Generator

Watch my presentation at React Europe to see how it works.

Installation

npm install --save-dev redux-devtools-test-generator

Usage

If you use Redux DevTools Extension, Remote Redux DevTools or RemoteDev, it's already there, and no additional actions required.

With redux-devtools and redux-devtools-inspector:

containers/DevTools.js
import React from 'react';
import { createDevTools } from 'redux-devtools';
import Inspector from 'redux-devtools-inspector';
import TestGenerator from 'redux-devtools-test-generator';
import mochaTemplate from 'redux-devtools-test-generator/lib/redux/mocha'; // If using default tests.

const testComponent = (props) => (
  <TestGenerator
    expect={mochaTemplate.expect} wrap={mochaTemplate.wrap} useCodemirror
    {...props}
  />
);

export default createDevTools(
  <Inspector
    tabs: defaultTabs => [...defaultTabs, { name: 'Test', component: testComponent }]
  />
);

Instead of mochaTemplate.expect and mochaTemplate.wrap you can use your function templates.

If useCodemirror specified, include codemirror/lib/codemirror.css style and optionally themes from codemirror/theme/.

Props

NameDescription
assertionString template or function with an object argument containing action, prevState, curState keys, which returns a string representing the assertion (see the function or template).
[wrap]Optional string template or function which gets assertions argument and returns a string (see the example function or template).
[useCodemirror]Boolean. If specified will use codemirror styles.
[theme]String. Name of the codemirror theme.

License

MIT

Created By

If you like this, follow @mdiordiev on twitter.