These are chat archives for airbnb/enzyme

Mar 2016
Leland Richardson
Mar 08 2016 00:25
Adam Duro
Mar 08 2016 03:40
Is anyone using Enzyme to test redux connected "Container" components?
I cannot for the life of me figure out how to get a Container that has been connected using "react-redux" to render properly using Enzyme
Leland Richardson
Mar 08 2016 03:48
@duro a “container” component is a higher order component. These components usually just manage state and pass props to the wrapped component in their render method
if you are using “shallow” with one of these components, it will only render the single node of the wrapped component, since it only shallowly rendered
mount will render everything down to the bottom of the tree
but the ideal way to handle this is to test the pure unwrapped component directly using shallow
if you export the wrapped component like export default connect(…)
then you can also export the pure component by doing something like
export { Foo as PureComponent }
and then in your tests grab that and test that instead
or alternatively, you can separate your pure components from the “connected” ones