Skip to content
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

ReanimatedSwipeable > Jest > getByGestureTestId fails to find component. #3032

Closed
markaustinws opened this issue Aug 6, 2024 · 3 comments · Fixed by #3039
Closed

ReanimatedSwipeable > Jest > getByGestureTestId fails to find component. #3032

markaustinws opened this issue Aug 6, 2024 · 3 comments · Fixed by #3039
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@markaustinws
Copy link

Description

Trying to retrieve a swipeable component using getByGestureTestId, but it's failing. Seems that the Test ID does not get rendered

Steps to reproduce

test("GetByGestureTestId", async () => {
// const swipeable = screen.getByTestId("mySwipe");

render(

  <Swipeable testID="abcd">
    <Text>Hello</Text>
  </Swipeable>

);

screen.debug();

const swipeable = getByGestureTestId("abcd");

});

Handler with id: 'abcd' cannot be found

Screen debug:

<View
  collapsable={false}
  jestAnimatedStyle={
    {
      "value": {},
    }
  }
  onLayout={[Function onRowLayout]}
  style={
    {
      "overflow": "hidden",
    }
  }
>
  <View
    collapsable={false}
    jestAnimatedStyle={
      {
        "value": {
          "pointerEvents": "auto",
          "transform": [
            {
              "translateX": 0,
            },
          ],
        },
      }
    }
    style={
      {
        "pointerEvents": "auto",
        "transform": [
          {
            "translateX": 0,
          },
        ],
      }
    }
  >
    <Text>
      Hello
    </Text>
  </View>
</View>

Snack or a link to a repository

https://snack.expo.dev/@mausti/tenacious-green-tortillas

Gesture Handler version

2.18.1

React Native version

0.74.3

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

Expo managed workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

None

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided labels Aug 6, 2024
@Glazzes
Copy link

Glazzes commented Aug 6, 2024

getGestureByIdmethod will retrieve the gesture object, it's not meant to bring components

// Pan gesture in some component
const pan = Gesture.Pan().withTestID("pan")

test("some tests", () => {
  render(<SomeComponent />) // Some component with the gesture shown above
 const pan = getGestureById("pan");
})

With code like this you will get the pan gesture.

@markaustinws
Copy link
Author

I'm trying to get the gesture from the Swipeable component. Is this not possible?:

render(<Swipeable testID="swipeable" />);
getByGestureTestId("swipeable");

Erroring with   Handler with id: 'swipeable' cannot be found

@latekvo
Copy link
Contributor

latekvo commented Aug 9, 2024

Hi @markaustinws,

please let me know if this PR fixes your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
3 participants