gr2m / gr2m/node-net-interceptor

Mocking net.Socket ?

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Hi,

Thanks for isolating this logic. I tried to use this to mock a regular `Socket` connection so I can test how well a DB client handles network failures. This is a 3rd-party client which call `new Socket(...)` deep inside the library and we cannot change that code. I wanted to intercept their connections by using this library, however currently `node-net-interceptor` patches `net.connect` and `net.createConnection`, but not `new net.Socket()`. Do you plan to support mocking `net.Socket` connections?

For example -
```js

// Intercepted by node-net-interceptor
net.connect({ port: 80, host: "www.example.com" });

// Not intercepted
const testSocket = new net.Socket();
testSocket.connect({ port: 80, host: "www.example.com" });
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.