How do you test BottomSheetModal?
See original GitHub issueAsk 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:
- Created 3 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Anyone has had any luck with this? I am using Detox, and I am struggling to programmatically tap components inside the BottomSheet 😦
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?