@@ -392,6 +392,20 @@ test('accessible regex name in error message for multiple found', () => {
392
392
. toThrowErrorMatchingInlineSnapshot ( `
393
393
"Found multiple elements with the role "button" and name \`/value/i\`
394
394
395
+ Here are the matching elements:
396
+
397
+ <button>
398
+ Increment value
399
+ </button>
400
+
401
+ <button>
402
+ Decrement value
403
+ </button>
404
+
405
+ <button>
406
+ Reset value
407
+ </button>
408
+
395
409
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
396
410
397
411
<div>
@@ -420,6 +434,20 @@ test('accessible string name in error message for multiple found', () => {
420
434
. toThrowErrorMatchingInlineSnapshot ( `
421
435
"Found multiple elements with the role "button" and name "Submit"
422
436
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
+
423
451
(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
424
452
425
453
<div>
@@ -436,6 +464,48 @@ test('accessible string name in error message for multiple found', () => {
436
464
` )
437
465
} )
438
466
467
+ test ( 'matching elements in error for multiple found' , ( ) => {
468
+ const { getByRole} = render (
469
+ `<button>Increment value</button
470
+ ><button>Different label</button
471
+ ><p>Wrong role</p
472
+ ><button>Reset value</button
473
+ >` ,
474
+ )
475
+
476
+ expect ( ( ) => getByRole ( 'button' , { name : / v a l u e / i} ) )
477
+ . toThrowErrorMatchingInlineSnapshot ( `
478
+ "Found multiple elements with the role "button" and name \`/value/i\`
479
+
480
+ Here are the matching elements:
481
+
482
+ <button>
483
+ Increment value
484
+ </button>
485
+
486
+ <button>
487
+ Reset value
488
+ </button>
489
+
490
+ (If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).
491
+
492
+ <div>
493
+ <button>
494
+ Increment value
495
+ </button>
496
+ <button>
497
+ Different label
498
+ </button>
499
+ <p>
500
+ Wrong role
501
+ </p>
502
+ <button>
503
+ Reset value
504
+ </button>
505
+ </div>"
506
+ ` )
507
+ } )
508
+
439
509
describe ( 'configuration' , ( ) => {
440
510
let originalConfig
441
511
beforeEach ( ( ) => {
0 commit comments