satya164/react-native-tab-view

Add testID to TabView

whalemare opened this issue · 3 comments

Description

It's allow to test screens that uses TabView without extra wrapping with View container, for set testID

Alternatives

No response

Inspirations & examples

Patch that add it is:

diff --git a/node_modules/react-native-tab-view/src/TabView.tsx b/node_modules/react-native-tab-view/src/TabView.tsx
index 72d1271..821423f 100644
--- a/node_modules/react-native-tab-view/src/TabView.tsx
+++ b/node_modules/react-native-tab-view/src/TabView.tsx
@@ -31,6 +31,7 @@ export type Props<T extends Route> = PagerProps & {
   lazyPreloadDistance?: number;
   sceneContainerStyle?: StyleProp<ViewStyle>;
   style?: StyleProp<ViewStyle>;
+  testID?: string
 };
 
 export default function TabView<T extends Route>({
@@ -49,6 +50,7 @@ export default function TabView<T extends Route>({
   style,
   swipeEnabled = true,
   tabBarPosition = 'top',
+  testID,
 }: Props<T>) {
   const [layout, setLayout] = React.useState({
     width: 0,
@@ -75,7 +77,7 @@ export default function TabView<T extends Route>({
   };
 
   return (
-    <View onLayout={handleLayout} style={[styles.pager, style]}>
+    <View testID={testID} onLayout={handleLayout} style={[styles.pager, style]}>
       <Pager
         layout={layout}
         navigationState={navigationState}

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

Couldn't find version numbers for the following packages in the issue:

  • react-native
  • react-native-tab-view
  • react-native-pager-view

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.