title: How to simulate proxy during unit testing?
body: <p>I have a Node.js library that makes <code>https.request</code> (<a href="https://nodejs.org/api/https.html" rel="nofollow noreferrer">https://nodejs.org/api/https.html</a>) calls to external sources.</p>
  
  <p>In some cases, the user of the library may be behind a proxy. Due to configuration (or misconfiguration?) of the proxy, users behind the proxy may experience issues with SSL certificates. In this case, in order to make https requests in Node, you need to set the <code>https.request</code> option: <code>rejectUnauthorized</code> to be <code>false</code>. (on a related note, these proxies typically require <code>npm --strict-ssl=false</code> as well)</p>
  
  <p>How can I setup a test that simulates being behind a proxy that rejects signed certificates so that I can ensure that my library will work properly for those behind proxies such as these?</p>
  
  <p>I'm using <code>mocha</code> and/or <code>chai</code> as the testing library and <code>nock</code> to simulate external sources that are being called.</p>