i'm trying to stub a socketcluster-client to emit events to the socketserver.
i keep getting the below error from sinon
TypeError: socket.emit is not a function
this is my test-suite
import {expect} from 'chai';
import sinon from 'sinon'
import io from 'socketcluster-client';
import testServer from '../../server/server.js';
describe('httpServer',() => {
beforeEach(() => {
testServer(4000)
})
it('should respond to the ping event',() => {
var socket =sinon.stub(io,'connect')
var message = 'house'
socket.emit('ping',message);
})
})
the connect function usually needs to be called with an argument specifying the port io.connect({port:4000})
how do i stub this with sinon?
i would ideally like to emit events from the stub to check my server response