vitest-mock-socket

JSON →
library 2.1.0 ·javascript
verified Jun 7, 2026

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.