1

I am using Mocha and chai for client testing of a small app that I wrote. However, I have run into a problem where even though I know my socket is connected, mocha reports that it isn't. I have looked around and can't seem to find something that satisfies my needs. Here is the code that I am using for testing.

var assert = chai.assert;

describe('index', function(){
    var socket = rpsApp.setupSocket();
    it('should be connected', function(){
        assert.equal(true, socket.socket.connected);
    });
});
robotmayo
  • 131
  • 10

2 Answers2

1
var chai = require('chai');
var should = chai.should();
var io = require('socket.io-client');

describe("Socket-Server", function () {
  it('user connected and able to send msg through socket.', function (done) {
    var client = io(socketURL);
    client.on('connect', function (data) {
      done();
    });
  });
});

update the socketURL

Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
Sanjeev Kumar
  • 447
  • 1
  • 4
  • 10
0

You need socket.io-client library.

laggingreflex
  • 32,948
  • 35
  • 141
  • 196