(n)
| 394 | }); |
| 395 | |
| 396 | function createDummyServers(n) { |
| 397 | const basePort = process.env.WEBPACK_DEV_SERVER_TEST_BASE_PORT || 30000; |
| 398 | process.env.WEBPACK_DEV_SERVER_BASE_PORT = basePort; |
| 399 | |
| 400 | return (Array.isArray(n) ? n : Array.from({ length: n })).reduce( |
| 401 | (p, _, i) => |
| 402 | p.then( |
| 403 | () => |
| 404 | new Promise((resolve) => { |
| 405 | devServerPort = basePort + i; |
| 406 | const compiler = webpack(config); |
| 407 | const server = new Server( |
| 408 | { port: devServerPort, host: "0.0.0.0" }, |
| 409 | compiler, |
| 410 | ); |
| 411 | |
| 412 | dummyServers.push(server); |
| 413 | |
| 414 | server.startCallback((err) => { |
| 415 | if (err) { |
| 416 | // If we get EACCES, try again with a higher port range |
| 417 | if ( |
| 418 | err.code === "EACCES" && |
| 419 | !process.env.WEBPACK_DEV_SERVER_TEST_RETRY |
| 420 | ) { |
| 421 | process.env.WEBPACK_DEV_SERVER_TEST_RETRY = true; |
| 422 | process.env.WEBPACK_DEV_SERVER_TEST_BASE_PORT = 40000; |
| 423 | // Resolve and let the test restart with the new port range |
| 424 | resolve(); |
| 425 | } else { |
| 426 | Promise.reject(err); |
| 427 | } |
| 428 | } else { |
| 429 | resolve(); |
| 430 | } |
| 431 | }); |
| 432 | }), |
| 433 | ), |
| 434 | Promise.resolve(), |
| 435 | ); |
| 436 | } |
| 437 | |
| 438 | it("should return the port when the port is specified", async () => { |
| 439 | const retryCount = 1; |
no test coverage detected
searching dependent graphs…