Skip to content

Commit ca6ceb3

Browse files
committed
Adds accessible name to error message
1 parent b339616 commit ca6ceb3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/__tests__/role.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,18 +390,21 @@ test('accessible regex name in error message for multiple found', () => {
390390

391391
expect(() => getByRole('button', {name: /value/i}))
392392
.toThrowErrorMatchingInlineSnapshot(`
393-
"Found multiple elements with the role "button"
393+
"Found multiple elements with the role "button" and name \`/value/i\`
394394
395395
Here are the matching elements:
396396
397397
<button>
398398
Increment value
399399
</button>
400400
401+
<button>
402+
Decrement value
403+
</button>
404+
401405
<button>
402406
Reset value
403407
</button>
404-
"Found multiple elements with the role "button" and name \`/value/i\`
405408
406409
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
407410
@@ -431,6 +434,20 @@ test('accessible string name in error message for multiple found', () => {
431434
.toThrowErrorMatchingInlineSnapshot(`
432435
"Found multiple elements with the role "button" and name "Submit"
433436
437+
Here are the matching elements:
438+
439+
<button>
440+
Submit
441+
</button>
442+
443+
<button>
444+
Submit
445+
</button>
446+
447+
<button>
448+
Submit
449+
</button>
450+
434451
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
435452
436453
<div>
@@ -458,7 +475,7 @@ test('matching elements in error for multiple found', () => {
458475

459476
expect(() => getByRole('button', {name: /value/i}))
460477
.toThrowErrorMatchingInlineSnapshot(`
461-
"Found multiple elements with the role "button"
478+
"Found multiple elements with the role "button" and name \`/value/i\`
462479
463480
Here are the matching elements:
464481

0 commit comments

Comments
 (0)