Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Jest mock export for the Clickable component within the gesture button mocks, intended to simplify testing usage of Clickable in environments using the library’s mocks.
Changes:
- Export
Clickablefromsrc/mocks/GestureButtons.tsxas an alias ofRawButton.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const RectButton = RawButton; | ||
| export const BorderlessButton = TouchableNativeFeedback; | ||
| export const Clickable = RawButton; |
There was a problem hiding this comment.
Clickable is a v3 export (src/v3/components/index.ts -> src/v3/components/Clickable/Clickable), but this mock file is used to mock ./src/components/GestureButtons (legacy) in jestSetup.js. Exporting Clickable here likely won’t affect import { Clickable } from 'react-native-gesture-handler' in tests, so the PR may not actually provide a Jest mock for the public Clickable API. Consider adding a dedicated v3 Clickable mock and wiring it up in jestSetup.js (e.g., mock ./src/v3/components/Clickable/Clickable or ./src/v3/components).
| export const BaseButton = RawButton; | ||
| export const RectButton = RawButton; | ||
| export const BorderlessButton = TouchableNativeFeedback; | ||
| export const Clickable = RawButton; |
There was a problem hiding this comment.
Clickable’s onPress callback in the real implementation receives a pointerInside: boolean (same as BaseButtonProps), but this mock delegates directly to TouchableNativeFeedback, which calls onPress with a press event object. This API mismatch can cause consumer tests to pass in Jest but break in production (or vice versa) when callbacks rely on the boolean argument. Consider wrapping the handler in the mock to call onPress?.(true) (and similarly map onLongPress, onPressIn, onPressOut if you want closer parity).
| export const Clickable = RawButton; | |
| export const Clickable = ({ | |
| onPress, | |
| onLongPress, | |
| onPressIn, | |
| onPressOut, | |
| ...rest | |
| }: any) => ( | |
| <RawButton | |
| {...rest} | |
| onPress={() => onPress?.(true)} | |
| onLongPress={() => onLongPress?.(true)} | |
| onPressIn={() => onPressIn?.(true)} | |
| onPressOut={() => onPressOut?.(true)} | |
| /> | |
| ); |
Description
This PR adds mock for
ClickablecomponentTest plan