You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Counting on super.write() won't work because I'm sure Node will throw something connection-related if the socket connection failed (think of the mocked requests to non-existing hosts) and you try to write onto that socket.
I hate to re-create internal Node errors so let's brainstorm how we can achieve this behavior without repeating Node.
@kettanaito It seems like the input validation is the first thing Node does before trying to write into the socket (source) so we can do something like:
it('does not allow empty chunk',async()=>{constemitter=newEmitter<HttpRequestEventMap>()constrequest=newNodeClientRequest(normalizeClientRequestArgs('http:',httpServer.http.url('/comment'),{method: 'POST',}),{
emitter,
logger,})// @ts-expect-error - test undefined chunkexpect(()=>request.write()).toThrow('The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined')// @ts-expect-error - test null chunkexpect(()=>request.write(null)).toThrow('May not write null values to stream')})
https://github.com/mswjs/interceptors/blob/main/src/interceptors/ClientRequest/NodeClientRequest.ts#L101
chunk
must not be undefined and throw:I can open a PR, but because you ignored this case positively, I want to ensure I don't miss something.
About the solution, we can either:
The text was updated successfully, but these errors were encountered: