title: use jest mock functions to test code that calls another server
body: <p>Roughly, my JavaScript function that I want to unit-test looks like this:</p>
  
  <pre><code>const request = require('request-promise-native');
  async function callServer() {
      // Prepare parameters
      // Call `request` with parameters
      // Parse response JSON and return
  }
  </code></pre>
  
  <p>Is there any way to unit-test this function without making an actual call to the real server? Can I use a jest mock function to somehow override <code>request()</code>? To do that, will I need to modify every function to take the <code>request</code> function as a parameter or there is another way?</p>