react-native-safe-area-context
react-native-safe-area-context copied to clipboard
Extends mock capabilities and doc how to enable Babel parsing
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"
@janicduplessis any chance to merge this one? It's useful for folks who need to mock it.