-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Add mocks for RNGH #493
Add mocks for RNGH #493
Conversation
@@ -0,0 +1,13 @@ | |||
export default { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also find out that you may need to mock those:
jest.mock('NativeModules', () => ({
UIManager: {
RCTView: () => {}, // or 'View'
},
PlatformConstants: {
forceTouchAvailable: false,
},
}))
I'm not sure but it may help others :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nevermind. You've changed implementation of GestureHandler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly I do not need PlatformConstants
. See the changes and you'll figure out why :).
Why do you think I do need RCTView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. This seems to be obsolete. I've had this one in past and thought it's still necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Can you just comment on how you tested this change? E.g. share a project with jest setup the way it picks up the correct mocks for GH
Co-Authored-By: osdnk <micosa97@gmail.com>
I'll share project later. I don't want to have it done in Example because of really strange config, which makes it more difficult and less universal. |
https://github.com/mehranabi/rn-gh-error/blob/master/__tests__/App.js |
@dsznajder I see that people are doing it, but I don't want to make it matter of faith. I suppose it was important it previous version because of this: But since this commit I see it does not have any impact. |
I can confirm that also. It does not make any difference with |
@@ -33,6 +34,8 @@ | |||
"PlatformConstants.web.js", | |||
"react-native-gesture-handler.d.ts", | |||
"README.md", | |||
"RNGestureHandlerModule.js", | |||
"jestConfig.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be jestSetup.js
, I think? Which probably explains why the jestSetup.js
appears to be missing from the 1.2.0 release.
(Also, thanks for this PR/adding this mock--I incidentally ran into issues trying to mock react-native-gesture-handler yesterday, so it landed with quite convenient timing!)
* Add basic test * cleanup * Directions -> Direction * Revert changes in package.json * Update package.json Co-Authored-By: osdnk <micosa97@gmail.com> * add a note to getting started
Motivation
Need to provide some mocks for RNGH in order to make it workable with jest.
Changes
PlatformConstants
. Thanks @tsapeta! Now I check whetherPlatformConstants
exists before usage.