<p dir="auto"><strong>Describe the bug</strong><br>
A clear and concise description of what the bug is. <strong>If your problem is not a bug, please file under Support or Usage Question</strong></p>
<p dir="auto"><strong>To Reproduce</strong><br>
Code snippet to reproduce, ideally that will work by pasting into something like <a href="https://npm.runkit.com/axios" rel="nofollow">https://npm.runkit.com/axios</a>, a hosted solution, or a repository that illustrates the issue. <strong>If your problem is not reproducible, please file under Support or Usage Question</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// Example code here"><pre class="notranslate"><span class="pl-c">// Example code here</span></pre></div>
<p dir="auto"><strong>Expected behavior</strong><br>
A clear and concise description of what you expected to happen.</p>
<p dir="auto"><strong>Environment:</strong></p>
<ul dir="auto">
<li>Axios Version [e.g. 0.18.0]</li>
<li>OS: [e.g. iOS 12.1.0, OSX 10.13.4]</li>
<li>Browser [e.g. Chrome, Safari]</li>
<li>Browser Version [e.g. 22]</li>
<li>Additional Library Versions [e.g. React 16.7, React Native 0.58.0]</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong><br>
Add any other context about the problem here. If applicable, add screenshots to help explain.</p>
<p dir="auto">We're using <code class="notranslate">axios</code> both on the back-end, to communicate with some third-party APIs, and on the front-end, to communicate with our back-end. I recently ran into some problems trying to add some client-side tests for code that uses axios. Because axios detects its environment at require time, even using something like <code class="notranslate">jsdom</code>, one is constrained to setting up axios as either browser-oriented or node-oriented for the entire test suite. This matters in testing because relative URLs fail when running in node (and possibly other differences).</p>
<p dir="auto">I see several possible workarounds:</p>
<ul dir="auto">
<li>have two separate client and server test suites</li>
<li>always pass baseURL from window.location.href when using axios on the client</li>
<li>always force a client environment via <code class="notranslate">jsdom</code> for the whole test suite</li>
</ul>
<p dir="auto">None of these seem that great though (with the first one probably being the best and least likely to cause trouble, but requiring more duplicate setup). Any suggestions for how to approach this?</p>