I am developing an android app that requires to read nfc tags, so I am using the react-native-nfc-manager
. However, I have come across two issues that I could not figure out at all.
- What does the
nfcManager.start()
function actually do? I realized that the app was working even if I remove it from the top of the method. If I try to check what the promise returns, it returnsundefined
- I want to test the page, so I try to mock
nfcManager
. However, I always get this issueTypeError: _reactNativeNfcManager.default.start is not a function
orTypeError: _reactNativeNfcManager.default.isSupported is not a function
etc with all the functions of the interface.
What I try to do and get the above mentioned errors is
const mockNfcManager = jest.fn();
jest.mock("react-native-nfc-manager", ()=>({ NfcManagerModule: { start: mockNfcManager, }, }));
and then render the component and check if expect(mockedNavigate).toHaveBeenCalled()