title: Mocha not finish when using emit socket io
body: <p>Hello i'm using Mocha to run Unit test, everything is OK until testing a method using <code>io.emit</code>, you can see my code below: </p>
  
  <pre><code>var emit = (type, to, content, url) =&gt; {
      var f = false;
      var io = require("../index").io;
      var socketIds = global.socketIds;
      if (socketIds &amp;&amp; socketIds[to]) {
          let sockets = socketIds[to];
          for(let item of sockets){
              io.to(item).emit(type, { type: type, content: content, url: url });
              f = true;
          }
      }
      return f;
  };
  </code></pre>
  
  <p>and this is my test code: </p>
  
  <pre><code>describe("create new notification with offline account", () =&gt; {
      it("it should be return a notification and offline status", done =&gt; {
              const save = global.socketIds;
              global.socketIds = {};
              callService(expected.notification, result =&gt; {
                  Notification.findOne(expected.notification, (err, noti) =&gt; {
                      expect(result.online).to.equal(expected.online);
                      expect(noti).to.exist;
                      global.socketIds = save;
                      done();
                  });
              });
          });
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/fpcQS.png" rel="nofollow noreferrer">Mocha not finish and stop here</a></p>
  
  <ul>
  <li>Mocha version: 5.2.0</li>
  </ul>