<p dir="auto"><strong>Describe the bug</strong><br>
When upgrading from 0.19.0 to 0.19.1, our test suite breaks because <code class="notranslate">nock</code> receives the cors OPTIONS call, which it did not receive before and did not expect. This is a breaking change, and I wouldn't expect the OPTIONS call to be made during tests.</p>
<p dir="auto">Here's the error stack :</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Error: Error: Nock: No match for request {
        &quot;method&quot;: &quot;OPTIONS&quot;,
        &quot;url&quot;: &quot;http://some_url.org/&quot;,
        &quot;headers&quot;: {
          &quot;origin&quot;: &quot;http://localhost&quot;,
          &quot;access-control-request-method&quot;: &quot;PUT&quot;,
          &quot;user-agent&quot;: &quot;Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0&quot;,
          &quot;host&quot;: &quot;some_url.org&quot;,
          &quot;content-length&quot;: 0
        }
      }
          at Object.dispatchError (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
          at EventEmitter.&lt;anonymous&gt; (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
          at EventEmitter.emit (events.js:215:7)
          at Request.&lt;anonymous&gt; (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:412:47)
          at Request.emit (events.js:210:5)
          at Request.onRequestError (/Users/somatt/www/hm/_hm/app/client/node_modules/request/request.js:881:8)
          at OverriddenClientRequest.emit (events.js:210:5)
          at /Users/somatt/www/hm/_hm/app/client/node_modules/nock/lib/intercepted_request_router.js:101:11
          at processTicksAndRejections (internal/process/task_queues.js:75:11)
          at runNextTicks (internal/process/task_queues.js:62:3) undefined"><pre class="notranslate">Error: Error: Nock: No match <span class="pl-k">for</span> request {
        <span class="pl-s"><span class="pl-pds">"</span>method<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>OPTIONS<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>url<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>http://some_url.org/<span class="pl-pds">"</span></span>,
        <span class="pl-s"><span class="pl-pds">"</span>headers<span class="pl-pds">"</span></span>: {
          <span class="pl-s"><span class="pl-pds">"</span>origin<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>http://localhost<span class="pl-pds">"</span></span>,
          <span class="pl-s"><span class="pl-pds">"</span>access-control-request-method<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>PUT<span class="pl-pds">"</span></span>,
          <span class="pl-s"><span class="pl-pds">"</span>user-agent<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/11.12.0<span class="pl-pds">"</span></span>,
          <span class="pl-s"><span class="pl-pds">"</span>host<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>some_url.org<span class="pl-pds">"</span></span>,
          <span class="pl-s"><span class="pl-pds">"</span>content-length<span class="pl-pds">"</span></span>: 0
        }
      }
          at Object.dispatchError (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
          at EventEmitter.<span class="pl-k">&lt;</span>anonymous<span class="pl-k">&gt;</span> (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
          at EventEmitter.emit (events.js:215:7)
          at Request.<span class="pl-k">&lt;</span>anonymous<span class="pl-k">&gt;</span> (/Users/somatt/www/hm/_hm/app/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:412:47)
          at Request.emit (events.js:210:5)
          at Request.onRequestError (/Users/somatt/www/hm/_hm/app/client/node_modules/request/request.js:881:8)
          at OverriddenClientRequest.emit (events.js:210:5)
          at /Users/somatt/www/hm/_hm/app/client/node_modules/nock/lib/intercepted_request_router.js:101:11
          at processTicksAndRejections (internal/process/task_queues.js:75:11)
          at runNextTicks (internal/process/task_queues.js:62:3) undefined</pre></div>
<p dir="auto"><strong>Expected behavior</strong><br>
Mostly, a patch version should not break anything and breaking changes should be documented.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version 0.19.1</li>
<li>OS: OSX 10.15.3 (19D76)</li>
<li>nock: 11.7.0</li>
</ul>
<p dir="auto"><strong>Describe the bug</strong><br>
After upgrading axios from 0.19.0 to 0.19.1 all tests that use nock got broken. They now produce the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Error: Cross origin http://localhost forbidden"><pre lang="text" class="notranslate"><code class="notranslate">Error: Cross origin http://localhost forbidden
</code></pre></div>
<p dir="auto"><strong>To Reproduce</strong><br>
Repo with minimal test case that reproduces the issue: <a href="https://github.com/EvgenyOrekhov/js-framework/tree/axios-bug">https://github.com/EvgenyOrekhov/js-framework/tree/axios-bug</a>.</p>
<p dir="auto">Note that <a href="https://github.com/EvgenyOrekhov/js-framework/tree/150ebe811c9531b7699c030e7921514e469fe84e">previous commit</a> (which has axios 0.19.0) works fine, the test passes.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import axios from &quot;axios&quot;;
import nock from &quot;nock&quot;;

it(&quot;makes HTTP requests&quot;, async done =&gt; {
  const scope = nock(&quot;https://example.com/foo/&quot;)
    .get(&quot;/bar&quot;)
    .reply(200, { foo: &quot;bar&quot; });

  await axios.get(&quot;https://example.com/foo/bar&quot;);

  scope.done();
  done();
});"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">axios</span> <span class="pl-k">from</span> <span class="pl-s">"axios"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s1">nock</span> <span class="pl-k">from</span> <span class="pl-s">"nock"</span><span class="pl-kos">;</span>

<span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">"makes HTTP requests"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-s1">done</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">scope</span> <span class="pl-c1">=</span> <span class="pl-en">nock</span><span class="pl-kos">(</span><span class="pl-s">"https://example.com/foo/"</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">"/bar"</span><span class="pl-kos">)</span>
    <span class="pl-kos">.</span><span class="pl-en">reply</span><span class="pl-kos">(</span><span class="pl-c1">200</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">foo</span>: <span class="pl-s">"bar"</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">await</span> <span class="pl-s1">axios</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">"https://example.com/foo/bar"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-s1">scope</span><span class="pl-kos">.</span><span class="pl-en">done</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-en">done</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior</strong><br>
The test should pass.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version: 0.19.1</li>
<li>OS: Ubuntu 19.10</li>
<li>Browser: n/a</li>
<li>Browser Version: n/a</li>
<li>Additional Library Versions: nock 11.7.2</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
Jest error with stack trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" FAIL  src/http.test.js
  ✕ makes HTTP requests (34ms)

  ● makes HTTP requests

    Network Error

      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:83:14)
      at XMLHttpRequest.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:33:32)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at XMLHttpRequestEventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:132:7)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:62:3)
      at Object.validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
      at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
      at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
      at Request.onRequestResponse (node_modules/request/request.js:1066:10)
      at respond (node_modules/nock/lib/playback_interceptor.js:299:11)
      at respondUsingInterceptor (node_modules/nock/lib/playback_interceptor.js:341:7)
      at node_modules/nock/lib/playback_interceptor.js:281:7

  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Cross origin http://localhost forbidden
        at dispatchError (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
        at Object.validCORSHeaders (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
        at receiveResponse (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
        at Request.&lt;anonymous&gt; (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
        at Request.emit (events.js:321:20)
        at Request.onRequestResponse (/home/user/my-app/node_modules/request/request.js:1066:10)
        at OverriddenClientRequest.emit (events.js:321:20)
        at respond (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:299:11)
        at respondUsingInterceptor (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:341:7)
        at /home/user/my-app/node_modules/nock/lib/playback_interceptor.js:281:7 undefined"><pre lang="text" class="notranslate"><code class="notranslate"> FAIL  src/http.test.js
  ✕ makes HTTP requests (34ms)

  ● makes HTTP requests

    Network Error

      at createError (node_modules/axios/lib/core/createError.js:16:15)
      at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:83:14)
      at XMLHttpRequest.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:33:32)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at XMLHttpRequestEventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:132:7)
      at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:62:3)
      at Object.validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
      at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
      at Request.&lt;anonymous&gt; (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
      at Request.onRequestResponse (node_modules/request/request.js:1066:10)
      at respond (node_modules/nock/lib/playback_interceptor.js:299:11)
      at respondUsingInterceptor (node_modules/nock/lib/playback_interceptor.js:341:7)
      at node_modules/nock/lib/playback_interceptor.js:281:7

  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Cross origin http://localhost forbidden
        at dispatchError (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
        at Object.validCORSHeaders (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
        at receiveResponse (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
        at Request.&lt;anonymous&gt; (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
        at Request.emit (events.js:321:20)
        at Request.onRequestResponse (/home/user/my-app/node_modules/request/request.js:1066:10)
        at OverriddenClientRequest.emit (events.js:321:20)
        at respond (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:299:11)
        at respondUsingInterceptor (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:341:7)
        at /home/user/my-app/node_modules/nock/lib/playback_interceptor.js:281:7 undefined
</code></pre></div>