@applitools/execution-grid-tunnel
Version:
Allows user to run tests with exection-grid and navigate to private hosts and ips
18 lines (13 loc) • 373 B
JavaScript
const findProcess = require('find-process')
module.exports = async function (min, max) {
let port
let processesOnPort
do {
port = _getRandomPort(min, max)
processesOnPort = await findProcess('port', port)
} while (processesOnPort.length !== 0)
return port
}
function _getRandomPort(min, max) {
return Math.floor(Math.random() * (max - min) + min)
}