I am beginner in Jest and these are classes defined.APIService class is not exported; only openURL function is defined.
APIService.ts
export const openURL = async (openURL : string) => { await Linking.openURL(openURL );};
RegistrationPage.tsx
import{openURL} from '../APIService';
RegistrationPage.test.ts
test('should call function openURL with empty value', async () => {const url = '';const mockOpenURL = jest.fn();mockOpenURL .mockImplementation(() => Promise.resolve(''));const openURLSpy = jest.spyOn(openURL, 'openURL');const mockURL = await openURL(url);expect(mockOpenURL).toBeCalled();expect(mockURL).toEqual(url);expect(mockOpenURL).toHaveBeenCalledWith(url);openURLSpy.mockRestore();
});
After writing this function as per my understating may be it has loopholes not having properly mocked or spyedrunning it causing an error for Argument of type '"openURL"' is not assignable to parameter of type 'never' using Jest
suggestions to improve this testcase will be helpful.