a mocked version of a socket for testing

Usage no npm install needed!

<script type="module">
  import socketIoMock from '';


npm version npm license XO code style

Build Status Code Climate Test Coverage Issue Count npm npm

A mock to test the library implementation.

🚀 Now written in ES6! Bundled with rollup.

NEW! Added support for disconnect() and close()


npm install


Simply create new socket mock with:

import MockedSocket from '';
let socket = new MockedSocket();

And use the socket as if it was a normal socket.

For example:

import SocketMock from '';
import { expect } from 'chai';

describe('Fast and isolated socket tests', function(){
    it('Sockets should be able to talk to each other without a server', function(done) {
        let socket = new SocketMock();

        socket.on('message', function (message) {
            expect(message).to.equal('Hello World!');
        socket.socketClient.emit('message', 'Hello World!');