Skip to content

Commit 8eb8c9f

Browse files
author
Kent C. Dodds
authored
Merge branch 'master' into 372-label-fix
2 parents dc48a12 + 4fed5ae commit 8eb8c9f

23 files changed

+357
-80
lines changed

.all-contributorsrc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@
633633
"contributions": [
634634
"code",
635635
"test",
636-
"doc"
636+
"doc",
637+
"infra"
637638
]
638639
},
639640
{
@@ -721,7 +722,8 @@
721722
"profile": "http://olzhas.de",
722723
"contributions": [
723724
"code",
724-
"test"
725+
"test",
726+
"doc"
725727
]
726728
},
727729
{
@@ -733,6 +735,24 @@
733735
"code",
734736
"test"
735737
]
738+
},
739+
{
740+
"login": "mmantel",
741+
"name": "Michael Mantel",
742+
"avatar_url": "https://avatars2.githubusercontent.com/u/1326403?v=4",
743+
"profile": "https://github.com/mmantel",
744+
"contributions": [
745+
"test"
746+
]
747+
},
748+
{
749+
"login": "tomanagle",
750+
"name": "Tom Nagle",
751+
"avatar_url": "https://avatars1.githubusercontent.com/u/8683577?v=4",
752+
"profile": "https://tomdoes.tech/",
753+
"contributions": [
754+
"code"
755+
]
736756
}
737757
],
738758
"repoHost": "https://github.com"

.codesandbox/ci.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sandboxes": ["github/kentcdodds/react-testing-library-examples"]
3+
}

.github/ISSUE_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ understand what's going on and fix the issue.
88
99
I'll probably ask you to submit the fix (after giving some direction). If you've
1010
never done that before, that's great! Check this free short video tutorial to
11-
learn how: http://kcd.im/pull-request
11+
learn how: https://kcd.im/pull-request
1212
1313
1414
If this is an issue with the documentation, please file an issue in the docs repo:
15-
https://github.com/alexkrolick/testing-library-docs
15+
https://github.com/testing-library/testing-library-docs
1616
1717
-->
1818

@@ -22,7 +22,7 @@ https://github.com/alexkrolick/testing-library-docs
2222

2323
Relevant code or config
2424

25-
```javascript
25+
```js
2626
```
2727

2828
What you did:
@@ -32,7 +32,7 @@ What happened:
3232
<!-- Please provide the full error message/screenshots/anything -->
3333

3434
Reproduction repository:
35-
https://github.com/alexkrolick/dom-testing-library-template
35+
https://github.com/testing-library/dom-testing-library-template
3636

3737
<!--
3838
If possible, please create a repository that reproduces the issue with the

.github/ISSUE_TEMPLATE/Bug_Report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ about: Bugs, missing documentation, or unexpected behavior 🤔.
1414
1515
We'll probably ask you to submit the fix (after giving some direction). If
1616
you've never done that before, that's great! Check this free short video
17-
tutorial to learn how: http://kcd.im/pull-request
17+
tutorial to learn how: https://kcd.im/pull-request
1818
1919
If this is an issue with the documentation, please file an issue in the docs repo:
2020
https://github.com/testing-library/testing-library-docs

.github/ISSUE_TEMPLATE/Feature_Request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ to work on.
1717
1818
It'd be great if after the discussion you're the one who submits the PR that
1919
implements this feature. If you've never done that before, that's great! Check
20-
this free short video tutorial to learn how: http://kcd.im/pull-request
20+
this free short video tutorial to learn how: https://kcd.im/pull-request
2121
2222
2323
If this is an issue with the documentation, please file an issue in the docs repo:
24-
https://github.com/alexkrolick/testing-library-docs
24+
https://github.com/testing-library/testing-library-docs
2525
-->
2626

2727
### Describe the feature you'd like:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Also, please make sure you're familiar with and follow the instructions in the
88
contributing guidelines (found in the CONTRIBUTING.md file).
99
1010
If you're new to contributing to open source projects, you might find this free
11-
video course helpful: http://kcd.im/pull-request
11+
video course helpful: https://kcd.im/pull-request
1212
1313
Please fill out the information below to expedite the review and (hopefully)
1414
merge of your pull request!
@@ -35,8 +35,9 @@ merge of your pull request!
3535
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
3636

3737
- [ ] Documentation added to the
38-
[docs site](https://github.com/alexkrolick/testing-library-docs)
39-
- [ ] I've prepared a PR for types targetting https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__dom
38+
[docs site](https://github.com/testing-library/testing-library-docs)
39+
- [ ] I've prepared a PR for types targeting
40+
[DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__dom)
4041
- [ ] Tests
4142
- [ ] Ready to be merged
4243
<!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ members of the project's leadership.
6969
## Attribution
7070

7171
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
72-
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
72+
version 1.4, available at
73+
[https://contributor-covenant.org/version/1/4][version]
7374

74-
[homepage]: http://contributor-covenant.org
75-
[version]: http://contributor-covenant.org/version/1/4/
75+
[homepage]: https://contributor-covenant.org
76+
[version]: https://contributor-covenant.org/version/1/4/

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ practices.</p>
2727
[![downloads][downloads-badge]][npmtrends]
2828
[![MIT License][license-badge]][license]
2929

30-
[![All Contributors](https://img.shields.io/badge/all_contributors-74-orange.svg?style=flat-square)](#contributors)
30+
[![All Contributors](https://img.shields.io/badge/all_contributors-76-orange.svg?style=flat-square)](#contributors)
3131
[![PRs Welcome][prs-badge]][prs]
3232
[![Code of Conduct][coc-badge]][coc]
3333

@@ -212,7 +212,7 @@ Thanks goes to these people ([emoji key][emojis]):
212212
<td align="center"><a href="https://github.com/michaellasky"><img src="https://avatars2.githubusercontent.com/u/6646599?v=4" width="100px;" alt="Michael Lasky"/><br /><sub><b>Michael Lasky</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=michaellasky" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=michaellasky" title="Tests">⚠️</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=michaellasky" title="Documentation">📖</a></td>
213213
</tr>
214214
<tr>
215-
<td align="center"><a href="https://twitter.com/sebsilbermann"><img src="https://avatars3.githubusercontent.com/u/12292047?v=4" width="100px;" alt="Sebastian Silbermann"/><br /><sub><b>Sebastian Silbermann</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Tests">⚠️</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Documentation">📖</a></td>
215+
<td align="center"><a href="https://twitter.com/sebsilbermann"><img src="https://avatars3.githubusercontent.com/u/12292047?v=4" width="100px;" alt="Sebastian Silbermann"/><br /><sub><b>Sebastian Silbermann</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Tests">⚠️</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=eps1lon" title="Documentation">📖</a> <a href="#infra-eps1lon" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
216216
<td align="center"><a href="https://dylanvann.com/"><img src="https://avatars0.githubusercontent.com/u/1537615?v=4" width="100px;" alt="Dylan Vann"/><br /><sub><b>Dylan Vann</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=DylanVann" title="Code">💻</a></td>
217217
<td align="center"><a href="https://afontcu.dev"><img src="https://avatars0.githubusercontent.com/u/9197791?v=4" width="100px;" alt="Adrià Fontcuberta"/><br /><sub><b>Adrià Fontcuberta</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=afontcu" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=afontcu" title="Tests">⚠️</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=afontcu" title="Documentation">📖</a></td>
218218
<td align="center"><a href="http://thomlom.dev"><img src="https://avatars3.githubusercontent.com/u/16003285?v=4" width="100px;" alt="Thomas Lombart"/><br /><sub><b>Thomas Lombart</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=thomlom" title="Code">💻</a></td>
@@ -223,8 +223,10 @@ Thanks goes to these people ([emoji key][emojis]):
223223
<tr>
224224
<td align="center"><a href="https://github.com/brapifra"><img src="https://avatars3.githubusercontent.com/u/17855450?v=4" width="100px;" alt="Brais Piñeiro"/><br /><sub><b>Brais Piñeiro</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=brapifra" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=brapifra" title="Tests">⚠️</a></td>
225225
<td align="center"><a href="https://www.dominykas.com/"><img src="https://avatars1.githubusercontent.com/u/505619?v=4" width="100px;" alt="Dominykas Blyžė"/><br /><sub><b>Dominykas Blyžė</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=dominykas" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=dominykas" title="Tests">⚠️</a></td>
226-
<td align="center"><a href="http://olzhas.de"><img src="https://avatars3.githubusercontent.com/u/15848876?v=4" width="100px;" alt="Olzhas Askar"/><br /><sub><b>Olzhas Askar</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=pheeria" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=pheeria" title="Tests">⚠️</a></td>
226+
<td align="center"><a href="http://olzhas.de"><img src="https://avatars3.githubusercontent.com/u/15848876?v=4" width="100px;" alt="Olzhas Askar"/><br /><sub><b>Olzhas Askar</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=pheeria" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=pheeria" title="Tests">⚠️</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=pheeria" title="Documentation">📖</a></td>
227227
<td align="center"><a href="https://twitter.com/mbelsky_"><img src="https://avatars1.githubusercontent.com/u/3923527?v=4" width="100px;" alt="Max Belsky"/><br /><sub><b>Max Belsky</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=mbelsky" title="Code">💻</a> <a href="https://github.com/testing-library/dom-testing-library/commits?author=mbelsky" title="Tests">⚠️</a></td>
228+
<td align="center"><a href="https://github.com/mmantel"><img src="https://avatars2.githubusercontent.com/u/1326403?v=4" width="100px;" alt="Michael Mantel"/><br /><sub><b>Michael Mantel</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=mmantel" title="Tests">⚠️</a></td>
229+
<td align="center"><a href="https://tomdoes.tech/"><img src="https://avatars1.githubusercontent.com/u/8683577?v=4" width="100px;" alt="Tom Nagle"/><br /><sub><b>Tom Nagle</b></sub></a><br /><a href="https://github.com/testing-library/dom-testing-library/commits?author=tomanagle" title="Code">💻</a></td>
228230
</tr>
229231
</table>
230232

other/testingjavascript.jpg

-35.5 KB
Loading

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"end-to-end",
1818
"e2e"
1919
],
20-
"author": "Kent C. Dodds <kent@doddsfamily.us> (http://kentcdodds.com/)",
20+
"author": "Kent C. Dodds <kent@doddsfamily.us> (https://kentcdodds.com/)",
2121
"license": "MIT",
2222
"engines": {
2323
"node": ">=8"
@@ -40,20 +40,20 @@
4040
"dist"
4141
],
4242
"dependencies": {
43-
"@babel/runtime": "^7.5.5",
43+
"@babel/runtime": "^7.6.2",
4444
"@sheerun/mutationobserver-shim": "^0.3.2",
4545
"@types/testing-library__dom": "^6.0.0",
4646
"aria-query": "3.0.0",
47-
"pretty-format": "^24.8.0",
48-
"wait-for-expect": "^1.3.0"
47+
"pretty-format": "^24.9.0",
48+
"wait-for-expect": "^3.0.0"
4949
},
5050
"devDependencies": {
51-
"@testing-library/jest-dom": "^4.0.0",
51+
"@testing-library/jest-dom": "^4.1.0",
5252
"jest-in-case": "^1.0.2",
5353
"jest-serializer-ansi": "^1.0.3",
54-
"jest-watch-select-projects": "^0.1.1",
54+
"jest-watch-select-projects": "^1.0.0",
5555
"jsdom": "^15.1.1",
56-
"kcd-scripts": "^1.5.2"
56+
"kcd-scripts": "^1.7.0"
5757
},
5858
"eslintConfig": {
5959
"extends": "./node_modules/kcd-scripts/eslint.js",

src/__node_tests__/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,23 @@ test('works without a browser context on a dom node (JSDOM Fragment)', () => {
7676
/>
7777
`)
7878
})
79+
80+
test('byRole works without a global DOM', () => {
81+
const {
82+
window: {
83+
document: {body: container},
84+
},
85+
} = new JSDOM(`
86+
<html>
87+
<body>
88+
<button>Say "Hello, Dave!"</button>
89+
</body>
90+
</html>
91+
`)
92+
93+
expect(dtl.getByRole(container, 'button')).toMatchInlineSnapshot(`
94+
<button>
95+
Say "Hello, Dave!"
96+
</button>
97+
`)
98+
})

src/__node_tests__/screen.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {screen} from '..'
2+
3+
test('the screen export throws a helpful error message when no global document is accessible', () => {
4+
expect(() =>
5+
screen.getByText(/hello world/i),
6+
).toThrowErrorMatchingInlineSnapshot(
7+
`"For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error"`,
8+
)
9+
})

src/__tests__/element-queries.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ test('query/get select by text with multiple options selected', () => {
414414
})
415415

416416
describe('query by test id', () => {
417+
afterEach(() => {
418+
// Restore the default test id attribute
419+
// even if these tests failed
420+
configure({testIdAttribute: 'data-testid'})
421+
})
422+
417423
test('can get elements by test id', () => {
418424
const {queryByTestId} = render(`<div data-testid="firstName"></div>`)
419425
expect(queryByTestId('firstName')).toBeTruthy()
@@ -435,12 +441,6 @@ describe('query by test id', () => {
435441
configure({testIdAttribute: 'something-else'})
436442
expect(queryByTestId('theTestId')).toBeFalsy()
437443
})
438-
439-
afterEach(() => {
440-
// Restore the default test id attribute
441-
// even if these tests failed
442-
configure({testIdAttribute: 'data-testid'})
443-
})
444444
})
445445

446446
test('queryAllByRole returns semantic html elements', () => {

0 commit comments

Comments
 (0)