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

Extends mock capabilities and doc how to enable Babel parsing #449

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LucasGarcez
Copy link

Summary

Extends mock capabilities

Use jest.fn on useSafeAreaInsets and useSafeAreaFrame to allow the use of Mock Functions method as shown below:

import {useSafeAreaInsets} from 'react-native-safe-area-context';

const mockedUseSafeAreaInsets = jest.mocked(useSafeAreaInsets);
mockedUseSafeAreaInsets.mockImplementationOnce()

Improve documentation: Enabling Babel Parsing for Modules

Add a few lines to describe how to parse the mock file using jest config transformIgnorePatterns

transformIgnorePatterns: [
  'node_modules/(?!((jest-)?react-native|@react-native(-community)?|react-native-safe-area-context)/)',
];

Test Plan

Tested linking my react-native-safe-are-context fork as the dependency on my project:
"react-native-safe-area-context": "git+https://github.com/LucasGarcez/react-native-safe-area-context.git#chore-improve-build-in-mock"

@LucasGarcez
Copy link
Author

@janicduplessis any chance to merge this one? It's useful for folks who need to mock it.

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

Successfully merging this pull request may close these issues.

None yet

1 participant