# socket.io-stub

> Stub for testing servet socket.io code

Latest version **1.0.2** (published 2018-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install socket.io-stub
pnpm add socket.io-stub
yarn add socket.io-stub
bun add socket.io-stub
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-03-08 |
| First published | 2018-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 190.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nik Korablin |
| Maintainers | nikorablin |
| Keywords | socket.io, stub, testing |

## Links

- npm: https://www.npmjs.com/package/socket.io-stub
- Repository: https://github.com/nikorablin/socket.io-stub
- Homepage: https://github.com/nikorablin/socket.io-stub#readme
- Issues: https://github.com/nikorablin/socket.io-stub/issues
- npm.io page: https://npm.io/package/socket.io-stub

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2018-03-08
- 1.0.1 — 2018-03-07
- 1.0.0 — 2018-03-07

## README

# Socket.io Stub

A socket stub to use when testing [socket.io](https://socket.io/) code

### Using the Stub

```js
const manager = socket => {
  socket.on('ping', payload => socket.emit('pong', payload));
};

describe('Testing socket', () => {
  it('ping will pong', () => {
    const socket = new SocketStub();
    manager(socket);
    socket.simulate('ping', true);
    expect(socket.emitted.length).to.equal(1);
    expect(socket.emitted).to.eql([['pong', true]]);
  });
});
```

### Installation

```
npm i socket.io-stub --save-dev
```

```
yarn add socket.io-stub --dev
```

### Tests

```
yarn test
```

### Methods

**new SocketStub(properties: ?object)**

Instantiate a new socket stub. You can pass a properties object into the constructor to apply properties on the Socket

**simulate(event: string, payload: any)**

Simulate an event on the socket

**clear**

Clear all tracked emitted events from socket

---
_Source: https://npm.io/package/socket.io-stub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
