PhoenixTestDatastar.StreamAdapter (PhoenixTestDatastar v0.0.2)

Copy Markdown

Custom Plug adapter for testing long-lived SSE connections.

This adapter intercepts send_chunked/3 and chunk/2 calls, forwarding chunks as messages to a subscriber process. This allows tests to consume SSE events from handlers that enter long-lived receive loops (e.g., waiting for PubSub messages).

How it works

  1. The adapter wraps the standard test adapter
  2. When send_chunked/3 is called, it notifies the subscriber
  3. When chunk/2 is called, it sends the chunk content to the subscriber
  4. The subscriber can receive these messages and parse them as SSE events