redux-tdd
v1.1.0
Published
Dot-chaining syntax for testing the Redux data-flow of React components
Downloads
38
Readme
Redux TDD
Install
npm install --save-dev redux-tdd
import reduxTdd from 'redux-tdd';
// reduxTdd() takes as arguments an object which will be passed to redux combineReducers()
// and a function which returns an array of components that map your state to props
reduxTdd({ counter: counterReducer }, state => [
<Counter
onClick={incrementAction}
counter={state.counter.count} />
])
.action(props => props.onClick()) // action() takes a function that must return a redux action
.toMatchProps({ counter: 1 }) // toMatchProps() checks whether the component took the correct props
.contains(<span>1</span>) // finally contains() checks that the component contains correct value
About
Check out my HOW-TO article on Hacker Noon: https://hackernoon.com/redux-tdd-a-deep-dive-344cd7682a54
Also you can read more about this technique in our freeCodeCamp article: https://medium.freecodecamp.org/test-driven-development-with-react-and-redux-using-redux-tdd-3fd3be299918
Also to learn more in depth how to use Redux TDD please look inside the /test
folder.