Skip to content

How to mock RNS with Jest #838

Closed Answered by kacperkapusciak
getinnocuous asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @getinnocuous,
try this snippet:

jest.useFakeTimers();
jest.mock('react-native-screens', () => {
  const RealComponent = jest.requireActual('react-native-screens');
  RealComponent.enableScreens = function () {};
  RealComponent.screensEnabled = function () {
    return true;
  };
  return RealComponent;
});

If you want to know more about this see: #247 (comment) and this: jestjs/jest#6434 (comment)

If this snippet doesn't help please provide us with some code to reproduce your problem. Cheers!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@getinnocuous
Comment options

Answer selected by kacperkapusciak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants