title: The db connection throws error in model unit test without explicit invoking
body: <p>I am doing unit test on nodejs 12.x jest 25 app. When the unit test is started with <code>npm test</code>, at the end it throws an error about a startup file <code>db.js</code> which establishes db connection. Here is the db.js file:</p>
  
  <pre><code>const Sql = require("sequelize");
  const db = new Sql('emps', 'postgres', `${process.env.DB_PASSWORD}`, {
      host: 'localhost',
      dialect: 'postgres',
      port:5432,
  } );
  
  db
      .authenticate()  //&lt;&lt;&lt;====this line causes the error 
      .then(() =&gt; {
          console.log('DB connection has been established successfully.');
  
      })
      .catch(err =&gt; {
          console.error('Unable to connect to the database:', err);
      });
  
  module.exports = db;
  </code></pre>
  
  <p>Here is the error at the end of jest unit test:</p>
  
  <pre><code>  console.error startup/db.js:32
      Unable to connect to the database: ConnectionError [SequelizeConnectionError]: password authentication failed for user "postgres"
          at C:\D\code\js\emps_bbone\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:182:24
          at Connection.connectingErrorHandler (C:\D\code\js\emps_bbone\node_modules\pg\lib\client.js:194:14)
          at Connection.emit (events.js:311:20)
          at Socket.&lt;anonymous&gt; (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:134:12)
          at Socket.emit (events.js:311:20)
          at addChunk (_stream_readable.js:294:12)
          at readableAddChunk (_stream_readable.js:275:11)
          at Socket.Readable.push (_stream_readable.js:209:10)
          at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
        name: 'SequelizeConnectionError',
        parent: error: password authentication failed for user "postgres"
            at Connection.Object.&lt;anonymous&gt;.Connection.parseE (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:614:13)
            at Connection.Object.&lt;anonymous&gt;.Connection.parseMessage (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:413:19)
            at Socket.&lt;anonymous&gt; (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:129:22)
            at Socket.emit (events.js:311:20)
            at addChunk (_stream_readable.js:294:12)
            at readableAddChunk (_stream_readable.js:275:11)
            at Socket.Readable.push (_stream_readable.js:209:10)
            at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
          name: 'error',
          length: 163,
          severity: 'FATAL',
          code: '28P01',
          detail: undefined,
          hint: undefined,
          position: undefined,
          internalPosition: undefined,
          internalQuery: undefined,
          where: undefined,
          schema: undefined,
          table: undefined,
          column: undefined,
          dataType: undefined,
          constraint: undefined,
          file: 'd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\libpq\\auth.c',
          line: '336',
          routine: 'auth_failed'
        },
        original: error: password authentication failed for user "postgres"
            at Connection.Object.&lt;anonymous&gt;.Connection.parseE (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:614:13)
            at Connection.Object.&lt;anonymous&gt;.Connection.parseMessage (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:413:19)
            at Socket.&lt;anonymous&gt; (C:\D\code\js\emps_bbone\node_modules\pg\lib\connection.js:129:22)
            at Socket.emit (events.js:311:20)
            at addChunk (_stream_readable.js:294:12)
            at readableAddChunk (_stream_readable.js:275:11)
            at Socket.Readable.push (_stream_readable.js:209:10)
            at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
          name: 'error',
          length: 163,
          severity: 'FATAL',
          code: '28P01',
          detail: undefined,
          hint: undefined,
          position: undefined,
          internalPosition: undefined,
          internalQuery: undefined,
          where: undefined,
          schema: undefined,
          table: undefined,
          column: undefined,
          dataType: undefined,
          constraint: undefined,
          file: 'd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\libpq\\auth.c',
          line: '336',
          routine: 'auth_failed'
        }
      }
  </code></pre>
  
  <p>The <code>db.js</code> is required in app's <code>index.js</code>:</p>
  
  <pre><code>require("./startup/db");
  </code></pre>
  
  <p>Since my unit tests only test models (the db connection works fine. The problem is likely <code>process.env.DB_PASSWORD</code> didn't return a value somehow.), I don't quite understand how the db connection test jumps in by itself and throws error. </p>