-
-
Notifications
You must be signed in to change notification settings - Fork 988
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
Add testing-library
compatibility props
#3357
base: main
Are you sure you want to change the base?
Changes from 1 commit
122d977
e51fdcd
9828131
930dabc
f1ac3ce
c63a561
556f8f2
f13e7b0
4d942e8
7a31f5e
6184078
4ec26c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,6 +380,8 @@ export default function Pressable(props: PressableProps) { | |
? children({ pressed: pressedState }) | ||
: children; | ||
|
||
const inJestEnv = typeof jest !== 'undefined'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in e51fdcd There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future RNTL would like to support other test runners, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case why don't we change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree the |
||
|
||
return ( | ||
<GestureDetector gesture={gesture}> | ||
<NativeButton | ||
|
@@ -390,7 +392,10 @@ export default function Pressable(props: PressableProps) { | |
touchSoundDisabled={android_disableSound ?? undefined} | ||
rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)} | ||
rippleRadius={android_ripple?.radius ?? undefined} | ||
style={[pointerStyle, styleProp]}> | ||
style={[pointerStyle, styleProp]} | ||
testOnly_onPress={inJestEnv ? onPress : undefined} | ||
testOnly_onPressIn={inJestEnv ? onPressIn : undefined} | ||
testOnly_onPressOut={inJestEnv ? onPressOut : undefined}> | ||
{childrenProp} | ||
{__DEV__ ? ( | ||
<PressabilityDebugView color="red" hitSlop={normalizedHitSlop} /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of argument should be passed to
testOnly_onPress
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testOnly_onPress
will currently always be of type((event: PressableEvent) => void) | null
, but this may change if more of our components will implementtestOnly_onPress
.I've made it of type
Function
, becauseRawButtonProps
usage is not specific toPressable
.Link to type definitions: (link)
Extract from type definitions: