Skip to content

ByRole queries don't find node with name when the node with role has the name as a direct string child #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AugustinLF opened this issue Sep 27, 2022 · 0 comments · Fixed by #1139

Comments

@AugustinLF
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant