Contain doesn't work in react 15?
Closed this issue · 2 comments
RobinClowers commented
I just upgraded to react 15.0.1, enzyme 2.3.0, and chai-enzyme 0.4.2. I have a pretty simple test:
const component = enzymeShallow(
<ParentComponent {...props}/>
)
expect(component).to.contain(ChildComponent)
I get this error:
ShallowWrapper::contains() can only be called with ReactElement (or array of them), string or number as argument.
The only odd thing is that ChildComponent
is a sinon stub, but the error indicates that it never even got to the actual assertion. What am I doing wrong?
RobinClowers commented
In retrospect, this seems like a problem with Enzyme, not this lib. Feel free to close this if that's the case.
RobinClowers commented
I switched to using containsMatchingElement
, which worked.