react-native-testing-library
react-native-testing-library copied to clipboard
Make onPress more life-like
Taking inspiration from user-event which tries to mimic the real event order when user interacts with an element.
Summary
fireEvent.press
currently only invoke the onPress
-handler, and this PR aim to make it more real-life-like by also invoking onPressIn
, onPressOut
and onFocus
if possible (silently failing if there are no registered handlers).
Also adding fireEvent.longPress
for convenience.
Test plan
Test added in fireEvent.test.js
Thoughts
One could discuss that this should be another method called tap
or something else that map closer to user intent than to event handler name. Looking forward to hear your feedback.
Removed the throwing behaviour from invokeEvent here: #691 That PR should be merged before this one :)
Mind rebasing? :)
@thymikee done :)
Will this ever be merged? I need to be able to work with onFocus and I can't test it atm.
@rarenatoe we'll take care of it, but have no timeline. In the meantime you can invoke fireEvent(element, 'onFocus')
manually
Long term, shouldn't we try to to either create native-user-event
package, or at least export something specific for that in this library? I'm not sure that having a different behaviour between the web and native library when doing a simple fireEvent
is the best.
Closing in favour of #1119 which would be more organised approach that is also similar to RTL.