Skip to content

Commit d36f234

Browse files
Update dependency @testing-library/dom to v8.13.0 (#459)
1 parent 4145ced commit d36f234

4 files changed

Lines changed: 37 additions & 9 deletions

File tree

.changeset/purple-bags-add.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'pleasantest': minor
3+
---
4+
5+
Update dependency `@testing-library/dom` to `v8.13.0`.
6+
7+
This adds support to filtering `ByRole` queries by description:
8+
9+
```ts
10+
// Select by accessible role and description
11+
await screen.getByRole('button', {
12+
description: /^items in the trash will be/i,
13+
});
14+
```

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@rollup/plugin-alias": "3.1.9",
2020
"@rollup/plugin-babel": "5.3.1",
2121
"@rollup/plugin-node-resolve": "13.3.0",
22-
"@testing-library/dom": "8.12.0",
22+
"@testing-library/dom": "8.13.0",
2323
"@testing-library/jest-dom": "5.15.1",
2424
"@types/jest": "27.5.1",
2525
"@types/node": "12.20.52",

tests/testing-library-queries/ByRole.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ test(
88
<div>hello</div>
99
<div role="button">butt1</div>
1010
<div role="button">butt2</div>
11+
<button aria-describedby="trash-desc">Move to trash</button>
12+
<p id="trash-desc">Items in the trash will be permanently removed after 30 days.</p>
1113
`);
1214

1315
// Finds just one
1416
await screen.getByRole('heading');
15-
// Alternate syntax
17+
18+
// Select by accessible name
1619
await screen.getByRole('button', { name: /butt2/ });
20+
21+
// Select by accessible role and description
22+
await screen.getByRole('button', {
23+
description: /^items in the trash will be/i,
24+
});
25+
1726
// Doesn't find any
1827
await expect(screen.getByRole('banner')).rejects
1928
.toThrowErrorMatchingInlineSnapshot(`
@@ -41,6 +50,9 @@ test(
4150
Name \\"butt2\\":
4251
<div role=\\"button\\">butt2</div>
4352
53+
Name \\"Move to trash\\":
54+
<button aria-describedby=\\"trash-desc\\">Move to trash</button>
55+
4456
--------------------------------------------------
4557
4658
Within: #document"
@@ -56,6 +68,8 @@ test(
5668
5769
<div role=\\"button\\">butt2</div>
5870
71+
<button aria-describedby=\\"trash-desc\\">Move to trash</button>
72+
5973
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
6074
6175
Within: #document"

0 commit comments

Comments
 (0)