Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test Jest and Testing Library: Can't mock sensors #436

Open
oleksii00ishchenko opened this issue Aug 5, 2022 · 0 comments
Open

Unit test Jest and Testing Library: Can't mock sensors #436

oleksii00ishchenko opened this issue Aug 5, 2022 · 0 comments

Comments

@oleksii00ishchenko
Copy link

I mocked library in jest.setup file like this
jest.mock('react-native-sensors', () => require('react-native-sensors/mock'));
This works fine through all tests except one case.

In my project i have hook that calculates pitch using orientation.
Screenshot 2022-08-05 at 11 57 56

The problem appears when i'm running simple test for this hook. In some reason its undefined
Screenshot 2022-08-05 at 12 23 34

Any ideas why this happens? Will be appreciative for any help.

  • React Native Version: 0.67.3
  • React Native Sensors: 7.3.5
  • Jest: 27.5.1
  • Testing library react hooks: 8.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant