Skip to content

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

Closed
Alvindelito wants to merge 1 commit into
callstack:mainfrom
Alvindelito:main
Closed

fix: add React.Fragment support for matching text#883
Alvindelito wants to merge 1 commit into
callstack:mainfrom
Alvindelito:main

Conversation

@Alvindelito

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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