Permalink
Switch branches/tags
v2.9.1 v2.9.0 v2.8.2 v2.8.1 v2.8.0 v2.7.1 v2.7.0 v2.6.0 v2.5.2 v2.5.1 v2.5.0 v2.4.2 v2.4.1 v2.4.0 v2.3.0 v2.2.0 v2.1.0 v2.0.0 v1.6.0 v1.5.0 v1.4.1 v1.4.0 v1.3.1 v1.3.0 v1.2.0 v1.1.0 v1.0.0 reagent-v1.0.1 reagent-v1.0.0 enzyme@3.7.0 enzyme@3.6.0 enzyme@3.5.1 enzyme@3.5.0 enzyme@3.4.4 enzyme@3.4.3 enzyme@3.4.2 enzyme@3.4.1 enzyme@3.4.0 enzyme@3.3.0 enzyme@3.2.0 enzyme@3.1.1 enzyme@3.1.0 enzyme@3.0.0 enzyme@3.0.0-beta.7 enzyme@3.0.0-beta.6 enzyme@3.0.0-beta.5 enzyme@3.0.0-beta.4 enzyme@3.0.0-beta.3 enzyme@3.0.0-beta.2 enzyme@3.0.0-beta.1 enzyme-test-suite@1.0.0 enzyme-test-suite@1.0.0-beta.7 enzyme-test-suite@1.0.0-beta.6 enzyme-test-suite@1.0.0-beta.5 enzyme-test-suite@1.0.0-beta.4 enzyme-test-suite@1.0.0-beta.3 enzyme-test-suite@1.0.0-beta.2 enzyme-test-suite@1.0.0-beta.1 enzyme-example-mocha@0.1.0 enzyme-adapter-utils@1.8.1 enzyme-adapter-utils@1.8.0 enzyme-adapter-utils@1.7.0 enzyme-adapter-utils@1.6.1 enzyme-adapter-utils@1.6.0 enzyme-adapter-utils@1.5.0 enzyme-adapter-utils@1.4.0 enzyme-adapter-utils@1.3.0 enzyme-adapter-utils@1.2.0 enzyme-adapter-utils@1.1.1 enzyme-adapter-utils@1.1.0 enzyme-adapter-utils@1.0.1 enzyme-adapter-utils@1.0.0 enzyme-adapter-utils@1.0.0-beta.7 enzyme-adapter-utils@1.0.0-beta.6 enzyme-adapter-utils@1.0.0-beta.5 enzyme-adapter-utils@1.0.0-beta.4 enzyme-adapter-utils@1.0.0-beta.3 enzyme-adapter-utils@1.0.0-beta.2 enzyme-adapter-utils@1.0.0-beta.1 enzyme-adapter-react-helper@1.3.1 enzyme-adapter-react-helper@1.3.0 enzyme-adapter-react-helper@1.2.3 enzyme-adapter-react-helper@1.2.2 enzyme-adapter-react-helper@1.2.1 enzyme-adapter-react-helper@1.2.0 enzyme-adapter-react-helper@1.1.0 enzyme-adapter-react-helper@1.0.3 enzyme-adapter-react-helper@1.0.2 enzyme-adapter-react-helper@1.0.1 enzyme-adapter-react-helper@1.0.0 enzyme-adapter-react-16.3@1.3.0 enzyme-adapter-react-16.3@1.2.0 enzyme-adapter-react-16.3@1.1.1 enzyme-adapter-react-16.3@1.1.0 enzyme-adapter-react-16.3@1.0.0 enzyme-adapter-react-16.2@1.2.1 enzyme-adapter-react-16.2@1.2.0 enzyme-adapter-react-16.2@1.1.0 enzyme-adapter-react-16.2@1.0.0 enzyme-adapter-react-16@1.6.0
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (14 sloc) 555 Bytes

.hasClass(className) => Boolean

Returns whether or not the current node has a className prop including the passed in class name.

Arguments

  1. className (String): A single class name.

Returns

Boolean: whether or not the current node has the class or not.

Example

const wrapper = shallow(<MyComponent />);
expect(wrapper.find('.my-button').hasClass('disabled')).to.equal(true);

Common Gotchas

  • .hasClass() expects a class name, NOT a CSS selector. .hasClass('.foo') should be .hasClass('foo')