()
| 277 | } |
| 278 | |
| 279 | function getAvailablePort() { |
| 280 | const min = 7000; |
| 281 | const max = 65535; |
| 282 | let count = 0; |
| 283 | const getRandomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; |
| 284 | let port = getRandomInt(min, max); |
| 285 | while (!isPortAvailable(port) && count < max - min) { |
| 286 | port++; |
| 287 | if (port > max) { |
| 288 | port = min; |
| 289 | } |
| 290 | if (isPortAvailable(port)) { |
| 291 | return port; |
| 292 | } |
| 293 | count++; |
| 294 | if (count >= max - min) { |
| 295 | throw new Error(`No port is available in the range ${min} - ${max}`); |
| 296 | } |
| 297 | } |
| 298 | return port; |
| 299 | } |
| 300 | |
| 301 | async function testDom() { |
| 302 | const port = getAvailablePort(); |
no test coverage detected