{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/383","repository_url":"https://api.github.com/repos/airbnb/enzyme","labels_url":"https://api.github.com/repos/airbnb/enzyme/issues/383/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/enzyme/issues/383/comments","events_url":"https://api.github.com/repos/airbnb/enzyme/issues/383/events","html_url":"https://github.com/airbnb/enzyme/issues/383","id":154380202,"number":383,"title":"Proposal: wrapper.findClass() shorthand","user":{"login":"joshhunt","id":46142,"avatar_url":"https://avatars.githubusercontent.com/u/46142?v=3","gravatar_id":"","url":"https://api.github.com/users/joshhunt","html_url":"https://github.com/joshhunt","followers_url":"https://api.github.com/users/joshhunt/followers","following_url":"https://api.github.com/users/joshhunt/following{/other_user}","gists_url":"https://api.github.com/users/joshhunt/gists{/gist_id}","starred_url":"https://api.github.com/users/joshhunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshhunt/subscriptions","organizations_url":"https://api.github.com/users/joshhunt/orgs","repos_url":"https://api.github.com/users/joshhunt/repos","events_url":"https://api.github.com/users/joshhunt/events{/privacy}","received_events_url":"https://api.github.com/users/joshhunt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-12T01:52:20Z","updated_at":"2016-05-12T02:03:10Z","closed_at":null,"body":"We're using CSS Modules, and so we have an object of our classNames. When using these to seach for components with enzume, we have to add a dot at the beginning of these, and repeat this a lot.\r\n\r\n```\r\noutput.find(`.${styles.fakeCheckbox}`)\r\noutput.find('.' + styles.fakeCheckbox)\r\nslide.find(`.${styles.subHeading}`)\r\nslide.find(`.${styles.subHeading}`)\r\nslide.find(`.${styles.description}`)\r\nslide.find(`.${styles.description}`)\r\nwrapper.find(`.${styles.itemLink}`)\r\nwrapper.find(`.${styles.item}`)\r\ndropdownComponent.find(`.${styles.label}`)\r\ndropdownComponent.find(`.${styles.label}`)\r\ndropdownComponent.find(`.${styles.menu}`)\r\ndropdownComponent.find(`.${styles.label}`)\r\ndropdownComponent.find(`.${styles.label}`)\r\noutput.find(`.${stylesStub.main}`)\r\noutput.find(`.${stylesStub.sidebar}`)\r\noutput.find(`.${stylesStub.header}`)\r\noutput.find(`.${stylesStub.header}`)\r\nnavComponent.find(`.${stylesStub.prevLinkWrapper}`)\r\nnavComponent.find(`.${stylesStub.prevLinkWrapper}`)\r\nnavComponent.find(`.${stylesStub.nextLinkWrapper}`)\r\nnavComponent.find(`.${stylesStub.nextLinkWrapper}`)\r\noutput.find(`.${messageStyles.title}`)\r\noutput.find(`.${messageStyles.subtitle}`)\r\ncomponent.find(`.${styles.checkbox}`)\r\ncomponent.find(`.${styles.sidebar}`)\r\ncomponent.find(`.${styles.scrollContent}`)\r\nextrasContent.find(`.${stylesStub.innerWrapper}`)\r\nwrapper.find(`.${mockStyles.subtitle}`)\r\n```\r\n\r\nWhat we would like to do is add a method to both ShallowWrapper and ReactWrapper called `.findClass()` where we can pass in just the class name, without the dot at the beginning. So like `wrapper.findClass(styles.header)`.\r\n\r\nThoughts? I'm willing to work on a PR, but wanted to get feedback on the idea first.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/comments/218640524","html_url":"https://github.com/airbnb/enzyme/issues/383#issuecomment-218640524","issue_url":"https://api.github.com/repos/airbnb/enzyme/issues/383","id":218640524,"user":{"login":"Aweary","id":6886061,"avatar_url":"https://avatars.githubusercontent.com/u/6886061?v=3","gravatar_id":"","url":"https://api.github.com/users/Aweary","html_url":"https://github.com/Aweary","followers_url":"https://api.github.com/users/Aweary/followers","following_url":"https://api.github.com/users/Aweary/following{/other_user}","gists_url":"https://api.github.com/users/Aweary/gists{/gist_id}","starred_url":"https://api.github.com/users/Aweary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aweary/subscriptions","organizations_url":"https://api.github.com/users/Aweary/orgs","repos_url":"https://api.github.com/users/Aweary/repos","events_url":"https://api.github.com/users/Aweary/events{/privacy}","received_events_url":"https://api.github.com/users/Aweary/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T02:03:10Z","updated_at":"2016-05-12T02:03:10Z","body":"@joshhunt also note that you can always extend `ReactWrapper` or `ShallowWrapper` for `mount` and `shallow` respectively\r\n\r\n```js\r\nimport { ShallowWrapper } from 'enzyme';\r\nShallowWrapper.prototype.findClass = function (className) { \r\n  return ShallowWrapper.find(`.${className}`)\r\n};\r\n```"}}