Closing the connection

Mocking SSE connection closure.

You can close the intercepted client connection by calling client.close() at any time in your request handler.

sse('/stream', ({ client }) => {
  client.close()
})

Unlike client.error(), calling client.close() produces a graceful connection closure and will not emit the error event on the underlying EventSource instance.