Back to Fastapi

Testing WebSockets { #testing-websockets }

docs/en/docs/advanced/testing-websockets.md

0.137.1410 B
Original Source

Testing WebSockets { #testing-websockets }

You can use the same TestClient to test WebSockets.

For this, you use the TestClient in a with statement, connecting to the WebSocket:

{* ../../docs_src/app_testing/tutorial002_py310.py hl[27:31] *}

/// note

For more details, check Starlette's documentation for testing WebSockets.

///