.closest(selector) => ReactWrapper
Returns a wrapper of the first element that matches the selector by traversing up through the wrapped node's ancestors in the tree, starting with itself. It must be a single-node wrapper.
Arguments
-
selector
(EnzymeSelector
): The selector to match.
Returns
ReactWrapper
: A new wrapper that wraps the resulting node.
Examples
const wrapper = mount(<MyComponent />); expect(wrapper.find(Foo).closest('.bar')).to.have.lengthOf(1);
Related Methods
.children([selector]) => ReactWrapper
.parent() => ReactWrapper
.parents([selector]) => ReactWrapper
© 2015 Airbnb, Inc.
Licensed under the MIT License.
https://enzymejs.github.io/enzyme/docs/api/ReactWrapper/closest.html