-
-
Notifications
You must be signed in to change notification settings - Fork 908
Closed
Labels
Description
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?