question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you test BottomSheetModal?

See original GitHub issue

Ask your Question

I am using react-test-renderer but I am unable to retrieve children of BottomSheetModal possibly because the modal is mounted to a portal above the component?

      <BottomSheetModal ref={bottomSheet} index={0} snapPoints={['90%']} data-testid='bottom-sheet'>
        <View style={{ marginBottom: 5, flexDirection: 'row', justifyContent: 'flex-end' }}>
          <Button
            appearance='ghost'
            onPress={() => bottomSheet.current.dismiss()}
            data-testid='close-bottom-sheet-button'
          >
            CLOSE
          </Button>
        </View>

        <BottomSheetScrollView contentContainerStyle={{ padding: 15 }}>
          <OrderLog order={order} data-testid='order-log' />
        </BottomSheetScrollView>
      </BottomSheetModal>

The data-testid inside the modal cannot be found. In my test:

    //BottomSheet.test.tsx
    const instance = create(
      <Provider store={store}>
        <ApplicationProvider {...eva} theme={{ ...eva.light, ...mtTheme }}>
          <BottomSheetModalProvider>
            <OrderFooter order={order('placed', 'delivery')} restaurantLocation={restaurantLocation} />
          </BottomSheetModalProvider>
        </ApplicationProvider>
      </Provider>
    );

    const bottomSheet = instance.root.findByProps({ 'data-testid': 'bottom-sheet' }); // this is found
    const closeBottomSheetButton = bottomSheet.findByProps({ 'data-testid': 'close-bottom-sheet-button' });
    const orderLog = bottomSheet.findByProps({ 'data-testid': 'order-log' })

Also tried instance.root.findByProps({ 'data-testid': 'close-bottom-sheet-button' }). And the error

No instances found with props: {"data-testid":"close-bottom-sheet-button"}

So how do we test this in our component?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
bertrand-caroncommented, Sep 30, 2021

Anyone has had any luck with this? I am using Detox, and I am struggling to programmatically tap components inside the BottomSheet 😦

2reactions
shamilovtimcommented, Jun 1, 2022

We are having issues with Detox and unfortunately the solutions proposed don’t solve the problem for e2e testing. Is anyone aware of how to make Detox work with this library?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Bottom Sheet Modal - GitHub Pages
A performant interactive bottom sheet modal with fully configurable options. ... Apple Maps sheet modals ❤️, check out the Apple Map sheet modals...
Read more >
Flutter: Custom Bottom Sheet Modal | by Alex Melnyk | LITSLINK
It's a test newsletter! Take a look. Get this newsletter. By signing up, you will create a Medium account if you don't already...
Read more >
How can I open BottomSheetModal (@gorhom/bottom-sheet ...
I found out to do this, incase anyone comes across this question, I'll post it here! So what you have to do is...
Read more >
showModalBottomSheet function - material library - Dart API
To create a local project with this code sample, run: flutter create --sample=material.showModalBottomSheet.1 mysample. Dart Solution Tests. Install SDK
Read more >
Flutter - Modal Bottom Sheet - GeeksforGeeks
... GATE CS 2023 Test Series · Explore More Self-Paced Courses ... GATE 2023 Test Series · GATE Computer Science Notes ... CS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found