Avoid an uncaught TypeError which can stop the entire QUnit test suite

- If the WebSocket transport failed to connect, an uncaught type error
  would be thrown from the modified