gr2m / gr2m/node-net-interceptor
Mocking net.Socket ?
- 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
Assessment
This issue has not been assessed yet.