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.

[v4] | [v2] Issue in resolving the test case for BottomSheetTextInput.

See original GitHub issue

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

  1. Implement the bottom sheets component and it contains bottomsheetinputtext.

Describe what you expected to happen:

  1. resolving the issue that I’m getting for bottom sheet test case.

Reproducible sample code

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

4reactions
developiuscommented, Jul 15, 2022

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,
}));
2reactions
Ekaanthcommented, Jul 15, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run a single unit test case through Test Explorer
In our unit test projects, we use NUnit 3.10 with the TestCase attribute. ... The only way to resolve the issue is to...
Read more >
Writing and running tests - Django documentation
When you run your tests, the default behavior of the test utility is to find all the test cases (that is, subclasses of...
Read more >
Keyboard Handling | React Native Bottom Sheet - GitHub Pages
To handle the keyboard appearance, I have simplified the approach by creating a pre-integrated TextInput called BottomSheetTextInput, which communicate ...
Read more >
What is Test Data? Test Data Preparation Techniques with ...
In this tutorial, I will provide tips on how to prepare test data so any important test case will not be missed by...
Read more >
upgrade test planning guide - Aras Community
Chapter 4 contains a reference to a set of sample test cases that you can use ... cases should not start until those...
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