title: How do you mock/test requestjs requestcallback with Jest
body: <p>I am making a get request to an API using requestjs and then in the requestCallBack mapping the body to a custom json object. I am trying to test this code using Jest but no matter how I mock it, it doesn't seem to work</p>
  
  <p>I have tried <code>request.get.mockImplementation()</code> and that seems to only mock the get and doesn't let me test the code in the callback</p>
  
  <pre><code>    await request.get('endpoint', requestOptions, (err, res, body) =&gt; { transformBodyContent(body) })
  </code></pre>
  
  <pre><code>    jest.mock('request')
      jest.mock('request-promise-native')
  
      import request from 'request-promise-native'
  
      test('test requestCallback code', async () =&gt; {
          // not sure how to test that bodyTransformer is called and is working
      }
  </code></pre>