Skip to content
Merged
24 changes: 24 additions & 0 deletions packages/react-native-gesture-handler/jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ jest.mock('./lib/commonjs/components/GestureComponents', () =>
jest.mock('./lib/commonjs/v3/detectors/HostGestureDetector', () =>
require('./lib/commonjs/mocks/hostDetector')
);
jest.mock('./lib/commonjs/v3/components/Clickable/Clickable', () =>
require('./lib/commonjs/mocks/v3GestureComponents')
);
jest.mock('./lib/commonjs/v3/components/GestureButtons', () =>
require('./lib/commonjs/mocks/v3GestureComponents')
);
jest.mock('./lib/commonjs/v3/components/Pressable', () =>
require('./lib/commonjs/mocks/Pressable')
);
jest.mock('./lib/commonjs/v3/components/GestureComponents', () =>
require('./lib/commonjs/mocks/v3GestureComponents')
);

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jestSetup.js mocks v3 components only for ./lib/commonjs/... and ./lib/module/..., but not for the ./src/v3/components/... entrypoints. Since the package publishes src/ and also has a react-native entry (package.json:22) that can be used by React Native/Jest resolvers, consumers may still hit the unmocked ./src/v3/components/* implementations in tests. Add equivalent jest.mock('./src/v3/components/...') entries for Clickable, GestureButtons, Pressable, and GestureComponents to keep source and built entrypoints consistent.

Copilot uses AI. Check for mistakes.

jest.mock('./lib/module/RNGestureHandlerModule', () =>
require('./lib/module/mocks/module')
Expand All @@ -43,6 +55,18 @@ jest.mock('./lib/module/components/GestureComponents', () =>
jest.mock('./lib/module/v3/detectors/HostGestureDetector', () =>
require('./lib/module/mocks/hostDetector')
);
Comment thread
m-bert marked this conversation as resolved.
jest.mock('./lib/module/v3/components/Clickable/Clickable', () =>
require('./lib/module/mocks/v3GestureComponents')
);
jest.mock('./lib/module/v3/components/GestureButtons', () =>
require('./lib/module/mocks/v3GestureComponents')
);
jest.mock('./lib/module/v3/components/Pressable', () =>
require('./lib/module/mocks/Pressable')
);
jest.mock('./lib/module/v3/components/GestureComponents', () =>
require('./lib/module/mocks/v3GestureComponents')
);

jest.mock('react-native-worklets', () =>
require('react-native-worklets/src/mock')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from 'react';
import { TouchableNativeFeedback, View } from 'react-native';
export const RawButton = ({ enabled, children, ...rest }: any) => (

const RawButton = ({ enabled, children, ...rest }: any) => (
<TouchableNativeFeedback disabled={enabled === false} {...rest}>
{children ?? <View />}
</TouchableNativeFeedback>
);
export const BaseButton = RawButton;
export const RectButton = RawButton;
export const BorderlessButton = TouchableNativeFeedback;

export const LegacyRawButton = RawButton;
export const LegacyBaseButton = RawButton;
export const LegacyRectButton = RawButton;
export const LegacyBorderlessButton = RawButton;
export const LegacyPureNativeButton = RawButton;
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import {
TouchableHighlight,
TouchableNativeFeedback,
TouchableOpacity,
TouchableWithoutFeedback,
ScrollView,
FlatList,
Switch,
TextInput,
DrawerLayoutAndroid,
RefreshControl,
} from 'react-native';

export default {
TouchableHighlight,
TouchableNativeFeedback,
TouchableOpacity,
TouchableWithoutFeedback,
Comment thread
j-piasecki marked this conversation as resolved.
ScrollView,
FlatList,
Switch,
TextInput,
DrawerLayoutAndroid,
} as const;
export const LegacyScrollView = ScrollView;
export const LegacyFlatList = FlatList;
export const LegacySwitch = Switch;
export const LegacyTextInput = TextInput;
export const LegacyDrawerLayoutAndroid = DrawerLayoutAndroid;
export const LegacyRefreshControl = RefreshControl;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import {
ScrollView,
FlatList,
Switch,
TextInput,
RefreshControl,
TouchableNativeFeedback,
View,
} from 'react-native';

export { ScrollView, FlatList, Switch, TextInput, RefreshControl };

const RawButton = ({ enabled, children, ...rest }: any) => (
<TouchableNativeFeedback disabled={enabled === false} {...rest}>
{children ?? <View />}
</TouchableNativeFeedback>
);

export { RawButton };
export const BaseButton = RawButton;
export const RectButton = RawButton;
export const BorderlessButton = RawButton;
Comment thread
m-bert marked this conversation as resolved.
Outdated
export const Clickable = RawButton;
Loading