title: Mocha beforeEach and afterEach during testing
body: <p>I have been trying to test my test server using mocha. This is the following code that I use, almost the same as one found in another similar post.</p>
  
  <pre><code>beforeEach(function(done) {
      // Setup
      console.log('test before function');
      ws.on('open', function() {
          console.log('worked...');
          done();
      });
      ws.on('close', function() {
          console.log('disconnected...');
      });
  });
  
  afterEach(function(done) {
      // Cleanup
      if(readyState) {
          console.log('disconnecting...');
          ws.close();
      } else {
          // There will not be a connection unless you have done() in beforeEach, socket.on('connect'...)
          console.log('no connection to break...');
      }
      done();
  });
  
  describe('WebSocket test', function() {
      //assert.equal(response.result, null, 'Successful Authentification');
  });
  </code></pre>
  
  <p>the problem is that when I execute this draft, none of the console.log that is expected to be seen is visible on the command prompt. Can you please explain to me what am I doing wrong? </p>