{"action":"created","comment":{"url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/comments/227554671","pull_request_review_id":167624835,"id":227554671,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzU1NDY3MQ==","diff_hunk":"@@ -557,6 +557,47 @@ const usernameInputElement = getByTestId('username-input')\n > about `data-testid`s from the blog post [\"Making your UI tests resilient to\n > change\"][data-testid-blog-post]\n \n+<details>\n+  <summary>What if my project already uses <code>data-test-id</code>? Do I have to migrate to <code>data-testid</code>?\n+</summary>\n+\n+`getByTestId` is looking for the `data-testid` attribute and that's not going to\n+change\n+[#76](https://github.com/kentcdodds/dom-testing-library/issues/76#issuecomment-406321122)\n+[#128](https://github.com/kentcdodds/dom-testing-library/issues/128)\n+[#204](https://github.com/kentcdodds/react-testing-library/issues/204).\n+\n+What you can do is to create a [custom render](#custom-render) that overwrites\n+`getByTestId`:\n+\n+```js\n+// test-utils.js\n+import {render} from 'react-testing-library'\n+\n+const customRender = (node, ...options) => {\n+  const utils = render(node, ...options)\n+\n+  return {\n+    ...utils,\n+    getByTestId: id => {\n+      const el = utils.container.querySelector(`[data-test-id=\"${id}\"]`)","path":"README.md","position":27,"original_position":27,"commit_id":"5fb29bd5cc5fa44aa7af39f7797e44a148b4013c","original_commit_id":"5fb29bd5cc5fa44aa7af39f7797e44a148b4013c","user":{"login":"alexkrolick","id":1571667,"node_id":"MDQ6VXNlcjE1NzE2Njc=","avatar_url":"https://avatars3.githubusercontent.com/u/1571667?v=4","gravatar_id":"","url":"https://api.github.com/users/alexkrolick","html_url":"https://github.com/alexkrolick","followers_url":"https://api.github.com/users/alexkrolick/followers","following_url":"https://api.github.com/users/alexkrolick/following{/other_user}","gists_url":"https://api.github.com/users/alexkrolick/gists{/gist_id}","starred_url":"https://api.github.com/users/alexkrolick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexkrolick/subscriptions","organizations_url":"https://api.github.com/users/alexkrolick/orgs","repos_url":"https://api.github.com/users/alexkrolick/repos","events_url":"https://api.github.com/users/alexkrolick/events{/privacy}","received_events_url":"https://api.github.com/users/alexkrolick/received_events","type":"User","site_admin":false},"body":"Query helpers are exported directly for this very use case\r\nhttps://github.com/kentcdodds/dom-testing-library/blob/master/src/index.js","created_at":"2018-10-23T20:37:43Z","updated_at":"2018-10-23T20:37:44Z","html_url":"https://github.com/kentcdodds/react-testing-library/pull/207#discussion_r227554671","pull_request_url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/comments/227554671"},"html":{"href":"https://github.com/kentcdodds/react-testing-library/pull/207#discussion_r227554671"},"pull_request":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207"}},"in_reply_to_id":227512188},"pull_request":{"url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207","id":225138781,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1MTM4Nzgx","html_url":"https://github.com/kentcdodds/react-testing-library/pull/207","diff_url":"https://github.com/kentcdodds/react-testing-library/pull/207.diff","patch_url":"https://github.com/kentcdodds/react-testing-library/pull/207.patch","issue_url":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/207","number":207,"state":"closed","locked":false,"title":"docs: ✏️ explain how to implement custo getByTestId","user":{"login":"Gpx","id":767959,"node_id":"MDQ6VXNlcjc2Nzk1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/767959?v=4","gravatar_id":"","url":"https://api.github.com/users/Gpx","html_url":"https://github.com/Gpx","followers_url":"https://api.github.com/users/Gpx/followers","following_url":"https://api.github.com/users/Gpx/following{/other_user}","gists_url":"https://api.github.com/users/Gpx/gists{/gist_id}","starred_url":"https://api.github.com/users/Gpx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gpx/subscriptions","organizations_url":"https://api.github.com/users/Gpx/orgs","repos_url":"https://api.github.com/users/Gpx/repos","events_url":"https://api.github.com/users/Gpx/events{/privacy}","received_events_url":"https://api.github.com/users/Gpx/received_events","type":"User","site_admin":false},"body":"<!--\r\nThanks for your interest in the project. Bugs filed and PRs submitted are appreciated!\r\n\r\nPlease make sure that you are familiar with and follow the Code of Conduct for\r\nthis project (found in the CODE_OF_CONDUCT.md file).\r\n\r\nAlso, please make sure you're familiar with and follow the instructions in the\r\ncontributing guidelines (found in the CONTRIBUTING.md file).\r\n\r\nIf you're new to contributing to open source projects, you might find this free\r\nvideo course helpful: http://kcd.im/pull-request\r\n\r\nPlease fill out the information below to expedite the review and (hopefully)\r\nmerge of your pull request!\r\n-->\r\n\r\n<!-- What changes are being made? (What feature/bug is being fixed here?) -->\r\n\r\n**What**:\r\n\r\nAdding an explanation on how to implement a `getByTestId` that looks for `data-test-id`.\r\n\r\n<!-- Why are these changes necessary? -->\r\n\r\n**Why**:\r\n\r\n<!-- How were these changes implemented? -->\r\n\r\nBecause people tend to ask this question.\r\n\r\n**How**:\r\n\r\n<!-- Have you done all of these things?  -->\r\n\r\n**Checklist**:\r\n\r\n<!-- add \"N/A\" to the end of each line that's irrelevant to your changes -->\r\n\r\n<!-- to check an item, place an \"x\" in the box like so: \"- [x] Documentation\" -->\r\n\r\n- [x] Documentation\r\n- [ ] Tests N/A\r\n- [x] Ready to be merged\r\n      <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->\r\n- [ ] Added myself to contributors table\r\n      <!-- this is optional, see the contributing guidelines for instructions -->\r\n\r\n<!-- feel free to add additional comments -->\r\n","created_at":"2018-10-23T18:19:56Z","updated_at":"2018-10-23T20:37:43Z","closed_at":"2018-10-23T18:28:03Z","merged_at":"2018-10-23T18:28:03Z","merge_commit_sha":"3cc387ba218572f8ebfeb844d029c6085a3cb491","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207/commits","review_comments_url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207/comments","review_comment_url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/207/comments","statuses_url":"https://api.github.com/repos/kentcdodds/react-testing-library/statuses/5fb29bd5cc5fa44aa7af39f7797e44a148b4013c","head":{"label":"Gpx:master","ref":"master","sha":"5fb29bd5cc5fa44aa7af39f7797e44a148b4013c","user":{"login":"Gpx","id":767959,"node_id":"MDQ6VXNlcjc2Nzk1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/767959?v=4","gravatar_id":"","url":"https://api.github.com/users/Gpx","html_url":"https://github.com/Gpx","followers_url":"https://api.github.com/users/Gpx/followers","following_url":"https://api.github.com/users/Gpx/following{/other_user}","gists_url":"https://api.github.com/users/Gpx/gists{/gist_id}","starred_url":"https://api.github.com/users/Gpx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gpx/subscriptions","organizations_url":"https://api.github.com/users/Gpx/orgs","repos_url":"https://api.github.com/users/Gpx/repos","events_url":"https://api.github.com/users/Gpx/events{/privacy}","received_events_url":"https://api.github.com/users/Gpx/received_events","type":"User","site_admin":false},"repo":{"id":129456310,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk0NTYzMTA=","name":"react-testing-library","full_name":"Gpx/react-testing-library","private":false,"owner":{"login":"Gpx","id":767959,"node_id":"MDQ6VXNlcjc2Nzk1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/767959?v=4","gravatar_id":"","url":"https://api.github.com/users/Gpx","html_url":"https://github.com/Gpx","followers_url":"https://api.github.com/users/Gpx/followers","following_url":"https://api.github.com/users/Gpx/following{/other_user}","gists_url":"https://api.github.com/users/Gpx/gists{/gist_id}","starred_url":"https://api.github.com/users/Gpx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gpx/subscriptions","organizations_url":"https://api.github.com/users/Gpx/orgs","repos_url":"https://api.github.com/users/Gpx/repos","events_url":"https://api.github.com/users/Gpx/events{/privacy}","received_events_url":"https://api.github.com/users/Gpx/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Gpx/react-testing-library","description":"🐐 Simple and complete React DOM testing utilities that encourage good testing practices.","fork":true,"url":"https://api.github.com/repos/Gpx/react-testing-library","forks_url":"https://api.github.com/repos/Gpx/react-testing-library/forks","keys_url":"https://api.github.com/repos/Gpx/react-testing-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Gpx/react-testing-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Gpx/react-testing-library/teams","hooks_url":"https://api.github.com/repos/Gpx/react-testing-library/hooks","issue_events_url":"https://api.github.com/repos/Gpx/react-testing-library/issues/events{/number}","events_url":"https://api.github.com/repos/Gpx/react-testing-library/events","assignees_url":"https://api.github.com/repos/Gpx/react-testing-library/assignees{/user}","branches_url":"https://api.github.com/repos/Gpx/react-testing-library/branches{/branch}","tags_url":"https://api.github.com/repos/Gpx/react-testing-library/tags","blobs_url":"https://api.github.com/repos/Gpx/react-testing-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Gpx/react-testing-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Gpx/react-testing-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/Gpx/react-testing-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Gpx/react-testing-library/statuses/{sha}","languages_url":"https://api.github.com/repos/Gpx/react-testing-library/languages","stargazers_url":"https://api.github.com/repos/Gpx/react-testing-library/stargazers","contributors_url":"https://api.github.com/repos/Gpx/react-testing-library/contributors","subscribers_url":"https://api.github.com/repos/Gpx/react-testing-library/subscribers","subscription_url":"https://api.github.com/repos/Gpx/react-testing-library/subscription","commits_url":"https://api.github.com/repos/Gpx/react-testing-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/Gpx/react-testing-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/Gpx/react-testing-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/Gpx/react-testing-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/Gpx/react-testing-library/contents/{+path}","compare_url":"https://api.github.com/repos/Gpx/react-testing-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Gpx/react-testing-library/merges","archive_url":"https://api.github.com/repos/Gpx/react-testing-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Gpx/react-testing-library/downloads","issues_url":"https://api.github.com/repos/Gpx/react-testing-library/issues{/number}","pulls_url":"https://api.github.com/repos/Gpx/react-testing-library/pulls{/number}","milestones_url":"https://api.github.com/repos/Gpx/react-testing-library/milestones{/number}","notifications_url":"https://api.github.com/repos/Gpx/react-testing-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Gpx/react-testing-library/labels{/name}","releases_url":"https://api.github.com/repos/Gpx/react-testing-library/releases{/id}","deployments_url":"https://api.github.com/repos/Gpx/react-testing-library/deployments","created_at":"2018-04-13T21:41:42Z","updated_at":"2018-10-23T18:26:15Z","pushed_at":"2018-10-23T18:26:13Z","git_url":"git://github.com/Gpx/react-testing-library.git","ssh_url":"git@github.com:Gpx/react-testing-library.git","clone_url":"https://github.com/Gpx/react-testing-library.git","svn_url":"https://github.com/Gpx/react-testing-library","homepage":"http://npm.im/react-testing-library","size":473,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kentcdodds:master","ref":"master","sha":"fe3b65ca158f0ac088b67b195b678a9428a7a2b5","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},"repo":{"id":125863507,"node_id":"MDEwOlJlcG9zaXRvcnkxMjU4NjM1MDc=","name":"react-testing-library","full_name":"kentcdodds/react-testing-library","private":false,"owner":{"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},"html_url":"https://github.com/kentcdodds/react-testing-library","description":"🐐 Simple and complete React DOM testing utilities that encourage good testing practices.","fork":false,"url":"https://api.github.com/repos/kentcdodds/react-testing-library","forks_url":"https://api.github.com/repos/kentcdodds/react-testing-library/forks","keys_url":"https://api.github.com/repos/kentcdodds/react-testing-library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kentcdodds/react-testing-library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kentcdodds/react-testing-library/teams","hooks_url":"https://api.github.com/repos/kentcdodds/react-testing-library/hooks","issue_events_url":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/events{/number}","events_url":"https://api.github.com/repos/kentcdodds/react-testing-library/events","assignees_url":"https://api.github.com/repos/kentcdodds/react-testing-library/assignees{/user}","branches_url":"https://api.github.com/repos/kentcdodds/react-testing-library/branches{/branch}","tags_url":"https://api.github.com/repos/kentcdodds/react-testing-library/tags","blobs_url":"https://api.github.com/repos/kentcdodds/react-testing-library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kentcdodds/react-testing-library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kentcdodds/react-testing-library/git/refs{/sha}","trees_url":"https://api.github.com/repos/kentcdodds/react-testing-library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kentcdodds/react-testing-library/statuses/{sha}","languages_url":"https://api.github.com/repos/kentcdodds/react-testing-library/languages","stargazers_url":"https://api.github.com/repos/kentcdodds/react-testing-library/stargazers","contributors_url":"https://api.github.com/repos/kentcdodds/react-testing-library/contributors","subscribers_url":"https://api.github.com/repos/kentcdodds/react-testing-library/subscribers","subscription_url":"https://api.github.com/repos/kentcdodds/react-testing-library/subscription","commits_url":"https://api.github.com/repos/kentcdodds/react-testing-library/commits{/sha}","git_commits_url":"https://api.github.com/repos/kentcdodds/react-testing-library/git/commits{/sha}","comments_url":"https://api.github.com/repos/kentcdodds/react-testing-library/comments{/number}","issue_comment_url":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/comments{/number}","contents_url":"https://api.github.com/repos/kentcdodds/react-testing-library/contents/{+path}","compare_url":"https://api.github.com/repos/kentcdodds/react-testing-library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kentcdodds/react-testing-library/merges","archive_url":"https://api.github.com/repos/kentcdodds/react-testing-library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kentcdodds/react-testing-library/downloads","issues_url":"https://api.github.com/repos/kentcdodds/react-testing-library/issues{/number}","pulls_url":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls{/number}","milestones_url":"https://api.github.com/repos/kentcdodds/react-testing-library/milestones{/number}","notifications_url":"https://api.github.com/repos/kentcdodds/react-testing-library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kentcdodds/react-testing-library/labels{/name}","releases_url":"https://api.github.com/repos/kentcdodds/react-testing-library/releases{/id}","deployments_url":"https://api.github.com/repos/kentcdodds/react-testing-library/deployments","created_at":"2018-03-19T13:39:49Z","updated_at":"2018-10-23T18:28:05Z","pushed_at":"2018-10-23T18:28:03Z","git_url":"git://github.com/kentcdodds/react-testing-library.git","ssh_url":"git@github.com:kentcdodds/react-testing-library.git","clone_url":"https://github.com/kentcdodds/react-testing-library.git","svn_url":"https://github.com/kentcdodds/react-testing-library","homepage":"http://npm.im/react-testing-library","size":478,"stargazers_count":3511,"watchers_count":3511,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":204,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":204,"open_issues":3,"watchers":3511,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207"},"html":{"href":"https://github.com/kentcdodds/react-testing-library/pull/207"},"issue":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/207"},"comments":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/issues/207/comments"},"review_comments":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207/comments"},"review_comment":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/pulls/207/commits"},"statuses":{"href":"https://api.github.com/repos/kentcdodds/react-testing-library/statuses/5fb29bd5cc5fa44aa7af39f7797e44a148b4013c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"alexkrolick"}}