Skip to content

Commit

Permalink
refactor(test): do not hardcode any ports, use ephemeral ports
Browse files Browse the repository at this point in the history
  • Loading branch information
lamweili committed Oct 3, 2022
1 parent c1c4402 commit 8847310
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('request(app)', function () {
res.send('hey');
});

server = app.listen(4000, function () {
server = app.listen(function () {
request(server)
.get('/')
.end(function (err, res) {
Expand All @@ -99,8 +99,9 @@ describe('request(app)', function () {
res.send('hey');
});

server = app.listen(4001, function () {
request('http://localhost:4001')
server = app.listen(function () {
const url = 'http://localhost:' + server.address().port;
request(url)
.get('/')
.end(function (err, res) {
res.status.should.equal(200);
Expand Down

0 comments on commit 8847310

Please sign in to comment.