Today I Learned

2 posts by wojciechbożek

Very fast way to patch ReactNative Native libraries

For example, you can change the native code of react-native-firebase

install patch-package from here

yarn add --dev patch-package

make a change inside the native code

eg. code node_modules/react-native-firebase/ios/RNFirebase/notifications/RNFirebaseNotifications.m

make patch

patch-package react-native-firebase

add post-install script

eg. "postinstall": "patch-package && ./scripts/postinstall.sh",

and enjoy your fix :D

probably CircleCI require more love from you, but you can check the package documentation

Jest.js haveBeenCalledWith anything()

Sometimes we want to check if the callback has been called with some arguments, but providing all of them can be hard (some nested structure with other callbacks, etc.)

We can check however some of the calling arguments and replace rest with expect.anything()

  it('should trigger confirmation when clicking on report lost button', () => {
    const { container, getByTestId } = render(<ReportScreen />);
    Alert.alert = jest.fn();
    const reportLostButton = getByTestId('reportLostButton');
    act(() => {
      fireEvent.press(reportLostButton);
    })
    expect(Alert.alert).toHaveBeenCalledWith(
      'Report as lost', 
      expect.anything(), 
      expect.anything(), 
      expect.anything()
    );
  });