text/event-stream Content-Type in a response, it automatically parses the SSE events and makes them available in the test results. Events are shown in verbose console output and returned in JSON/API results.
Basic Usage
Connect to an SSE endpoint and assert on the events received:How It Works
- hitspec sends the HTTP request normally (the
Accept: text/event-streamheader is set by your test file). - The server responds with
Content-Type: text/event-streamand a body containing SSE-formatted events. - hitspec detects the content type and parses the response body into structured events.
- Each event has optional
id,type, anddatafields per the SSE specification. - Parsed events appear in verbose output and in the JSON/API result under
sseEvents.
Configuration
Control how long hitspec listens for events using the@timeout directive:
Verbose Output
Run with--verbose to see parsed SSE events in the console:
Multi-line Data
SSE events with multipledata: lines are joined with newlines, per the SSE specification:
data equal to "line one\nline two\nline three".