Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Argument of type '"openURL"' is not assignable to parameter of type 'never' using Jest

$
0
0

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.


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>