react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

Extends mock capabilities and doc how to enable Babel parsing

Open LucasGarcez opened this issue 1 year ago • 1 comments

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 avatar Oct 28 '23 15:10 LucasGarcez

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

LucasGarcez avatar Feb 02 '24 08:02 LucasGarcez