I don’t use Redux in any real production apps, so I have less exposure to it, but here’s some general guidelines:
- Testing that
connectwired your components up to the store is a concern of Redux itself, so testing connected components fails rule #2 from my post.
- Your component tests should be around your unconnected components. If your app only cares about using your connected component, sometimes it can be useful to make a “private named export” just for using in your tests, like so:
const MyComponent = /* ... */
const MyConnectedComponent = connect(/* ... */)(MyComponent);
export default MyComponent;
export const _UnconnectedMyComponent = MyComponent;
- You should test your
mapDispatchToProps, etc functions.
- You should use selectors throughout your store to make your state as modular as possible! This will make it easier to unit test.