I've been trying for a bit to do some tests for a stateless functional component. I've been trying to use airbnb's enzyme library (now recommended on the FB Test Utils documentation page). Unlike TestUtils, it's able to render stateless components, whereas TestUtils seems to return null when rendering with renderIntoDocument. Normally, I use components rendered using enzyme's mount or shallow functions with unexpected-react by running the assertions on wrapper.node, where wrapper is the result of calling mount or shallow. For normal class-based components, wrapper.node matches one of the selected types that unexpcted-react expects, i.e. ReactElement, RenderedReactElement, and so on. But for stateless components it is StatelessComponent, and this causes unexpected-react to complain that there's "no matching assertion." Any thoughts about how to get around this?
I've been trying for a bit to do some tests for a stateless functional component. I've been trying to use airbnb's enzyme library (now recommended on the FB Test Utils documentation page). Unlike TestUtils, it's able to render stateless components, whereas TestUtils seems to return null when rendering with
renderIntoDocument
. Normally, I use components rendered using enzyme'smount
orshallow
functions with unexpected-react by running the assertions onwrapper.node
, wherewrapper
is the result of callingmount
orshallow
. For normal class-based components,wrapper.node
matches one of the selected types that unexpcted-react expects, i.e. ReactElement, RenderedReactElement, and so on. But for stateless components it isStatelessComponent
, and this causes unexpected-react to complain that there's "no matching assertion." Any thoughts about how to get around this?