How can I test it with Jest and React Native Testing Library? #423
Unanswered
dutradotdev
asked this question in
Q&A
Replies: 2 comments 8 replies
-
@dutradotdev in my case I was able to test it as follows: // in component
<DatePicker
// other props
testID="Date Picker"
/>
// in test
const someDate = new Date();
fireEvent(queryByTestId('Date Picker'), 'onChange', {
nativeEvent: { timestamp: someDate.getTime() },
}); |
Beta Was this translation helpful? Give feedback.
8 replies
-
@dutradotdev I was able to mock this by using jest manual mock https://jestjs.io/docs/tutorial-react-native#mock-native-modules-using-jestmock sample code :
Hope this helps |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I want to know how can I test it with Jest and React Native Testing Library? How to mock the DatePicker, select the confirm/cancel button and so on. Do you have a example of it?
Beta Was this translation helpful? Give feedback.
All reactions