Jest: with the hook API, raw touch events fired under a `GestureDetector` don't reach ancestors under Testing Library 14
Les mainteneurs répondent en général sous 2 jours
@aliassar y travaille déjà.
Depuis le 2/11/2026.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 66/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react-native, typescript
Piste de recherche
Start with the Jest mock at src/mocks/hostDetector.tsx and the hook detector at src/v3/detectors/NativeDetector.tsx, then reproduce the failing case from the linked repository with npx jest. Check how the mock and detector interact with Testing Library 14's touch event handling. Done when the parent receives touchStart in Jest under a hook gesture and the builder API case still passes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
This happens only in Jest: it's an interaction between Gesture Handler 3's test stand-in and React Native Testing Library, not a bug in the runtime.
Under Jest, jestSetup.js replaces HostGestureDetector with a plain View (src/mocks/hostDetector.tsx at v3.3.0). For a hook gesture, NativeDetector passes that View its onStartShouldSetResponder (NativeDetector.tsx#L76 at v3.3.0), which declines the responder.
Testing Library 14 treats a declining responder as blocking every event for the ancestors above it, raw touch events included. So fireEvent(child, 'touchStart') under a hook gesture's GestureDetector no longer reaches a parent's onTouchStart. On a device it does. (Once a gesture activates on a device, the ancestors get touchCancel, as expected: that isn't what this is about. In Jest, touchStart and the moves before activation never reach them.) With a builder-API gesture, no such View is rendered and the touch gets through, so tests that passed on 2.x start failing after moving to the hooks.
The root cause appears to be on Testing Library's side: on a device, raw touch events reach every ancestor whatever the responder does, and Testing Library applies the responder rule to them anyway. I've reported it there as callstack/react-native-testing-library#1957. I'm raising it here too because Gesture Handler 3 users will run into it when they move tests from the builder API to the hooks, so you may want to do something about it on your side, or at least be aware of it.
Steps to reproduce
- Clone https://github.com/jrmsayag/rntl-touch-bubbling-repro-demo and run
npm ci. - Run
npx jest. - "with a hook-API gesture (usePanGesture())" fails: the parent's
onTouchStartgets 0 calls. "with a builder-API gesture (Gesture.Pan())" passes.
function Pannable() {
const gesture = usePanGesture({});
return (
<GestureDetector gesture={gesture}>
<View testID="child" />
</GestureDetector>
);
}
it('a raw touchStart under a hook gesture reaches the parent', async () => {
const onTouchStart = jest.fn();
await render(
<GestureHandlerRootView>
<View onTouchStart={onTouchStart}>
<Pannable />
</View>
</GestureHandlerRootView>,
);
await fireEvent(screen.getByTestId('child'), 'touchStart');
expect(onTouchStart).toHaveBeenCalledTimes(1); // fails: 0 calls
});
A link to a Gist, an Expo Snack or a link to a repository
https://github.com/jrmsayag/rntl-touch-bubbling-repro-demo
Gesture Handler version
3.3.0
React Native version
0.88.1
Platforms
Android, iOS (it happens in Jest, whatever the platform)
JavaScript runtime
Hermes (not relevant: Jest runs on Node)
Workflow
Using Expo Prebuild or an Expo development build (the repro itself is plain React Native with @react-native/jest-preset)
Build type
Debug mode
Device
Not applicable (Jest); pick any.
Device model
Not applicable (Jest, Node 22). @testing-library/react-native 14.1.0, Jest 30.5.2.
Acknowledgements
Yes
- Langage dominant
- TypeScript
- Étoiles
- 6.8k
- Forks
- 1.1k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 46
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de software-mansion/react-native-gesture-handler
-
[Jest][3.5.0] `fireEvent.press` no longer reaches `Touchable` when its child is inside an `InterceptingGestureDetector`Peut-être pris @m-bert l’a pris il y a 3 jours. OuverteMissing info Platform: Web
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
software-mansion/react-native-gesture-handler#4689 · 4 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[Web] GestureDetector blocks context menu by defaultPeut-être pris @lassiecoder l’a pris il y a 4 jours. OuvertePlatform: Web
Difficulté 3/5 1-2 jours Accessibilité débutants 56/100
software-mansion/react-native-gesture-handler#4687 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[Android] v3 `ReanimatedSwipeable` takes over a vertical scroll in a React Native list once the finger drifts 10 dp sidewaysPeut-être à nouveau libre @JaydeepAgravat l’a pris il y a 10 jours, et aucune pull request n’est ouverte. OuvertePlatform: Android
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
software-mansion/react-native-gesture-handler#4670 · 6 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[Android] A held tap on a Touchable or Pressable in ScrollView does nothing while the keyboard is upPeut-être pris @m-bert l’a pris il y a 6 jours. OuverteMissing repro Platform: Android
Difficulté 4/5 3-5 jours Accessibilité débutants 50/100
software-mansion/react-native-gesture-handler#4653 · 7 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
[IOS] The "hitslop" attribute used in the packaging component FlatList does not work as expected.OuverteClose when stale Missing repro Platform: iOS
Difficulté 3/5 1-2 jours Accessibilité débutants 48/100
software-mansion/react-native-gesture-handler#4649 · 2 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de software-mansion/react-native-gesture-handler
Issues similaires
-
Stop retrying permanent GitHub API failures in retry.shPeut-être pris @muspi-merol-review l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
promplate/code-review#113 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
ix-toast (5.3): the status icon has `role="img"` and no accessible name (axe `role-img-alt`)Ouvertetriage
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 1 jour
-
サムネイルの Storage のバケット(`thumbnails`)に、大きさの上限(1 MiB)と許可する種類(JPEG、PNG、WebP)を設定するPeut-être pris @ykzts l’a pris aujourd’hui. Ouvertetech: supabase
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
inabagumi/shinju-date#7147 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
elecnix/your-attention#129 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
umami-software/umami#4780 ·
Les mainteneurs répondent en général sous 3 jours