Skip to content

Instantly share code, notes, and snippets.

@jrapala
Created July 16, 2020 20:55
Show Gist options
  • Save jrapala/343e7a83fb1738dc15163ea50535692f to your computer and use it in GitHub Desktop.
Save jrapala/343e7a83fb1738dc15163ea50535692f to your computer and use it in GitHub Desktop.
Mocking RN Linking
@FanchenBao
Copy link

Good method, but I have to also mock event listener functions to make it work.

jest.mock('react-native/Libraries/Linking/Linking', () => ({
  openURL: jest.fn().mockResolvedValue(null),
  addEventListener: jest.fn(),
  removeEventListener: jest.fn(),
}));

@B0Y3R
Copy link

B0Y3R commented May 16, 2023

needed an example of mocking openURL in a pinch and this did the trick. Thank you!

@anabeatrizzz
Copy link

@Coffeegerm yes, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment