@relaycorp/ws-mock
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"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). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28899
46
4