{"action":"created","issue":{"url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/80","repository_url":"https://api.github.com/repos/kentcdodds/dom-testing-library","labels_url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/80/comments","events_url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/80/events","html_url":"https://github.com/kentcdodds/dom-testing-library/issues/80","id":343936744,"node_id":"MDU6SXNzdWUzNDM5MzY3NDQ=","number":80,"title":"Baking-in `closest()`","user":{"login":"will-stone","id":654103,"node_id":"MDQ6VXNlcjY1NDEwMw==","avatar_url":"https://avatars1.githubusercontent.com/u/654103?v=4","gravatar_id":"","url":"https://api.github.com/users/will-stone","html_url":"https://github.com/will-stone","followers_url":"https://api.github.com/users/will-stone/followers","following_url":"https://api.github.com/users/will-stone/following{/other_user}","gists_url":"https://api.github.com/users/will-stone/gists{/gist_id}","starred_url":"https://api.github.com/users/will-stone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/will-stone/subscriptions","organizations_url":"https://api.github.com/users/will-stone/orgs","repos_url":"https://api.github.com/users/will-stone/repos","events_url":"https://api.github.com/users/will-stone/events{/privacy}","received_events_url":"https://api.github.com/users/will-stone/received_events","type":"User","site_admin":false},"labels":[{"id":892605680,"node_id":"MDU6TGFiZWw4OTI2MDU2ODA=","url":"https://api.github.com/repos/kentcdodds/dom-testing-library/labels/help%20wanted","name":"help wanted","color":"008672","default":true},{"id":894574511,"node_id":"MDU6TGFiZWw4OTQ1NzQ1MTE=","url":"https://api.github.com/repos/kentcdodds/dom-testing-library/labels/needs%20discussion","name":"needs discussion","color":"cc0ac8","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-07-24T08:32:31Z","updated_at":"2018-09-17T21:42:07Z","closed_at":"2018-09-17T21:42:07Z","author_association":"NONE","body":"<!--\r\n\r\nVote on feature requests by adding a 👍. This helps maintainers prioritize what\r\nto work on.\r\n\r\n* Please fill out this template with all the relevant information so we can\r\n  understand what's going on and fix the issue. We appreciate bugs filed and PRs\r\n  submitted!\r\n\r\n* Please make sure that you are familiar with and follow the Code of Conduct for\r\n  this project (found in the CODE_OF_CONDUCT.md file).\r\n\r\nIt'd be great if after the discussion you're the one who submits the PR that\r\nimplements this feature. If you've never done that before, that's great! Check\r\nthis free short video tutorial to learn how: http://kcd.im/pull-request\r\n\r\n-->\r\n\r\nHi Kent! Thanks so much for this and RTL, it's made testing really quite easy 😀\r\n\r\n### Describe the feature you'd like:\r\n\r\n<!--\r\nA clear and concise description of what you want to happen. Add any considered\r\ndrawbacks.\r\n-->\r\n\r\nIf I have this...\r\n\r\n```html\r\n<button>\r\n  <span>testing</span>\r\n</button>\r\n```\r\n\r\n...I have found myself having to use `.closest()` when trying to find the button, where the `span` isn't guaranteed to exist, and this works really well.\r\n\r\n```js\r\ngetByText('testing').closest('button')\r\n```\r\n\r\nHowever, I thought this would be what the `selector` option was supposed to provide but that didn't seem to work for me. I get:\r\n\r\n```\r\nUnable to find an element with the text: testing. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.\r\n```\r\n\r\n\r\nTherefore I'm not really sure if this is a bug report or feature request. If...\r\n\r\n```js\r\ngetByText('testing', { selector: 'button'})\r\n```\r\n\r\n... should find the button, then this is a bug report. If it's not, then maybe...\r\n\r\n```js\r\ngetByText('testing', { closest: 'button'})\r\n```\r\n\r\n...could be useful and some docs to explain this situation? Or maybe this is all overkill, what are your thoughts?\r\n\r\nHappy to help, just want to know if I'm barking up the correct tree to begin with."},"comment":{"url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/comments/422181525","html_url":"https://github.com/kentcdodds/dom-testing-library/issues/80#issuecomment-422181525","issue_url":"https://api.github.com/repos/kentcdodds/dom-testing-library/issues/80","id":422181525,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjE4MTUyNQ==","user":{"login":"kentcdodds","id":1500684,"node_id":"MDQ6VXNlcjE1MDA2ODQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1500684?v=4","gravatar_id":"","url":"https://api.github.com/users/kentcdodds","html_url":"https://github.com/kentcdodds","followers_url":"https://api.github.com/users/kentcdodds/followers","following_url":"https://api.github.com/users/kentcdodds/following{/other_user}","gists_url":"https://api.github.com/users/kentcdodds/gists{/gist_id}","starred_url":"https://api.github.com/users/kentcdodds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kentcdodds/subscriptions","organizations_url":"https://api.github.com/users/kentcdodds/orgs","repos_url":"https://api.github.com/users/kentcdodds/repos","events_url":"https://api.github.com/users/kentcdodds/events{/privacy}","received_events_url":"https://api.github.com/users/kentcdodds/received_events","type":"User","site_admin":false},"created_at":"2018-09-17T21:42:07Z","updated_at":"2018-09-17T21:42:07Z","author_association":"OWNER","body":"This is no longer actionable, so I'm going to close this one."}}
{"actor":{"display_login":"kentcdodds"}}