vitest-websocket-mock

JSON →
library 0.5.0 ·javascript
verified Jun 7, 2026

A mock WebSocket server for Vitest tests, forked from jest-websocket-mock. Current stable version is 0.5.0. It provides a WS class to create mock servers, track messages, and send responses, with Vitest-specific matchers and helpers. Works with Vitest >=3 and TypeScript types are included. Key differentiators: seamless Vitest integration (no Jest dependency), supports jsonProtocol, and includes async promises (connected, nextMessage, closed) for precise test timing.