-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
shallow text() returns 'TouchableText' instead text itself. #2188
Comments
This is expected because a shallow wrapper of X is whatever X renders, not X itself - additionally, shallow takes a react element, not a string. What happens if you shallow wrap a component that renders your desired text? |
The problem here is that it returns 'TouchableText'. It looks happening only in some environment. In other environments, it returns 'some text' correctly. |
One issue i see is that your react-test-renderer version is 16.3 while your react is 16.8; those always need to be the same minor. Separately though, what does |
react and react-test-renderer minor versions are all 8. 16.8.3 and 16.8.6. Do you mean that all patch ( the latest) should be same? |
Oh, nvm, i misread. In that case that’s not it - the other point still stands, tho. |
I have same Issue. |
Can you share the code for “Text”? If this is the react native primitive, without an actual react native enzyme adapter, you won’t be able to reliably use enzyme with react - follow #1436 for that. |
shallow().debug() results in below.
|
And the code for the Text component? |
What do you mean by 'the code for the Text component'?
is the code to test the enzyme and the Text component. 'Text' is the primitive RN component. |
OK, so then the answer is
enzyme does not support React Native without a react-native adapter, which as far as I know does not yet exist. Closing in lieu of #1436. |
this should work const text = 'some text';
const wrapper = shallow(<Text>{text}</Text>);
const textNode = wrapper.find('Text')
expect(textNode.children().text()).toEqual(text); |
const text = 'some text'; expect(textNode.children().text()).toEqual(text); |
Thanks for reporting an issue to us! We're glad you are using and invested in Enzyme.
Before submitting, please read over our commonly reported issues to prevent duplicates!
All common issues
Notoriously common issues
If you haven't found any duplicated issues, please report it with your environment!
Current behavior
Expected behavior
Your environment
API
Version
Adapter
The text was updated successfully, but these errors were encountered: