Skip to content

Commit

Permalink
Throw error if mock server port is busy (#20692)
Browse files Browse the repository at this point in the history
* Throw error if mock server port is busy

* Fix lint

---------

Co-authored-by: legobeat <[email protected]>
  • Loading branch information
FrederikBolding and legobeat authored Sep 8, 2023
1 parent 5e624cb commit 973e9ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@
"del": "^6.1.1",
"depcheck": "^1.4.3",
"dependency-tree": "^10.0.9",
"detect-port": "^1.5.1",
"duplexify": "^4.1.1",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const { promises: fs } = require('fs');
const BigNumber = require('bignumber.js');
const mockttp = require('mockttp');
const detectPort = require('detect-port');
const createStaticServer = require('../../development/create-static-server');
const { tEn } = require('../lib/i18n-helpers');
const { setupMocking } = require('./mock-e2e');
Expand Down Expand Up @@ -108,6 +109,11 @@ async function withFixtures(options, testSuite) {
const mockedEndpoint = await setupMocking(mockServer, testSpecificMock, {
chainId: ganacheOptions?.chainId || 1337,
});
if ((await detectPort(8000)) !== 8000) {
throw new Error(
'Failed to set up mock server, something else may be running on port 8000.',
);
}
await mockServer.start(8000);

driver = (await buildWebDriver(driverOptions)).driver;
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14162,7 +14162,7 @@ __metadata:
languageName: node
linkType: hard

"detect-port@npm:^1.3.0":
"detect-port@npm:^1.3.0, detect-port@npm:^1.5.1":
version: 1.5.1
resolution: "detect-port@npm:1.5.1"
dependencies:
Expand Down Expand Up @@ -24341,6 +24341,7 @@ __metadata:
del: "npm:^6.1.1"
depcheck: "npm:^1.4.3"
dependency-tree: "npm:^10.0.9"
detect-port: "npm:^1.5.1"
duplexify: "npm:^4.1.1"
end-of-stream: "npm:^1.4.4"
eslint: "npm:^8.36.0"
Expand Down

0 comments on commit 973e9ce

Please sign in to comment.