MCPcopy Index your code
hub / github.com/callstack/react-native-testing-library / getRole

Function getRole

src/helpers/accessibility.ts:117–131  ·  view source on GitHub ↗
(instance: TestInstance)

Source from the content-addressed store, hash-verified

115 * @returns
116 */
117export function getRole(instance: TestInstance): Role | AccessibilityRole {
118 const explicitRole = instance.props.role ?? instance.props.accessibilityRole;
119 if (explicitRole) {
120 return normalizeRole(explicitRole);
121 }
122
123 if (isHostText(instance)) {
124 return 'text';
125 }
126
127 // Note: host Image elements report "image" role in screen reader only on Android, but not on iOS.
128 // It's better to require explicit role for Image elements.
129
130 return 'none';
131}
132
133/**
134 * There are some duplications between (ARIA) `Role` and `AccessibilityRole` types.

Callers 5

queryAllByRoleFunction · 0.90
computeAriaCheckedFunction · 0.85

Calls 2

isHostTextFunction · 0.90
normalizeRoleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…