-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Provide a feature to mock native components in React Native #1738
Comments
Ok. It seems that This is it's property descriptor:
So, if you want to mock this function, do
Calling For that code, this snapshot is generated:
Not very helpful :) I'm closing issue since it's not related to Jest actually |
No, I will reopen it, since it generated helpful snapshots for some native components. I just wanted to have something like this, but for my custom component...
|
Hotfix(Or "Resolve"?) Just use React Element when you are mocking your native Component: Same code as abode, but only difference:
Provides this snapshot:
👍 👍 👍 P.S. That was very unclear. Thanks https://github.com/facebook/jest/blob/master/packages/jest-react-native/src/index.js and https://github.com/facebook/jest/blob/master/packages/jest-react-native/src/setup.js |
It seems like you figured out how to provide your own mock. If you can think of a generic solution to this, please feel free to send a PR. I'm gonna close this issue for now however as I'm unclear what kind of action we could take. |
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 want to request a feature. Using React Native v0.33, jest latest v15
What is the current behavior?
Non-testable code, which uses custom native component
What is the expected behavior?
Provide some way to define mock for native component.
It's just about
requireNativeComponent
. Can we mock it or something? I wanted to make a snapshot test with native component.For now, It just pops in console:
(
RCTPieChart
is custom component)The text was updated successfully, but these errors were encountered: