title: Jest test not reading environment variables with dotenv
body: <p>I'm running a test on a function that calls for environment variables, I'm getting undefined.
  Solutions I tried and didn't work:</p>
  
  <p>1/ add <code>require('dotenv').config({path:'../.env'})</code> in my test file</p>
  
  <p>2/ pass globals in package.json</p>
  
  <pre><code>"jest": {
      "globals": {
        "USER_ENDPOINT":"xxx",
        "USER_KEY":"xxx"
    }
  }
  </code></pre>
  
  <p>3/ pass my variables in test command in package.json</p>
  
  <pre><code>"test": "USER_ENDPOINT:xxx USER_KEY:xxx jest --watchAll --detectOpenHandles"
  </code></pre>
  
  <p>4/ added an Object.assign in a beforeEach() in my test file</p>
  
  <pre><code>beforeEach(() =&gt; {
          process.env = Object.assign(process.env, {USER_ENDPOINT:"xxx", USER_KEY:"xxx" });
  });
  </code></pre>
  
  <p>and got the error "Jest encountered an unexpected token"</p>
  
  <p>5/ I created a jest.config.js file on the root</p>
  
  <pre><code>require('dotenv').config({path:'./.env'});
  module.exports = {
      globals: {
          USER_ENDPOINT:"xxx", 
          USER_KEY:"xxx"
      }
  };
  </code></pre>
  
  <p>Most of these solution were suggested here:
  <a href="https://github.com/vuejs/vue-test-utils/issues/193" rel="nofollow noreferrer">https://github.com/vuejs/vue-test-utils/issues/193</a>
  but none of it worked</p>