Skip to content

Commit 5f6d903

Browse files
authored
test: add e2e tests for getFreePort api method (#4114)
1 parent d3858cb commit 5f6d903

File tree

6 files changed

+422
-143
lines changed

6 files changed

+422
-143
lines changed

test/e2e/__snapshots__/api.test.js.snap.webpack4

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,73 @@ exports[`API Invalidate callback should use the provided \`callback\` function:
2626

2727
exports[`API Invalidate callback should use the provided \`callback\` function: response status 1`] = `200`;
2828

29+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): console messages 1`] = `
30+
Array [
31+
"[HMR] Waiting for update signal from WDS...",
32+
"Hey.",
33+
"[webpack-dev-server] Hot Module Replacement enabled.",
34+
"[webpack-dev-server] Live Reloading enabled.",
35+
]
36+
`;
37+
38+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): page errors 1`] = `Array []`;
39+
40+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): response status 1`] = `200`;
41+
42+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): console messages 1`] = `
43+
Array [
44+
"[HMR] Waiting for update signal from WDS...",
45+
"Hey.",
46+
"[webpack-dev-server] Hot Module Replacement enabled.",
47+
"[webpack-dev-server] Live Reloading enabled.",
48+
]
49+
`;
50+
51+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): page errors 1`] = `Array []`;
52+
53+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): response status 1`] = `200`;
54+
55+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: console messages 1`] = `
56+
Array [
57+
"[HMR] Waiting for update signal from WDS...",
58+
"Hey.",
59+
"[webpack-dev-server] Hot Module Replacement enabled.",
60+
"[webpack-dev-server] Live Reloading enabled.",
61+
]
62+
`;
63+
64+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: page errors 1`] = `Array []`;
65+
66+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: response status 1`] = `200`;
67+
68+
exports[`API Server.getFreePort should return the port when the port is \`null\`: console messages 1`] = `
69+
Array [
70+
"[HMR] Waiting for update signal from WDS...",
71+
"Hey.",
72+
"[webpack-dev-server] Hot Module Replacement enabled.",
73+
"[webpack-dev-server] Live Reloading enabled.",
74+
]
75+
`;
76+
77+
exports[`API Server.getFreePort should return the port when the port is \`null\`: page errors 1`] = `Array []`;
78+
79+
exports[`API Server.getFreePort should return the port when the port is \`null\`: response status 1`] = `200`;
80+
81+
exports[`API Server.getFreePort should return the port when the port is undefined: console messages 1`] = `
82+
Array [
83+
"[HMR] Waiting for update signal from WDS...",
84+
"Hey.",
85+
"[webpack-dev-server] Hot Module Replacement enabled.",
86+
"[webpack-dev-server] Live Reloading enabled.",
87+
]
88+
`;
89+
90+
exports[`API Server.getFreePort should return the port when the port is undefined: page errors 1`] = `Array []`;
91+
92+
exports[`API Server.getFreePort should return the port when the port is undefined: response status 1`] = `200`;
93+
94+
exports[`API Server.getFreePort should throw the error when the port isn't found 1`] = `"busy"`;
95+
2996
exports[`API deprecated API should log warning when the "port" and "host" options from options different from arguments ('listen' method): console messages 1`] = `
3097
Array [
3198
"[HMR] Waiting for update signal from WDS...",

test/e2e/__snapshots__/api.test.js.snap.webpack5

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,73 @@ exports[`API Invalidate callback should use the provided \`callback\` function:
2626

2727
exports[`API Invalidate callback should use the provided \`callback\` function: response status 1`] = `200`;
2828

29+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): console messages 1`] = `
30+
Array [
31+
"[HMR] Waiting for update signal from WDS...",
32+
"Hey.",
33+
"[webpack-dev-server] Hot Module Replacement enabled.",
34+
"[webpack-dev-server] Live Reloading enabled.",
35+
]
36+
`;
37+
38+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): page errors 1`] = `Array []`;
39+
40+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): response status 1`] = `200`;
41+
42+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): console messages 1`] = `
43+
Array [
44+
"[HMR] Waiting for update signal from WDS...",
45+
"Hey.",
46+
"[webpack-dev-server] Hot Module Replacement enabled.",
47+
"[webpack-dev-server] Live Reloading enabled.",
48+
]
49+
`;
50+
51+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): page errors 1`] = `Array []`;
52+
53+
exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): response status 1`] = `200`;
54+
55+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: console messages 1`] = `
56+
Array [
57+
"[HMR] Waiting for update signal from WDS...",
58+
"Hey.",
59+
"[webpack-dev-server] Hot Module Replacement enabled.",
60+
"[webpack-dev-server] Live Reloading enabled.",
61+
]
62+
`;
63+
64+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: page errors 1`] = `Array []`;
65+
66+
exports[`API Server.getFreePort should retry finding the port when serial ports are busy: response status 1`] = `200`;
67+
68+
exports[`API Server.getFreePort should return the port when the port is \`null\`: console messages 1`] = `
69+
Array [
70+
"[HMR] Waiting for update signal from WDS...",
71+
"Hey.",
72+
"[webpack-dev-server] Hot Module Replacement enabled.",
73+
"[webpack-dev-server] Live Reloading enabled.",
74+
]
75+
`;
76+
77+
exports[`API Server.getFreePort should return the port when the port is \`null\`: page errors 1`] = `Array []`;
78+
79+
exports[`API Server.getFreePort should return the port when the port is \`null\`: response status 1`] = `200`;
80+
81+
exports[`API Server.getFreePort should return the port when the port is undefined: console messages 1`] = `
82+
Array [
83+
"[HMR] Waiting for update signal from WDS...",
84+
"Hey.",
85+
"[webpack-dev-server] Hot Module Replacement enabled.",
86+
"[webpack-dev-server] Live Reloading enabled.",
87+
]
88+
`;
89+
90+
exports[`API Server.getFreePort should return the port when the port is undefined: page errors 1`] = `Array []`;
91+
92+
exports[`API Server.getFreePort should return the port when the port is undefined: response status 1`] = `200`;
93+
94+
exports[`API Server.getFreePort should throw the error when the port isn't found 1`] = `"busy"`;
95+
2996
exports[`API deprecated API should log warning when the "port" and "host" options from options different from arguments ('listen' method): console messages 1`] = `
3097
Array [
3198
"[HMR] Waiting for update signal from WDS...",

0 commit comments

Comments
 (0)