You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fireEvent doesn't deliver raw touch events to an ancestor when a view below declines the responder #1957
fireEvent(element, 'touchStart') skips an ancestor's onTouchStart when the nearest touch responder below that ancestor declines the responder (onStartShouldSetResponder returns false). The same goes for touchMove and touchEnd.
On a device, raw touch events aren't part of the responder negotiation: they reach every ancestor's onTouchStart/onTouchMove/onTouchEnd, whether or not a view accepts the responder (verified on a device: RN 0.88.1, Android emulator, the same parent and child as below, with a tap and a drag). A test that checks a screen observing touches from above (to pause a timer while a finger is down, say) fails under Testing Library, even though the app works.
The rule comes from isEventEnabled, which applies the nearest responder's answer to every event type (src/events/is-enabled.ts at v14.1.0). It isn't new in 14: 13.3.3 has the same check in src/fire-event.ts.
We hit it with React Native Gesture Handler 3: its Jest stand-in for a hook gesture's detector is a View that receives the detector's onStartShouldSetResponder. So any raw touch fired under a GestureDetector stops reaching the ancestors (reported on their side as software-mansion/react-native-gesture-handler#4656).
Expected behavior
Raw touch events (touchStart, touchMove, touchEnd, touchCancel) reach every ancestor's handler, as on a device. The responder check would still apply to responder-driven events such as press and the responder* events.
import{fireEvent,render,screen}from'@testing-library/react-native';import{View}from'react-native';it('a raw touchStart reaches the parent when the child declines the responder',async()=>{constonTouchStart=jest.fn();awaitrender(<ViewonTouchStart={onTouchStart}><ViewtestID="child"onStartShouldSetResponder={()=>false}/></View>,);awaitfireEvent(screen.getByTestId('child'),'touchStart');expect(onTouchStart).toHaveBeenCalledTimes(1);// fails: 0 calls});
The same test without onStartShouldSetResponder on the child passes. The repo also shows the Gesture Handler 3 case: a hook gesture fails, while a builder-API gesture passes.
@jrmsayag thanks for bringing this up. I am currently working on impklementing a modern event system for RNTL v14, which should provide much more realistic simulation of event system, including fix for the issue you mentioned.
Activity
mdjastrzebski commentedon Nov 5, 2026
@jrmsayag thanks for bringing this up. I am currently working on impklementing a modern event system for RNTL v14, which should provide much more realistic simulation of event system, including fix for the issue you mentioned.