mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
test(AWS Websocket): Resend messsage if reception was not confirmed
This commit is contained in:
parent
90ceecd00d
commit
c6974a63c8
@ -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');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user