-
Notifications
You must be signed in to change notification settings - Fork 273
ByText queries don't seem to match across multiple Text elements #1221
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
Comments
The behaviour is party correct. In my opinion it should behave in this way if function MyComponent() {
return (
<Text>
<Text>Hello</Text>
<Text>World</Text>
</Text>
);
} However it does not, and this is the bug that we should fix. As a temporary workaround I can suggest using some other query + |
Sure, it's just we're in the middle of a upgrade and lots of our tests are now breaking on this one. |
Understood, I cannot promise any fix date for that bug, as proper text matching subject is more complex than it looks at first glance, we had couple of back and forth changes in the implementation, and we are ware around introducing potential breaking changes to other users. If you have interest in this issue and some spare time I invite to provide a PR for that issue. Otherwise, changing query type and/or changing app structure to put string content into single |
I've had a dig, and I have it working, but I'm really not sure of the consequences of the changes I've made :D The first bit I've removed is this:
Maybe The second part is removing the condition of this:
To just:
I don't know why it's limited to only fragments, but I'm sure there is a reason. It does also mean changing the component to havea wrapping
So that's a limiting factor ... as you say this is a fragile piece of functionality, but the documentation implies things to be "just right" in order to work. We were using 7.2.0. and I think I'll be able to use a |
The reason why current implementation is not recursive, is that in following example: <Text testID="outer-text">
<Text testID="text-1">Hello</Text>
<Text testID="text-2">World</Text>
</Text> recursive query for |
@leepowelldev v11.5.0 contains a fix for matching nested It should work with: <Text>
<Text>Hello</Text>
<Text>World</Text>
</Text> but not with <View>
<Text>Hello</Text>
<Text>World</Text>
</View> |
Brilliant I’ll give it a shot. Will the docs be updated to reflect?On 17 Nov 2022, at 12:25, Maciej Jastrzebski ***@***.***> wrote:
@leepowelldev v11.5.0 contains a fix for matching nested Text content.
It should work with:
<Text>
<Text>Hello</Text>
<Text>World</Text>
</Text>
but not with
<View>
<Text>Hello</Text>
<Text>World</Text>
</View>
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Give this test:
I would expect the test to pass, according to the docs the
Text
elements should be joined together. I've tried various permutations (regex's, non-exact match, extra Text with a space) and nothing seems to match.Expected behavior
Test should pass
Steps to Reproduce
Run simple test as above (I can put in a repo if it helps)
Screenshots
Versions
npmPackages:
@testing-library/react-native: ^11.4.0 => 11.4.0
react: 18.1.0 => 18.1.0
react-native: 0.70.3 => 0.70.3
react-test-renderer: 18.1.0 => 18.1.0
The text was updated successfully, but these errors were encountered: