-
-
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 9 commits
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ import { | |
} from './utils'; | ||
import { PressabilityDebugView } from '../../handlers/PressabilityDebugView'; | ||
import { GestureTouchEvent } from '../../handlers/gestureHandlerCommon'; | ||
import { INT32_MAX } from '../../utils'; | ||
import { INT32_MAX, isTestEnv } from '../../utils'; | ||
|
||
const DEFAULT_LONG_PRESS_DURATION = 500; | ||
|
||
|
@@ -390,7 +390,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={isTestEnv() ? onPress : undefined} | ||
testOnly_onPressIn={isTestEnv() ? onPressIn : undefined} | ||
testOnly_onPressOut={isTestEnv() ? onPressOut : 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. We could do something similar to Reanimated, i.e. call this only once and store result in constant const IS_TEST_ENV = isTestEnv() 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 though about that, but 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. Well, it calls 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. |
||
{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: