Returns whether or not at least one of the given react elements in patternNodes
matches an element in the wrapper's render tree. One or more elements of patternNodes
must be matched one or more times. Matching follows the rules for containsMatchingElement
.
patternNodes
(Array<ReactElement>
): The array of nodes whose presence you are detecting in the current instance's render tree.Boolean
: whether or not the current wrapper has a node anywhere in its render tree that looks like one of the array passed in.
const style = { fontSize: 13 }; const wrapper = mount(( <div> <span className="foo">Hello</span> <div style={style}>Goodbye</div> <span>Again</span> </div> )); expect(wrapper.containsAnyMatchingElements([ <span>Bonjour</span>, <div>Goodbye</div>, ])).to.equal(true);
.containsAnyMatchingElements()
expects an array of ReactElement, not a selector (like many other methods). Make sure that when you are calling it you are calling it with an array ReactElement or a JSX expression..matchesElement() => ReactWrapper
- rules for matching each node.containsMatchingElement() => ReactWrapper
- rules for matching whole wrapper.containsAllMatchingElements() => ReactWrapper
- must match all nodes in patternNodes
© 2015 Airbnb, Inc.
Licensed under the MIT License.
https://airbnb.io/enzyme/docs/api/ReactWrapper/containsAnyMatchingElements.html