Skip to content

Commit

Permalink
[test] Fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Mar 19, 2019
1 parent 148c373 commit 7f5025d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/websocket.test.js
Expand Up @@ -380,13 +380,14 @@ describe('WebSocket', () => {
});

it('does not re-emit `net.Socket` errors', (done) => {
const codes = ['EPIPE', 'ECONNABORTED', 'ECANCELED', 'ECONNRESET'];
const wss = new WebSocket.Server({ port: 0 }, () => {
const ws = new WebSocket(`ws://localhost:${wss.address().port}`);

ws.on('open', () => {
ws._socket.on('error', (err) => {
assert.ok(err instanceof Error);
assert.ok(err.message.startsWith('write E'));
assert.ok(codes.includes(err.code), `Unexpected code: ${err.code}`);
ws.on('close', (code, message) => {
assert.strictEqual(message, '');
assert.strictEqual(code, 1006);
Expand Down

0 comments on commit 7f5025d

Please sign in to comment.