Skip to content

fix: add React.Fragment support for matching text #883

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
wants to merge 1 commit into from

Conversation

Alvindelito
Copy link

Summary

This PR builds upon #663

I have used the code provided by @lachiet with an added conditional.

Searching for text by using getByText() should now detect the text inside of a <React.Fragment> nested in a <Text> component.

<Text>
  <React.Fragment>Hello world</React.Fragment>
</Text>

Test plan

I have included a test to test the new change and all other tests have passed.

@thymikee
Copy link
Member

Thanks for your contribution @Alvindelito! Can you test if this works with nested fragments as well? Checking for parent.parent proved to be buggy in the past. Also, have you considered updating the getChildrenAsText method to check for Fragment type? We could use react-is for this.

@thymikee
Copy link
Member

Closed via #934

@thymikee thymikee closed this Mar 25, 2022
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 this pull request may close these issues.

2 participants