karate icon indicating copy to clipboard operation
karate copied to clipboard

Server Sent Events testing

Open vs-dsva opened this issue 6 months ago • 3 comments

Server Sent Events (SSE) are quite ubiquitous nowadays but I cannot really test them with Karate when the response of a call is an SSE response.

sequenceDiagram
    client->>server: GET /notifications
    server-->>client: 200 OK + SSE stream payload
    server-->>client: SSE stream payload

So in order to test I would need either:

  1. A way to create assertions of the stream (stream contains data)
  2. A way to wait cancel the stream and transform the capture in JSON and then perform the assertion

vs-dsva avatar Jul 04 '25 09:07 vs-dsva

Isn't this your issue https://stackoverflow.com/questions/60121921/trying-to-do-assertion-on-sse-type-content-type

i asked this question few years ago and @ptrthomas responded fast as usual

unless it's something different

sadiqkassamali avatar Jul 08 '25 17:07 sadiqkassamali

Well - this is partially what i need. The issue is that I want to wait for let's say 3 minutes and watch the stream for a certain event that might or might not come. Apart from matching the data I need a way to deal with the stream which is different from the request-response mechanism in Karate. Even Postman (which I hate) has SSE and websocket extensions so I really think that a way of handling streaming responses is needed in Karate also.

vs-dsva avatar Jul 11 '25 05:07 vs-dsva

@vs-dsva noted. heads up that this is likely to be added as a closed-source extension to karate similar to kafka, gRPC and websocket which are already released: https://github.com/karatelabs/karate-addons

ptrthomas avatar Jul 22 '25 04:07 ptrthomas