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
RTL has userEvent that simulates user interactions instead of just dispatching native events like fireEvent.
Possible Implementations
In RTL this is a separate package, as it can be used with various web TL implementations based on DOM TL. We could just add it to our main package as another export.
Alternatively, we could migrate our repo to monorepo and have it as a separate package.
Features
Example APIs
simulate typing events, by inputing text character by character and also triggering onFocus/onBlur
simulate scroll events which involve following native calls: onScrollBeginDrag, onScrollEndDrag and also in between values.
simulate pasteboard event
In the initial PR we should focus on mobile features for touch screen devices, while later on we might add also more keyboard control/pointer events that make sense for connected accessories/desktop platforms like mac/windows
API surface
User Event has two versions of API, legacy v13, and current v14. I think that unless we find any compelling reasons, we should try to maintain API similarity with current v14.
Defining correct approach
In order to define correct behaviour person implementing this would have to start with investigating the real RN app behaviour on both iOS and Android. In order to observe what should happen e.g. when calling userEvent.press they would have to attach all potentially relevant event handlers for given host component, and observe sequence of called events as well as passed payloads. In certain cases there would be slight differences between iOS and Android, which might need further consideration.
Using fireEvent
Unlike the original User Event we do not have access to simulated DOM env that would dispatch events for us, in such case we will probably want to use fireEvent under-the-hood to trigger a sequence of relevant events for us.
Imo having it inside the library will enable this new feature to have more visibility than if it was a separate export. For instance, I have the feeling jest-native is not so used by the community because it's in a separate package that's not as much advertised.
Is it alright for you if we start small and investigate userEvent.press?
Reacted by Maciej Jastrzebski, Augustin Le Fèvre and Samitha Nanayakkara
Activity
thymikee commentedon Sep 15, 2022
I'm ok with this being a separate export. Are there any plans for RTL to merge this library in, provided it's so essential?
mdjastrzebski commentedon Sep 15, 2022
Not sure if they plan re-exporting it like DOM TL quieres.
Since it's a general DOM library they might value being able to develop and version it independently from RTL/DTL.
MattAgn commentedon Jan 20, 2023
With @pierrezimmermannbam we'd love to work on that!
Imo having it inside the library will enable this new feature to have more visibility than if it was a separate export. For instance, I have the feeling jest-native is not so used by the community because it's in a separate package that's not as much advertised.
Is it alright for you if we start small and investigate userEvent.press?
mdjastrzebski commentedon Aug 6, 2023
Basic User Event API has been released in v12.2.0 🚀🎉