title: Socket.on not being called in mocha
body: <p>I try to test socket.io using mocha, but i have a problem when make a socket call <em><strong>on</strong></em>. I think socket is not connected, because the console log not triggered but the console.log outside the socket call is show. Or it's wrong about how i use the done() method ?</p>
  <pre><code>const { assert } = require('chai');
  const ioServer = require('socket.io');
  const ioClient = require('socket.io-client');
  const http = require('http');
  
  const socketUrl = 'http://localhost:5000';
  const options = {
    transports: ['websocket'],
    'force new connection': true,
  };
  
  let server;
  let client;
  let httpServer;
  
  describe('Socket', () =&gt; {
    beforeEach(done =&gt; {
      httpServer = http.createServer().listen();
      server = ioServer(httpServer);
      client = ioClient.connect(socketUrl, options);
      server.on('connection', socket =&gt; {
        console.log('connected server');
        socket.emit('echo', 'Hello World');
      });
      client.on('echo', message =&gt; {
        console.log('connected client');
        console.log(message);
      });
      console.log('test');
      done();
    });
  
    afterEach(done =&gt; {
      server.close();
      client.close();
      done();
    });
  
    it('It should connect socket', done =&gt; {
      client.on('echo', message =&gt; {
        assert.equal(message, 'Hello World');
      });
      done();
    });
  });
  
  </code></pre>
  <p>Here's the screenshoot cli terminal when running mocha.
  <a href="https://i.stack.imgur.com/2zFM2.png" rel="nofollow noreferrer">Mocha</a></p>