title: How to use the same Node Environment as Axios with Cypress
body: <p>I have a website where you submit a form that starts a job on the server. To start this job, you send a request, and in the response you get back the job id. My website then makes requests to get the status of this job until it is complete. </p>
  
  <p>With cypress, I want to wait until a job is complete to move onto the next step. To do this I need to know when the job is complete. I use axios to make the requests and I want to add an <a href="https://github.com/axios/axios#interceptors" rel="nofollow noreferrer">interceptor</a> to all the requests that axios makes so I can look for the one that creates the job to get its id, and then look for the requests that get it's status so I can know when it's finished. </p>
  
  <p>I've tried to do that but when I import the axios instance from my request file, I noticed that any console.logs that I have in my request file get printed twice. This implies that when cypress imports the variable, it's running the file again, which means that cypress doesn't have access to the axios instance that's actually making the requests, but instead a new instance only used by cypress.</p>
  
  <p>When I print process.env.NODE_ENV, it prints twice with two different values
  <a href="https://i.stack.imgur.com/TTmeH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TTmeH.png" alt="cypress environment difference"></a></p>
  
  <p>I know that I can print the env variable with <code>Cypress.env('NODE_ENV')</code> but clearly cypress isn't using the same variable scope/enviornment as my API file. I've also tried setting my cypress.json to </p>
  
  <pre><code>{
      "env" : {
          "NODE_ENV" : "development"
      }
  }
  </code></pre>
  
  <p>and running this at the top of my test file <code>process.env.NODE_ENV = Cypress.env('NODE_ENV')</code> but that didn't work. I also tried <code>export NODE_ENV = development</code> in the terminal where I call cypress but that didn't work. Also this is the script from my package.json that I use to call cypress <code>"cypress": "./node_modules/.bin/cypress open"</code>, and I'm using cypress 3.1.0 and node 9.5.0</p>
  
  <p>Is it even possible to have cypress interact with variables? Do I just have my cypress or node setup wrong?</p>