title: Sinon unit testing MySQL connection
body: <p>I am trying to unit test my AWS Node Lambda. I am using MySQL. I have a utility file to get a MySQL connection pool, which is a dependency in my handler. I am trying to unit test my handler via Mocha and Sinon. I want to stub or mock the database pool and connection (without actually creating a db connection or hitting the database), but I am not having any luck. Does anyone know how to achieve this? I created the following 2 files as a test harness:</p>
  
  <p><strong>dbConn.js</strong></p>
  
  <pre><code>const mysql = require('mysql2/promise');
  
  async function getPool(options = {}) {
    return await mysql.createPool(optionsClone);
  }
  
  module.exports = {
    getPool
  };
  </code></pre>
  
  <p><strong>getEmployees.js</strong></p>
  
  <pre><code>const database = require('./dbConn');
  
  exports.handler = async function(event, context, callback) {
    // Connect to a database via connection pool
    let pool = await database.getPool(dbOptions);
    let conn = await pool.getConnection();
  
    const dbResult = await conn.query('select * from employees');
  
    conn.release();
  
    return dbResult;
  };
  </code></pre>