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
Jest for react-native does not recognize all props for <TouchableHighlight /> #1720
Comments
We don't specifically mock TouchableHighlight. It is rendered as View because that is what react-native renders it to. It seems like TouchableHighlight sets props directly on its native backing element: https://github.com/facebook/react-native/blob/master/Libraries/Components/Touchable/TouchableHighlight.js#L200 and you'd need a special mock for it to make it so your prop shows up in the rendered output. One thing that might work could be to create your own mock like suggested in the second example on the website: http://facebook.github.io/jest/docs/tutorial-react-native.html#mock-native-modules-using-jest-mock
|
@cpojer Thank you for quick response! My snapshot looks much cleaner now.
Any idea how I can simulate button click? Or do anything to have my test cover Thanks in advance! |
@rosiakr Yes, you can test the button click event.
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have a class for my custom button:
and the snapshot is generated with this test:
but when I add another prop to the
<TouchableHighlight/>
element, like:and re-run the test - I don't get a diff showing that the snapshot did not expect this extra prop. In fact, the only prop evaluated seams to be "style".
Is this work in progress?
Also, on a related note - why is TouchableHighlight's type showing in snapshot (and debugger) as 'View' and not 'TouchableHightlight'?
In my package.jason I have:
and my .babelrc in root dir is:
The text was updated successfully, but these errors were encountered: