@@ -29,6 +29,7 @@ getByRole(
2929 expanded?: boolean ,
3030 queryFallbacks?: boolean ,
3131 level?: number ,
32+ disabled?: boolean ,
3233 value?: {
3334 min?: number ,
3435 max?: number ,
@@ -356,7 +357,8 @@ specific value using the `level` option
356357` getByRole('spinbutton', { value: { now: 5, min: 0, max: 10, text: 'medium' } }) ` .
357358
358359Note that you don't have to specify all properties in ` value ` . A subset is
359- sufficient e.g. ` getByRole('spinbutton', { value: { now: 5, text: 'medium' } }) ` .
360+ sufficient e.g.
361+ ` getByRole('spinbutton', { value: { now: 5, text: 'medium' } }) ` .
360362
361363Given the example below,
362364
@@ -399,7 +401,7 @@ getAllByRole('spinbutton', {value: {min: 0}})
399401```
400402
401403> Every specified property in ` value ` must match. For example, if you query for
402- > ` {value: {min: 0, now: 3}} ` ` aria-valuemin ` must be equal to 0 ** AND**
404+ > ` {value: {min: 0, now: 3}} ` ` aria-valuemin ` must be equal to 0 ** AND** >
403405> ` aria-valuenow ` must be equal to 3
404406
405407> The ` value ` option is _ only_ applicable to certain roles (check the linked MDN
@@ -444,3 +446,32 @@ You can query a specific element like this
444446``` js
445447getByRole (' alertdialog' , {description: ' Your session is about to expire' })
446448```
449+
450+ ### ` disabled `
451+
452+ You can filter the returned elements by their disabled state by setting
453+ ` disabled: true ` , ` disabled: false ` , ` aria-disabled: true ` or
454+ ` aria-disabled: false ` .
455+
456+ For example in
457+
458+ ``` html
459+ <body >
460+ <button disabled >disabled</button >
461+ <button aria-disabled =" true" >aria-disabled</button >
462+ <button >normal</button >
463+ </body >
464+ ```
465+
466+ you can query a specific element(s) like this
467+
468+ ``` js
469+ getAllByRole (' button' , {disabled: true })
470+ // [
471+ // <button disabled>disabled</button>,
472+ // <button aria-disabled="true">aria-disabled</button>
473+ // ]
474+
475+ getByRole (' button' , {disabled: false })
476+ // <button>normal</button>
477+ ```
0 commit comments