-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add ability to fire gesture events in testing #1844
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
Conversation
Rename testHandlerTag to testId
|
Good point, fixed in 45f7d9e. |
Co-authored-by: Jakub Piasecki <[email protected]>
|
Hey @jakub-gonet @j-piasecki , do you know when a release including <GestureDetector gesture={tap}>
<View testID="background" style={[styles.background]} />
</GestureDetector>Or do you have a nightly build of master to use ? |
|
Hi @Andarius! We have just released a new version that, among others, contains the testing API. |
|
@jakub-gonet @j-piasecki is it expected that without Fabric enabled, the Suggested PR here: #1910 I could be wrong and this may be something that needs to be handled higher up instead of only assigning testID to the cloned element if one was provided to the handler |
…signed (#1910) Fix related to comment [here](#1844 (comment)) about `RNGestureHandlerButton` with `handlerType="NativeViewGestureHandler"` having missing testIDs when they were previously provided and assigned. The `testID` on the child being cloned within `createHandler` was being removed by the `testID` being set within the render function even the `testID` on the handler was not set. Now it will only assign a `testID` as a prop on the cloned element if a `testID` was provided to the handler.
Description
Supersedes #1762.
Needs to be synchronized with software-mansion/react-native-reanimated#2885.
This PR introduces a new test API
fireGestureHandler(handler, eventList), allowing to test handlers bound to a given gesture (or gesture handler).handlercan be one of two things:getByTestId(testIDmust be used directly on handler, e.g.<RotationGestureHandler testID="rotation">),getByHandlerTestId(testIDcan be set viawithTestId(name), e.g.Gesture.Pan().withTestId('pan')).eventListcontains events that should be emitted to providedhandler. State change events must havestatefield. SubsequentACTIVEevents can havestatefield omitted. Every entry can have additional attributes for a given handler type (e.g.translationXfor Pan).fireGestureHandleris typed and can be parametrized with all Gestures and Gesture Handlers (e.g.fireGestureHandler<PanGesture>,fireGestureHandler<LongPressGestureHandler>).Example test
TODO
fireGestureHandlerwith handler, e.g.fireGestureHandler<PanGesture>(...)orfireGestureHandler<PanGestureHandler>(...).Test plan
Ran
yarn test -i Events.