eclipsesource / eclipsesource/tabris-js-cli
Module "mock-socket" can cause false test positives and negatives
- Dominant language
- JavaScript
- Stars
- 11
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
There are multiple issues with the [library](https://www.npmjs.com/package/mock-socket), specifically with the server mock used - in our case - as a drop-in replacement for [the `ws` Server](https://www.npmjs.com/package/ws). It may be the case that that is not its intended use case.
Issues:
* Misses `Server.prototype.ping`
* Gives server instead of client in 'connect' event, [which is fixed in 8.0](https://github.com/thoov/mock-socket/releases/tag/8.0.0)...
* But if we upgrade this causes issues: https://github.com/thoov/mock-socket/issues/215
* Does not give request object in 'connect' event (we use that)
* Uses same object as server socket and client socket (impact unknown)
This also prevents us from implementing this test:
```
it('prints connect on slow reconnect', async function() {
const rc = createRemoteConsoleClient(debugServer, webSocketFactory);
const logPromise = waitForCalls(terminal.log, 2, 8000);
rc._webSocket.close(1000);
rc._disposeSocket();
await new Promise(resolve => setTimeout(resolve, 4000));
rc._connect();
const log = await logPromise;
expect(log).to.contain(' connected');
}).timeout(10000);
```
Contributor guide
Assessment
This issue has not been assessed yet.