MCPcopy
hub / github.com/testing-library/dom-testing-library / queryAllByRole

Function queryAllByRole

src/queries/role.ts:42–305  ·  view source on GitHub ↗
(
  container,
  role,
  {
    hidden = getConfig().defaultHidden,
    name,
    description,
    queryFallbacks = false,
    selected,
    busy,
    checked,
    pressed,
    current,
    level,
    expanded,
    value: {
      now: valueNow,
      min: valueMin,
      max: valueMax,
      text: valueText,
    } = {} as NonNullable<ByRoleOptions['value']>,
  } = {},
)

Source from the content-addressed store, hash-verified

40import {buildQueries, getConfig, matches} from './all-utils'
41
42const queryAllByRole: AllByRole = (
43 container,
44 role,
45 {
46 hidden = getConfig().defaultHidden,
47 name,
48 description,
49 queryFallbacks = false,
50 selected,
51 busy,
52 checked,
53 pressed,
54 current,
55 level,
56 expanded,
57 value: {
58 now: valueNow,
59 min: valueMin,
60 max: valueMax,
61 text: valueText,
62 } = {} as NonNullable<ByRoleOptions['value']>,
63 } = {},
64) => {
65 checkContainerType(container)
66
67 if (selected !== undefined) {
68 // guard against unknown roles
69 if (
70 allRoles.get(role as ARIARoleDefinitionKey)?.props['aria-selected'] ===
71 undefined
72 ) {
73 throw new Error(`"aria-selected" is not supported on role "${role}".`)
74 }
75 }
76
77 if (busy !== undefined) {
78 // guard against unknown roles
79 if (
80 allRoles.get(role as ARIARoleDefinitionKey)?.props['aria-busy'] ===
81 undefined
82 ) {
83 throw new Error(`"aria-busy" is not supported on role "${role}".`)
84 }
85 }
86
87 if (checked !== undefined) {
88 // guard against unknown roles
89 if (
90 allRoles.get(role as ARIARoleDefinitionKey)?.props['aria-checked'] ===
91 undefined
92 ) {
93 throw new Error(`"aria-checked" is not supported on role "${role}".`)
94 }
95 }
96
97 if (pressed !== undefined) {
98 // guard against unknown roles
99 if (

Callers 2

testByRoleFunction · 0.85
element-queries.jsFile · 0.85

Calls 15

checkContainerTypeFunction · 0.90
getImplicitAriaRolesFunction · 0.90
computeAriaSelectedFunction · 0.90
computeAriaBusyFunction · 0.90
computeAriaCheckedFunction · 0.90
computeAriaPressedFunction · 0.90
computeAriaCurrentFunction · 0.90
computeAriaExpandedFunction · 0.90
computeHeadingLevelFunction · 0.90
computeAriaValueNowFunction · 0.90
computeAriaValueMaxFunction · 0.90
computeAriaValueMinFunction · 0.90

Tested by 1

testByRoleFunction · 0.68