title: How to use env variable in app.js in node.js when debugging test?
body: <p>When I debug on visual studio app.js is run before test codes and env config files</p>
  <p>How to set env on app.js?</p>
  <p>If I deploy or test on terminal I can use envs on app.js and check env from log But not on debug.</p>
  <p>a.test.js</p>
  <pre><code>const { describe, it } = require('mocha');
  const request = require('supertest');
  const { expect } = require('chai');
  const { setConfig } = require('../../../setConfig');
  const { app } = require('../../../../app');
  
  setConfig();
  
  describe('transactionController', () =&gt; {
    it('test', async () =&gt; {
      await request(app)
        .post(`/`)
        .set('Accept', 'application/json')
        .type('application/json')
        .send()
        .expect(200);
    });
  
  </code></pre>
  <p>setConfig.js</p>
  <pre><code>const { config } = require('../config/config');
  
  module.exports.setConfig = () =&gt; {
    console.log(`setConfig : ${JSON.stringify(config.debug)}`);
    const { debug } = config;
    const { NODE_ENV, CACHE_HOST, CACHE_PORT } = debug;
  
    process.env.NODE_ENV = NODE_ENV;
    process.env.CACHE_HOST = CACHE_HOST;
    process.env.CACHE_PORT = CACHE_PORT;
  };
  
  </code></pre>
  <p>config.js</p>
  <pre><code>module.exports.config = {
    debug: {
      NODE_ENV: 'debug',
      CACHE_HOST: '127.0.0.1',
      CACHE_PORT: '6379'
    },
  };
  
  </code></pre>
  <p>app.js</p>
  <pre class="lang-js prettyprint-override"><code>const serverless = require('serverless-http');
  const express = require('express');
  
  const app = express();
  
  app.set('port', 3000);
  
  console.log(`app : env : ${process.env.NODE_ENV}`);
  if (process.env.NODE_ENV === 'prod' || process.env.NODE_ENV === 'dev') {
    app.listen(app.get('port'), () =&gt; {
      console.log(`Server running on ${app.get('port')} port`);
    });
    module.exports.app = serverless(app);
  } else {
    module.exports.app = app;
  }
  
  </code></pre>