import {withWebSocketTest} from '@rest-vir/run-service';
import {describe, it} from '@augment-vir/test'; // or use mocha, jest, etc. values
describe('my WebSocket', () => {
it(
'does a thing',
withWebSocketTest(
myServiceImplementation.webSockets['/my-web-socket-path'],
{},
(webSocket) => {
const response = await webSocket.sendAndWaitForReply();
assert.strictEquals(response, 'ok');
},
),
);
});
Test your WebSocket implementation with a real connection pipeline. This is used to generate an
it
callback and will automatically close the WebSocket connection at the end of the test.You can also use testWebSocket to directly test a WebSocket but it does not automatically close the WebSocket.
This should be used in backend testing to verify your WebSocket implementation.