TIL: Scripting WebSocket Tests With websocat
wscat is interactive. websocat is scriptable.
echo '{"type":"ping"}' | websocat wss://api.example.com/v1/listen
Pipes input from stdin into the WebSocket. Output goes to stdout.
websocat --exit-on-eof wss://api.example.com/v1/listen < messages.jsonl
Send a file of JSON lines through a WebSocket connection and exit when the input ends.
How do I install websocat?
brew install websocat
Does websocat support SSL?
Yes. Use wss:// URLs. The library handles TLS automatically.