Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supremetechnopriest/socket.io-mock
Mock for socket.io
https://github.com/supremetechnopriest/socket.io-mock
Last synced: 2 days ago
JSON representation
Mock for socket.io
- Host: GitHub
- URL: https://github.com/supremetechnopriest/socket.io-mock
- Owner: SupremeTechnopriest
- License: mit
- Created: 2016-12-23T21:51:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T19:42:42.000Z (about 2 years ago)
- Last Synced: 2025-02-06T09:38:15.265Z (14 days ago)
- Language: JavaScript
- Size: 193 KB
- Stars: 38
- Watchers: 2
- Forks: 11
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# socket.io-mock
[](http://badge.fury.io/js/socket.io-mock)
[](https://www.npmjs.com/package/socket.io-mock)
[](https://github.com/sindresorhus/xo)[](https://travis-ci.org/SupremeTechnopriest/socket.io-mock)
[](https://codeclimate.com/repos/587e92067a5baf5dec0032e2/feed)
[](https://codeclimate.com/repos/587e92067a5baf5dec0032e2/coverage)
[](https://codeclimate.com/repos/587e92067a5baf5dec0032e2/feed)
[](https://www.npmjs.com/package/socket.io-mock)
[](https://www.npmjs.com/package/socket.io-mock)A mock to test the socket.io library implementation.
🚀 Now written in ES6! Bundled with [`rollup`](https://github.com/rollup/rollup).
> NEW! Added support for disconnect() and close()
# Installation
```bash
npm install socket.io-mock
```# Usage
Simply create new socket mock with:
```js
import MockedSocket from 'socket.io-mock';
let socket = new MockedSocket();
```
And use the socket as if it was a normal Socket.io socket.For example:
```js
import SocketMock from 'socket.io-mock';
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!');
});
});
```