Skip to content

Commit 92079a0

Browse files
committed
test: fix test failure due to localhost being also ipv6
Depending on runtime environment, "localhost" might resolve to both IPv4 and IPv6, resulting in an AggregateError in place of an Error.
1 parent 2ae1c36 commit 92079a0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/supertest.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('request(url)', function () {
3434
});
3535

3636
server = app.listen(function () {
37-
const url = 'http://localhost:' + server.address().port;
37+
const url = 'http://127.0.0.1:' + server.address().port;
3838
request(url)
3939
.get('/')
4040
.expect('hello', done);
@@ -51,7 +51,7 @@ describe('request(url)', function () {
5151
});
5252

5353
server = app.listen(function () {
54-
const url = 'http://localhost:' + server.address().port;
54+
const url = 'http://127.0.0.1:' + server.address().port;
5555
const test = request(url).get('/');
5656
test.end(function (err, res) {
5757
this.should.eql(test);
@@ -107,7 +107,7 @@ describe('request(app)', function () {
107107
});
108108

109109
server = app.listen(function () {
110-
const url = 'http://localhost:' + server.address().port;
110+
const url = 'http://127.0.0.1:' + server.address().port;
111111
request(url)
112112
.get('/')
113113
.end(function (err, res) {
@@ -328,7 +328,7 @@ describe('request(app)', function () {
328328
});
329329

330330
server = app.listen(function () {
331-
const url = 'http://localhost:' + server.address().port;
331+
const url = 'http://127.0.0.1:' + server.address().port;
332332
request(url)
333333
.get('/')
334334
.timeout(1)
@@ -348,7 +348,7 @@ describe('request(app)', function () {
348348
});
349349

350350
server = app.listen(function () {
351-
const url = 'http://localhost:' + server.address().port;
351+
const url = 'http://127.0.0.1:' + server.address().port;
352352
server.close();
353353
request(url)
354354
.get('/')
@@ -381,7 +381,7 @@ describe('request(app)', function () {
381381

382382
describe('.expect(status)', function () {
383383
it('should handle connection error', function (done) {
384-
const req = request.agent('http://localhost:1234');
384+
const req = request.agent('http://127.0.0.1:1234');
385385

386386
req
387387
.get('/')

0 commit comments

Comments
 (0)