diff --git a/.all-contributorsrc b/.all-contributorsrc index 5d154811..ac1c1f6b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,6 +1,7 @@ { "projectName": "react-testing-library", "projectOwner": "kentcdodds", + "repoType": "github", "files": [ "README.md" ], @@ -18,6 +19,15 @@ "infra", "test" ] + }, + { + "login": "audiolion", + "name": "Ryan Castner", + "avatar_url": "https://avatars1.githubusercontent.com/u/2430381?v=4", + "profile": "http://audiolion.github.io", + "contributions": [ + "doc" + ] } ] } diff --git a/README.md b/README.md index c0196d00..26d9980e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![downloads][downloads-badge]][npmtrends] [![MIT License][license-badge]][license] -[](#contributors) +[](#contributors) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] @@ -253,6 +253,28 @@ const allLisInDiv = container.querySelectorAll('div li') const rootElement = container.firstChild ``` +**What if Iām iterating over a list of items that I want to put the data-testid="item" attribute on. How do I distinguish them from each other?** + +You can make your selector just choose the one you want by including :nth-child in the selector. + +```javascript +const thirdLiInUl = container.querySelector('ul > li:nth-child(3)') +``` + +Or you could include the index or an ID in your attribute: + +```javascript +