Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@relaycorp/ws-mock

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@relaycorp/ws-mock - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"name": "@relaycorp/ws-mock",
"version": "1.1.0",
"version": "1.1.1",
"author": {

@@ -5,0 +5,0 @@ "email": "no-reply@relaycorp.tech",

@@ -13,3 +13,3 @@ # @relaycorp/ws-mock

You should initialise `MockClient` by passing the WebSocket server to be tested and then call `client.connect()` to initiate the connection. From that point you can interact with the server. For example:
You should initialise `MockClient` by passing the `ws` server to be tested and then call `client.connect()` to initiate the connection. From that point you can interact with the server. For example:

@@ -27,1 +27,21 @@ ```javascript

You'll find [real-world examples in relaycorp/relaynet-internet-gateway](https://github.com/relaycorp/relaynet-internet-gateway/search?l=TypeScript&q=%22%40relaycorp%2Fws-mock%22).
## Using the mock server
Simply initialise `MockServer` with the `ws` client connection you wish to test. For example:
```javascript
test('Server message should be played back', async () => {
const mockConnection = new MockConnection();
const mockServer = new MockServer(mockConnection);
const clientUnderTest = new ClientUnderTest(mockConnection);
clientUnderTest.connectToServer();
mockServer.send('foo');
const clientResponse = await mockServer.receive();
expect(clientResponse).toEqual('foo');
});
```
You'll find [real-world examples in relaycorp/relaynet-poweb-js](https://github.com/relaycorp/relaynet-poweb-js/search?l=TypeScript&q=%22%40relaycorp%2Fws-mock%22).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc