Closed
Description
Describe the bug
getByRole(role, {name})
doesn't work when the target node doesn't have components as a child.
test('returns an element when the direct child is text', () => {
const { getByRole } = render(
<Text accessibilityRole="header" testID="target-header">
About
</Text>
);
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
expect(getByRole('header', { name: 'About' }).props.testID).toBe(
'target-header'
);
});
Issue open for better tracking, see #1139 for discussions.
Versions
RNTL 11.2
Metadata
Metadata
Assignees
Labels
No labels