A mock to test the socket.io library implementation
npm install socket-io-mock
Simply create new socket mock with:
var mockedSocket = new require('socket-io-mock')
And use the socket as if it was a normal Socket.io socket.
For example:
var SocketMock = require('socket-io-mock')
, should = require('chai').should()
describe('Fast and isolated socket tests', function(){
it('Sockets should be able to talk to each other without a server', function(done) {
var socket = new SocketMock()
socket.on('message', function (message) {
message.should.be.equal('Hello World!')
})
socket.socketClient.emit('message', 'Hello World!')
})
})