I'm testing my react native app with Jest and the following line gives me an issue.
AccessibilityInfo.announceForAccessibility(errorMessages[0]);
Error:
TypeError: Cannot read property 'announceForAccessibility' of undefined
I've tried to mock it using
jest.mock('react-native', () => ({
...jest.requireActual('react-native'),
AccessibilityInfo: {
fetch: jest.fn(),
addEventListener: jest.fn(),
setAccessibilityFocus: jest.fn(),
announceForAccessibility: jest.fn(),
removeEventListener: jest.fn(),
},
}));
but that brought a whole lot of other issues.
How could I mock this specific export on the react native package?