Skip to content

Commit

Permalink
[test] Use a reserved port
Browse files Browse the repository at this point in the history
The port 1337 might be open.
  • Loading branch information
lpinca committed Sep 8, 2023
1 parent ae60ce0 commit 50c9468
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2813,16 +2813,17 @@ describe('WebSocket', () => {
});

it('can be called from an error listener while connecting', (done) => {
const ws = new WebSocket('ws://localhost:1337');
const codes = ['ECONNREFUSED', 'ETIMEDOUT'];
const ws = new WebSocket('ws://localhost:270');

ws.on('open', () => done(new Error("Unexpected 'open' event")));
ws.on('error', (err) => {
assert.ok(err instanceof Error);
assert.strictEqual(err.code, 'ECONNREFUSED');
assert.ok(codes.includes(err.code), `Unexpected code: ${err.code}`);
ws.close();
ws.on('close', () => done());
});
}).timeout(4000);
});

it("can be called from a listener of the 'redirect' event", (done) => {
const server = http.createServer();
Expand Down Expand Up @@ -3087,16 +3088,17 @@ describe('WebSocket', () => {
});

it('can be called from an error listener while connecting', (done) => {
const ws = new WebSocket('ws://localhost:1337');
const codes = ['ECONNREFUSED', 'ETIMEDOUT'];
const ws = new WebSocket('ws://localhost:270');

ws.on('open', () => done(new Error("Unexpected 'open' event")));
ws.on('error', (err) => {
assert.ok(err instanceof Error);
assert.strictEqual(err.code, 'ECONNREFUSED');
assert.ok(codes.includes(err.code), `Unexpected code: ${err.code}`);
ws.terminate();
ws.on('close', () => done());
});
}).timeout(4000);
});

it("can be called from a listener of the 'redirect' event", (done) => {
const server = http.createServer();
Expand Down

0 comments on commit 50c9468

Please sign in to comment.