title: How to mock npm package methods in react native jest?
body: <p>I'm developing react native app, in that i'm using two packages for exiting and restarting my app.
  Whenever I tries to mock these functions in getting error. I'm not able to cover test cases for exit and restart methods
  Could anybody know how do we mock these functions</p>
  <pre><code>import RNRestart from 'react-native-restart';
  import RNExitApp from 'react-native-exit-app';
  
  if (configNotThere) {
     RNExitApp.exitApp();
  }
  
  if(configFound){
   RNRestart.Restart();
  }
  </code></pre>
  <p>Jest code</p>
  <pre><code>jest.mock('react-native-exit-app', () =&gt; ({
    RNExitApp: {
      exitApp: () =&gt; jest.fn(),
    },
  }));
  
  expect(exitApp).toHaveBeenCalledTimes(1);
  // expect(RNExitApp.exitApp()).toHaveBeenCalledTimes(1);
  // beforeEach(() =&gt; {
  //   const exitAppMockValue = jest.fn();
  //   exSpy.mockReturnValue(exitAppMockValue);
  // });
  // const dummyExit = jest.fn();
  // rnExitMock.mockReturnValue(dummyExit);
  
  // RNExitApp.exitApp().mockResolvedValueOnce();
  
  // const component = shallow(&lt;KfcAppError /&gt;);
  // component.find(TouchableOpacity).forEach((element) =&gt; {
  //   element.simulate('press');
  // });
  
  //  RNExitApp.exitApp().mockResolvedValueOnce(true);
  </code></pre>
  <p>tried with all the way BUT no luck for always some of the getting errors</p>
  <p>How to mock npm package methods in jest ?
  Please anybody help me on this</p>
  <p><a href="https://www.npmjs.com/package/react-native-exit-app" rel="nofollow noreferrer">react native exit app npm package</a>
  <a href="https://www.npmjs.com/package/react-native-restart" rel="nofollow noreferrer">react native restart app npm package</a></p>