MCPcopy Create free account
hub / github.com/Snapchat/Valdi / startMockServer

Function startMockServer

npm_modules/cli/test/hermesClient.spec.ts:168–179  ·  view source on GitHub ↗

Starts a mock WebSocket server that completes the handshake then calls `onReady`.

(
    onReady: (socket: net.Socket) => void,
  )

Source from the content-addressed store, hash-verified

166 Buffer.from('","webSocketDebuggerUrl":"ws://localhost:13595/1"}]', 'utf8'),
167 ]);
168 const runningServer = http.createServer((_req, res) => {
169 res.writeHead(200, { 'Content-Type': 'application/json' });
170 res.end(malformed);
171 });
172 server = runningServer;
173 await new Promise<void>((resolve) => runningServer.listen(0, '127.0.0.1', resolve));
174 port = (runningServer.address() as net.AddressInfo).port;
175
176 await expectAsync(listHermesDevices(port)).toBeRejectedWithError(/malformed UTF-8/);
177 });
178
179 it('rejects Hermes discovery bodies larger than the raw-byte limit', async () => {
180 const runningServer = http.createServer((_req, res) => {
181 res.writeHead(200, { 'Content-Type': 'application/json' });
182 res.end(Buffer.alloc(1024 * 1024 + 1, 0x20));

Callers 1

Calls 3

createMockHermesServerFunction · 0.85
makeWsHandshakeResponseFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected