react-native-bottom-sheet
react-native-bottom-sheet copied to clipboard
[v4] | [v2] Issue in resolving the test case for BottomSheetTextInput.
While trying to provide the test cases for the application I have been having difficulty mocking the call for BottomSheetTextInput
. I'm using the initial mock that was provided in the earlier version (Thanks a lot for that):
I try to mock for the BottomSheetTextInput
something like this:
jest.mock('@gorhom/bottom-sheet', () => {
const MockBottomSheet = require('@gorhom/bottom-sheet/mock');
const originalModule = jest.requireActual('@gorhom/bottom-sheet');
return {
__esModule: true,
BottomSheetTextInput: originalModule.BottomSheetTextInput,
...MockBottomSheet,
};
});
still facing an issue of thrown: "'useBottomSheetInternal' cannot be used out of the BottomSheet!"
Which I'm unable to resolve. It would be amazing if you can look into this issue by providing a mock implementation for this problem.
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | ^4.3.1 |
react-native | 0.67.3 |
react-native | 17.0.2 |
react-native-gesture-handler | ^2.4.2 |
Steps To Reproduce
- Implement the bottom sheets component and it contains bottomsheetinputtext.
Describe what you expected to happen:
- resolving the issue that I'm getting for bottom sheet test case.
Reproducible sample code
I am also facing same issue
Any update on this issue?
Following @pedrorestrepo's comment here, this is what I did to get the mock working:
import mockBottomSheet from '@gorhom/bottom-sheet/mock';
jest.mock('@gorhom/bottom-sheet', () => ({
...mockBottomSheet,
__esModule: true,
}));
@developius I do mock the same way right now, but I'm getting an error when I have the sheets that use BottomSheetTextInput.
I t would be nice that BottomSheetTextInput
is included in the mockup.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
Hi guys, Hi @Ekaanth, Ekaanth I'm still facing the same issue? any helps? Thank you guys so much. Really appreciated!
Hi @vdr-mm-quan, if you're still looking for a solution, you can use this mock instead of the basic one:
jest.mock('@gorhom/bottom-sheet', () => {
const { ScrollView, TextInput } = jest.requireActual('react-native')
return ({
...require('@gorhom/bottom-sheet/mock'),
__esModule: true,
BottomSheetScrollView: ScrollView,
BottomSheetTextInput: TextInput
})
})