config-plugin-react-native-intercom
config-plugin-react-native-intercom copied to clipboard
TypeError when using Jest along with this package
When I run my jest test scripts I get this error: TypeError: Cannot read property 'UNREAD_COUNT_CHANGE_NOTIFICATION' of undefined
In reference to #16, the only way to fix it is to install the v1.2.1 of this package. But, according to the README, if I am using Expo SDK 45, I have to use v1.3 or above of this package.
Seems to be impossible for anyone in SDK 45 and someone who is using jest to be able to use this config plugin package.
Is there a fix as referenced by #16?
Full error:
TypeError: Cannot read property 'UNREAD_COUNT_CHANGE_NOTIFICATION' of undefined
2 |
3 | import { isEmpty } from "@firebase/util";
> 4 | import Intercom from "@intercom/intercom-react-native";
| ^
5 | import * as AppleAuthentication from "expo-apple-authentication";
6 | import * as Crypto from "expo-crypto";
7 | import {
at Object.<anonymous> (node_modules/@intercom/intercom-react-native/lib/commonjs/index.tsx:36:26)
at Object.<anonymous> (src/provider/AuthProvider/AuthProvider.tsx:4:1)
Here is what I did
test/mocks/intercom/index.ts
import { IntercomType } from '@intercom/intercom-react-native'
export const mockIntercom: Partial<IntercomType> = {
displayMessageComposer: jest.fn(),
registerIdentifiedUser: jest.fn(),
logout: jest.fn(),
}
then in my jest setup file
import { mockIntercom } from '~/test/mocks/intercom'
jest.mock('@intercom/intercom-react-native', () => mockIntercom)