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

SafeAreaView with jest breaks

Open francois-pasquier opened this issue 3 years ago • 1 comments

I am getting this error message:

TypeError: _NativeSafeAreaContext.default.getConstants is not a function

      at Object.<anonymous> (node_modules/react-native-safe-area-context/lib/commonjs/InitialWindow.native.ts:4:61)
      at Object.<anonymous> (node_modules/react-native-safe-area-context/lib/commonjs/index.tsx:3:1)

Running version 4.2.2

francois-pasquier avatar Mar 24 '22 14:03 francois-pasquier

I had to add a mock for the functions

jest.mock("react-native-safe-area-context", () => ({
  getConstants: () => {/* constants to return here */}
  // additional mocks
  })
)

drice avatar May 16 '22 15:05 drice