W3cubDocs

/Enzyme

.exists([selector]) => Boolean

Returns whether or not any nodes exist in the wrapper. Or, if a selector is passed in, whether that selector has any matches in the wrapper.

Arguments

  1. selector (EnzymeSelector [optional]): The selector to check existence for.

Returns

Boolean: whether or not any nodes are on the list, or the selector had any matches.

Example

const wrapper = mount(<div className="some-class" />);
expect(wrapper.exists('.some-class')).to.equal(true);
expect(wrapper.find('.other-class').exists()).to.equal(false);

© 2015 Airbnb, Inc.
Licensed under the MIT License.
https://airbnb.io/enzyme/docs/api/ReactWrapper/exists.html