Skip to content

Commit c07a1ab

Browse files
author
Kent C. Dodds
committed
chore: cleanup
1 parent a41f0fc commit c07a1ab

File tree

11 files changed

+74
-63
lines changed

11 files changed

+74
-63
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ never done that before, that's great! Check this free short video tutorial to
1111
learn how: http://kcd.im/pull-request
1212
-->
1313

14-
* `dom-testing-library` version:
15-
* `node` version:
16-
* `npm` (or `yarn`) version:
14+
- `dom-testing-library` version:
15+
- `node` version:
16+
- `npm` (or `yarn`) version:
1717

1818
Relevant code or config
1919

.github/ISSUE_TEMPLATE/Bug_Report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ tutorial to learn how: http://kcd.im/pull-request
1818
1919
-->
2020

21-
* `dom-testing-library` version:
22-
* `react` version:
23-
* `node` version:
24-
* `npm` (or `yarn`) version:
21+
- `dom-testing-library` version:
22+
- `react` version:
23+
- `node` version:
24+
- `npm` (or `yarn`) version:
2525

2626
### Relevant code or config:
2727

.github/ISSUE_TEMPLATE/Question.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ and feature requests so we recommend not using this medium to ask them here 😁
1212

1313
## ❓ Support Forums
1414

15-
* React Spectrum
15+
- React Spectrum
1616
https://spectrum.chat/react-testing-library
17-
* Reactiflux on Discord
17+
- Reactiflux on Discord
1818
https://www.reactiflux.com
19-
* Stack Overflow
19+
- Stack Overflow
2020
https://stackoverflow.com/questions/tagged/react-testing-library
2121

2222
**ISSUES WHICH ARE QUESTIONS WILL BE CLOSED**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ merge of your pull request!
3434

3535
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
3636

37-
* [ ] Documentation
38-
* [ ] Tests
39-
* [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
40-
* [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions -->
37+
- [ ] Documentation
38+
- [ ] Tests
39+
- [ ] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
40+
- [ ] Added myself to contributors table <!-- this is optional, see the contributing guidelines for instructions -->
4141

4242
<!-- feel free to add additional comments -->

.size-snapshot.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dist/dom-testing-library.umd.js": {
3+
"bundled": 108659,
4+
"minified": 48227,
5+
"gzipped": 14779
6+
}
7+
}

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ import {
129129
// called "queries" which you could import here as well
130130
wait,
131131
} from 'dom-testing-library'
132-
// adds special assertions like toHaveTextContent and toBeInTheDOM
132+
// adds special assertions like toHaveTextContent
133133
import 'jest-dom/extend-expect'
134134

135135
function getExampleDOM() {
@@ -171,7 +171,7 @@ test('examples of some things', async () => {
171171
getByText(container, 'Print Username').click()
172172

173173
await wait(() =>
174-
expect(queryByTestId(container, 'printed-username')).toBeInTheDOM(),
174+
expect(queryByTestId(container, 'printed-username')).toBeTruthy(),
175175
)
176176

177177
// getByTestId and queryByTestId are an escape hatch to get elements
@@ -543,13 +543,13 @@ exmaple, you can use the ones provided by
543543
import 'jest-dom/extend-expect'
544544
545545
// <span data-testid="greetings">Hello World</span>
546-
expect(queryByTestId(container, 'greetings')).toBeInTheDOM()
547546
expect(queryByTestId(container, 'greetings')).not.toHaveTextContent('Bye bye')
548547
// ...
549548
550-
> Note: when using `toBeInTheDOM`, make sure you use a query function
551-
> (like `queryByTestId`) rather than a get function (like `getByTestId`).
552-
> Otherwise the `get*` function could throw an error before your assertion.
549+
> Note: when using some of these matchers, you may need to make sure
550+
> you use a query function (like `queryByTestId`) rather than a get
551+
> function (like `getByTestId`). Otherwise the `get*` function could
552+
> throw an error before your assertion.
553553
```
554554

555555
Check out [jest-dom's documentation](https://github.com/gnapse/jest-dom#readme)
@@ -629,7 +629,7 @@ the `query` API instead:
629629
const submitButton = queryByText(container, 'submit')
630630
expect(submitButton).toBeNull() // it doesn't exist
631631
// or if you're using the custom matchers:
632-
expect(submitButton).not.toBeInTheDOM()
632+
expect(submitButton).not.toBeTruthy()
633633
```
634634

635635
## `queryAll` and `getAll` APIs
@@ -639,7 +639,7 @@ Each of the `query` APIs have a corresponsing `queryAll` version that always ret
639639
```javascript
640640
const submitButtons = queryAllByText(container, 'submit')
641641
expect(submitButtons).toHaveLength(3) // expect 3 elements
642-
expect(submitButtons[0]).toBeInTheDOM()
642+
expect(submitButtons[0]).toBeTruthy()
643643
```
644644

645645
## `within` and `getQueriesForElement` APIs

other/CODE_OF_CONDUCT.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
2626
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
3030
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
31+
- Other conduct which could reasonably be considered inappropriate in a
3232
professional setting
3333

3434
## Our Responsibilities

src/__tests__/element-queries.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ test('can get elements by matching their text content', () => {
5252
</span>
5353
</div>
5454
`)
55-
expect(queryByText('Currently showing')).toBeInTheDOM()
56-
expect(queryByText('Step 1 of 4')).toBeInTheDOM()
55+
expect(queryByText('Currently showing')).toBeTruthy()
56+
expect(queryByText('Step 1 of 4')).toBeTruthy()
5757
})
5858

5959
test('matches case with RegExp matcher', () => {
6060
const {queryByText} = render(`
6161
<span>STEP 1 of 4</span>
6262
`)
63-
expect(queryByText(/STEP 1 of 4/)).toBeInTheDOM()
64-
expect(queryByText(/Step 1 of 4/)).not.toBeInTheDOM()
63+
expect(queryByText(/STEP 1 of 4/)).toBeTruthy()
64+
expect(queryByText(/Step 1 of 4/)).not.toBeTruthy()
6565
})
6666

6767
test('get can get form controls by label text', () => {
@@ -120,7 +120,7 @@ test('totally empty label', () => {
120120
test('getByLabelText with aria-label', () => {
121121
// not recommended normally, but supported for completeness
122122
const {queryByLabelText} = render(`<input aria-label="batman" />`)
123-
expect(queryByLabelText(/bat/)).toBeInTheDOM()
123+
expect(queryByLabelText(/bat/)).toBeTruthy()
124124
})
125125

126126
test('get element by its alt text', () => {
@@ -130,7 +130,9 @@ test('get element by its alt text', () => {
130130
<img alt="finding nemo poster" src="/finding-nemo.png" />
131131
</div>,
132132
`)
133-
expect(getByAltText(/fin.*nem.*poster$/i).src).toBe('http://localhost/finding-nemo.png')
133+
expect(getByAltText(/fin.*nem.*poster$/i).src).toBe(
134+
'http://localhost/finding-nemo.png',
135+
)
134136
})
135137

136138
test('query/get element by its title', () => {
@@ -161,14 +163,14 @@ test('query/get element by its value', () => {
161163

162164
test('can get elements by data-testid attribute', () => {
163165
const {queryByTestId} = render(`<div data-testid="firstName"></div>`)
164-
expect(queryByTestId('firstName')).toBeInTheDOM()
165-
expect(queryByTestId(/first/)).toBeInTheDOM()
166-
expect(queryByTestId(testid => testid === 'firstName')).toBeInTheDOM()
166+
expect(queryByTestId('firstName')).toBeTruthy()
167+
expect(queryByTestId(/first/)).toBeTruthy()
168+
expect(queryByTestId(testid => testid === 'firstName')).toBeTruthy()
167169
// match should be exact, case-sensitive
168-
expect(queryByTestId('firstname')).not.toBeInTheDOM()
169-
expect(queryByTestId('first')).not.toBeInTheDOM()
170-
expect(queryByTestId('firstNamePlusMore')).not.toBeInTheDOM()
171-
expect(queryByTestId('first-name')).not.toBeInTheDOM()
170+
expect(queryByTestId('firstname')).not.toBeTruthy()
171+
expect(queryByTestId('first')).not.toBeTruthy()
172+
expect(queryByTestId('firstNamePlusMore')).not.toBeTruthy()
173+
expect(queryByTestId('first-name')).not.toBeTruthy()
172174
})
173175

174176
test('getAll* matchers return an array', () => {
@@ -248,8 +250,8 @@ test('using jest helpers to assert element states', () => {
248250
const {queryByTestId} = render(`<span data-testid="count-value">2</span>`)
249251

250252
// other ways to assert your test cases, but you don't need all of them.
251-
expect(queryByTestId('count-value')).toBeInTheDOM()
252-
expect(queryByTestId('count-value1')).not.toBeInTheDOM()
253+
expect(queryByTestId('count-value')).toBeTruthy()
254+
expect(queryByTestId('count-value1')).not.toBeTruthy()
253255
expect(queryByTestId('count-value')).toHaveTextContent('2')
254256
expect(queryByTestId('count-value')).not.toHaveTextContent('21')
255257
expect(() =>
@@ -258,21 +260,17 @@ test('using jest helpers to assert element states', () => {
258260

259261
// negative test cases wrapped in throwError assertions for coverage.
260262
expect(() =>
261-
expect(queryByTestId('count-value')).not.toBeInTheDOM(),
263+
expect(queryByTestId('count-value')).not.toBeTruthy(),
262264
).toThrowError()
263265
expect(() =>
264-
expect(queryByTestId('count-value1')).toBeInTheDOM(),
266+
expect(queryByTestId('count-value1')).toBeTruthy(),
265267
).toThrowError()
266268
expect(() =>
267269
expect(queryByTestId('count-value')).toHaveTextContent('3'),
268270
).toThrowError()
269271
expect(() =>
270272
expect(queryByTestId('count-value')).not.toHaveTextContent('2'),
271273
).toThrowError()
272-
273-
expect(() =>
274-
expect({thisIsNot: 'an html element'}).toBeInTheDOM(),
275-
).toThrowError()
276274
})
277275

278276
test('using jest helpers to check element attributes', () => {
@@ -359,21 +357,21 @@ test('test the debug helper prints the dom state here', () => {
359357
</div>`
360358

361359
const {getByText} = render(Large) // render large DOM which exceeds 7000 limit
362-
expect(() => expect(getByText('not present')).toBeInTheDOM()).toThrowError()
360+
expect(() => expect(getByText('not present')).toBeTruthy()).toThrowError()
363361

364362
const Hello = `<div data-testid="debugging" data-otherid="debugging">
365363
Hello World!
366364
</div>`
367365
const {getByTestId} = render(Hello)
368366
process.env.DEBUG_PRINT_LIMIT = 5 // user should see `...`
369-
expect(() => expect(getByTestId('not present')).toBeInTheDOM()).toThrowError(
367+
expect(() => expect(getByTestId('not present')).toBeTruthy()).toThrowError(
370368
/\.\.\./,
371369
)
372370

373371
const {getByLabelText} = render(Hello)
374372
process.env.DEBUG_PRINT_LIMIT = 10000 // user shouldn't see `...`
375373
expect(() =>
376-
expect(getByLabelText('not present')).toBeInTheDOM(/^((?!\.\.\.).)*$/),
374+
expect(getByLabelText('not present')).toBeTruthy(/^((?!\.\.\.).)*$/),
377375
).toThrowError()
378376

379377
//all good replacing it with old value

src/__tests__/example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test('examples of some things', async () => {
4242
getByText(container, 'Print Username').click()
4343

4444
await wait(() =>
45-
expect(queryByTestId(container, 'printed-username')).toBeInTheDOM(),
45+
expect(queryByTestId(container, 'printed-username')).toBeTruthy(),
4646
)
4747

4848
// getByTestId and queryByTestId are an escape hatch to get elements

src/__tests__/wait-for-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {waitForElement, wait} from '../'
2-
// adds special assertions like toBeInTheDOM
2+
// adds special assertions like toBeTruthy
33
import 'jest-dom/extend-expect'
44
import {render} from './helpers/test-utils'
55

0 commit comments

Comments
 (0)