title: Jest/Node Axios Testing Throwing Errors
body: <p>Having an issue with running Jest testing with my lambda/node code.  When I run the index.js the Axios get works fine.</p>
  <p>This is my index.js</p>
  <pre><code>const sslRootCAs = require('ssl-root-cas/latest')
  const util = require('util')
  
  exports.handler = async function (event) {  
      const axios = require('axios');
      //const user = process.env.user;
      //const pw = process.env.pw;    
      const user = '';
      const pw = '';
      process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
      return axios.get('https://url', {
          auth: {username: user, password: pw}, rejectUnauthorized: false
      })
          .then(res =&gt; {
              return {
                  statusCode: 200,
                  body: res.data
              };
          })
          .catch(err =&gt; {
              return {
                  statusCode: 500,
                  body: JSON.stringify(err)
              };
          });
  }
  </code></pre>
  <p>This is my index.test.js</p>
  <pre><code>const lambda = require(&quot;./index&quot;);
  const axios = require(&quot;axios&quot;);
  const mockAdapter = require(&quot;axios-mock-adapter&quot;);
  
  // afterEach(() =&gt; {
  //   mockAxios.reset();
  // });
  
      it(&quot;test get - this will pass&quot;, async () =&gt; {
        let mock = new mockAdapter(axios, {delayResponse: 1000});
        mock.onGet().reply({
          status: 200,
          data: {
            expand: 'schema,names',
            startAt: 0,
            maxResults: 50,
            total: 2
          }
        });
        process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
        var event = {Key: &quot;12345&quot;};
        const result = await lambda.handler(event);
        console.log(result);
        expect(result).toMatchObject({ status: 200, body: &quot;test&quot; });
        mock.reset();
      });
  </code></pre>
  <p>I've tried multiple things with the index.test.js.  I've even cut out all the mocking and was testing to see if the get would work.  It does not.  I get &quot;unable to verify the first certificate&quot; when I run npm test.</p>
  <p>The code does not throw that error when I do a node index.js.  I suspect jest has some type of built in handler for that error or perhaps Axios?</p>
  <p>Any ideas would be great.</p>
  <p>Thanks,
  Tim</p>