title: Testing with Mocha Chai async function
body: <p>I have a Hapi JS server with routes, this is my Hapi js Server</p>
  
  <pre><code>const Hapi = require('hapi');
  
  import { Users } from './users';
  
  const port  3000;
  
  const server = new Hapi.Server();
  
  server.connection({ port });
  
  export async function HapiServer() {
  
    server.route([
      {
        method: 'GET',
  
        path: '/getUsers',
        config: {
          handler: async (req: any, reply: any) =&gt; {
            try {
  
  
              await Users.getUsers(req.params.id)
                .then((result) =&gt; {
                  reply(result);
                });
            } catch (error) {
              reply(error);
            }
          },
  
  
  
        },
      },
    ]);
    await server.start();
    console.log('server running at', server.info.port);
  }
  
  
  HapiServer();
  </code></pre>
  
  <p>I use Mocha and Chai for make a Unit Testing as follow:</p>
  
  <pre><code>'use strict';
  import { should } from 'chai';
  import { HapiServer } from '../../server';
  const chai = require('chai');
  const chaiHttp = require('chai-http');
  
  chai.use(chaiHttp);
  
  describe('testing users ', () =&gt; {
      it('can get all users', async (done) =&gt; {
          const result = await chai
          .request(HapiServer)
              .get(/getUsers)
          .then((error, response) =&gt; {
              if (error) { done(error); }
              response.should.have.status(200);
              done();            
          }).catch(done);
      });
  });
  </code></pre>
  
  <p>When run the test always have this:</p>
  
  <pre><code>Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (./server.test.ts)
  </code></pre>
  
  <p>I already try change my mocha config in package.json </p>
  
  <pre><code>mocha --timeout 10000
  </code></pre>
  
  <p>What could I be doing wrong? I understand that Mocha supports promises.</p>