title: Mocha web socket testing for https server
body: <p>I've been trying to test a web socket connection. There a few good tutorials out there that describe it which led me to this sort of dummy code just to see if I can test data being sent over websockets:</p>
  
  <pre><code>var socketURL= 'https://localhost:9002';
  var io = require('socket.io-client');
  options={
  transports: ['websocket'],
  'force new connection': true
  };
  describe("Connection test", function(){
  it('to check if data is received',function(done){
      var client = io.connect(socketURL,options);
  
      client.on('connect',function(){
          console.log("in connect");
          client.emit('data',{data:10});
  
          client.on('result',function(data){
              console.log(data);
              data.should.equal(10);
              done();
          });
  
      });
  });
  </code></pre>
  
  <p>I've set up the server like so, where the OPTIONS determine the key and cert to read</p>
  
  <pre><code>var app = express();
  var httpsServer = https.createServer(OPTIONS, app);
  
  httpsServer.listen(9002);
  var io = require('socket.io').listen(httpsServer);
  io.on('connection', function(socket){
      socket.on('data', function(data){
          socket.emit('result',data);
      })
  })
  </code></pre>
  
  <p>The problem is that the client.on('connect') is never called, I can see this by nothing printing out to the console. All that happens is a time out error: "timeout of 2000ms exceeded. Ensure the done() callback is being called in this test."
  I've moved the done() and it doesn't make a diffence. I think the problem is that the tutorials I've follow use a http server whereas I'm using a https server, and I figure that this may require addition methods to connect, however I'm quite new to mocha so I don't know what they may be.
  Any help would be appreciated</p>