vitest-mock-socket
JSON →A library to mock and assert WebSocket interactions in Vitest tests. Version 2.1.0 is current, released with support for Vitest 2+ and Node >=24. It intercepts global WebSocket connections and provides an API to simulate server events, send/receive messages, and assert on WebSocket state. Compared to alternatives like mock-socket, it is tailored for Vitest, integrates with Vitest's test lifecycle, and ships TypeScript definitions. Low release cadence, focused on stability.
Resources
packagevitest-mock-socket ↗
API endpoints
full doc /v1/registry/vitest-mock-socket