websocket-mockup is a lightweight mock WebSocket server and client implementation for testing, supporting both server-side and W3C WebSocket API shims. Version 1.3.1 is the latest stable release, with infrequent updates. It allows developers to simulate WebSocket connections without a real server, ideal for unit and integration tests. Key differentiators include simple API, event-driven request handling, and support for custom host routing. Unlike heavier solutions like mock-socket, this package focuses on mimicking the Node.js ws library server interface.
npm install websocket-mockupNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a mock WebSocket server and client, demonstrates message exchange and event handling.
Ensure server is listening before creating client, or use a timeout in test environment.
Use property assignment (ws.onopen = handler) or addEventListener if shimmed.
Move await logic outside the event handler.
Wrap binaryData in Buffer or decode with TextDecoder as needed.
Add 'new': new WebSocketServer({ ... }).Ensure server is created and 'request' event fires; use async/await with server setup.
Use a URL with host matching server's host option, e.g., 'wss://test.local'.
No dependency data recorded yet.