Skip to content

Commit

Permalink
test(AWS Websocket): Resend messsage if reception was not confirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Apr 24, 2020
1 parent 90ceecd commit c6974a6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/integration-all/websocket/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@ describe('AWS - API Gateway Websocket Integration Test', function() {
}
})(reject);

ws.on('error', reject);
ws.on('open', () => {
let timeoutId;
const sendMessage = () => {
log.debug("Sending message to 'hello' route");
ws.send(JSON.stringify({ action: 'hello', name: 'serverless' }));
});
timeoutId = setTimeout(sendMessage, 1000);
};

ws.on('error', reject);
ws.on('open', sendMessage);

ws.on('close', resolve);

ws.on('message', event => {
clearTimeout(timeoutId);
try {
log.debug(`Received WebSocket message: ${event}`);
expect(event).to.equal('Hello, serverless');
Expand Down

0 comments on commit c6974a6

Please sign in to comment.