@@ -412,6 +412,7 @@ test('queryAllByRole returns semantic html elements', () => {
412
412
</tbody>
413
413
</table>
414
414
<table role="grid"></table>
415
+ <div role="meter progressbar" />
415
416
<button>Button</button>
416
417
</form>
417
418
` )
@@ -433,6 +434,7 @@ test('queryAllByRole returns semantic html elements', () => {
433
434
expect ( queryAllByRole ( / r o w g r o u p / i) ) . toHaveLength ( 2 )
434
435
expect ( queryAllByRole ( / ( t a b l e ) | ( t e x t b o x ) / i) ) . toHaveLength ( 3 )
435
436
expect ( queryAllByRole ( / i m g / i) ) . toHaveLength ( 1 )
437
+ expect ( queryAllByRole ( 'progressbar' , { queryFallbacks : true } ) ) . toHaveLength ( 1 )
436
438
} )
437
439
438
440
test ( 'getAll* matchers return an array' , ( ) => {
@@ -471,6 +473,7 @@ test('getAll* matchers return an array', () => {
471
473
<option value="volvo">Toyota</option>
472
474
<option value="audi">Honda</option>
473
475
</select>
476
+ <div role="meter progressbar" />
474
477
</div>,
475
478
` )
476
479
expect ( getAllByAltText ( / f i n d i n g .* p o s t e r $ / i) ) . toHaveLength ( 2 )
@@ -482,6 +485,7 @@ test('getAll* matchers return an array', () => {
482
485
expect ( getAllByDisplayValue ( / c a r s $ / ) ) . toHaveLength ( 2 )
483
486
expect ( getAllByText ( / ^ w h e r e / i) ) . toHaveLength ( 1 )
484
487
expect ( getAllByRole ( / c o n t a i n e r / i) ) . toHaveLength ( 1 )
488
+ expect ( getAllByRole ( 'progressbar' , { queryFallbacks : true } ) ) . toHaveLength ( 1 )
485
489
} )
486
490
487
491
test ( 'getAll* matchers throw for 0 matches' , ( ) => {
@@ -658,6 +662,18 @@ test('using jest helpers to check element role', () => {
658
662
expect ( getByRole ( 'dialog' ) ) . toHaveTextContent ( 'Contents' )
659
663
} )
660
664
665
+ test ( 'using jest helpers to check element fallback roles' , ( ) => {
666
+ const { getByRole} = render ( `
667
+ <div role="meter progressbar">
668
+ <span>Contents</span>
669
+ </div>
670
+ ` )
671
+
672
+ expect ( getByRole ( 'progressbar' , { queryFallbacks : true } ) ) . toHaveTextContent (
673
+ 'Contents' ,
674
+ )
675
+ } )
676
+
661
677
test ( 'test the debug helper prints the dom state here' , ( ) => {
662
678
const originalDebugPrintLimit = process . env . DEBUG_PRINT_LIMIT
663
679
const Large = `<div>
0 commit comments