diff --git a/lib/Server.js b/lib/Server.js index edfc688a1e..5d1c6835d5 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -74,7 +74,7 @@ class Server { } static async getFreePort(port) { - if (port && port !== "auto") { + if (typeof port !== "undefined" && port !== null && port !== "auto") { return port; } diff --git a/lib/options.json b/lib/options.json index e647804f7d..b1c6215516 100644 --- a/lib/options.json +++ b/lib/options.json @@ -554,7 +554,9 @@ "Port": { "anyOf": [ { - "type": "number" + "type": "number", + "minimum": 0, + "maximum": 65535 }, { "type": "string", diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index becb276ac9..dd1a5f8e30 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -517,14 +517,24 @@ exports[`options validate should throw an error on the "port" option with '' val - options.port should be a non-empty string." `; +exports[`options validate should throw an error on the "port" option with '-1' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.port should be >= 0 and <= 65535." +`; + +exports[`options validate should throw an error on the "port" option with '65536' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.port should be >= 0 and <= 65535." +`; + exports[`options validate should throw an error on the "port" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.port should be one of these: - number | non-empty string | \\"auto\\" + number (should be >= 0 and <= 65535) | non-empty string | \\"auto\\" -> Allows to specify a port to use. -> Read more at https://webpack.js.org/configuration/dev-server/#devserverport Details: - * options.port should be a number. + * options.port should be a number (should be >= 0 and <= 65535). * options.port should be a non-empty string. * options.port should be \\"auto\\"." `; @@ -532,11 +542,11 @@ exports[`options validate should throw an error on the "port" option with 'false exports[`options validate should throw an error on the "port" option with 'null' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.port should be one of these: - number | non-empty string | \\"auto\\" + number (should be >= 0 and <= 65535) | non-empty string | \\"auto\\" -> Allows to specify a port to use. -> Read more at https://webpack.js.org/configuration/dev-server/#devserverport Details: - * options.port should be a number. + * options.port should be a number (should be >= 0 and <= 65535). * options.port should be a non-empty string. * options.port should be \\"auto\\"." `; diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index becb276ac9..dd1a5f8e30 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -517,14 +517,24 @@ exports[`options validate should throw an error on the "port" option with '' val - options.port should be a non-empty string." `; +exports[`options validate should throw an error on the "port" option with '-1' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.port should be >= 0 and <= 65535." +`; + +exports[`options validate should throw an error on the "port" option with '65536' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.port should be >= 0 and <= 65535." +`; + exports[`options validate should throw an error on the "port" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.port should be one of these: - number | non-empty string | \\"auto\\" + number (should be >= 0 and <= 65535) | non-empty string | \\"auto\\" -> Allows to specify a port to use. -> Read more at https://webpack.js.org/configuration/dev-server/#devserverport Details: - * options.port should be a number. + * options.port should be a number (should be >= 0 and <= 65535). * options.port should be a non-empty string. * options.port should be \\"auto\\"." `; @@ -532,11 +542,11 @@ exports[`options validate should throw an error on the "port" option with 'false exports[`options validate should throw an error on the "port" option with 'null' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.port should be one of these: - number | non-empty string | \\"auto\\" + number (should be >= 0 and <= 65535) | non-empty string | \\"auto\\" -> Allows to specify a port to use. -> Read more at https://webpack.js.org/configuration/dev-server/#devserverport Details: - * options.port should be a number. + * options.port should be a number (should be >= 0 and <= 65535). * options.port should be a non-empty string. * options.port should be \\"auto\\"." `; diff --git a/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack4 b/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack4 deleted file mode 100644 index 38355f35b6..0000000000 --- a/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack4 +++ /dev/null @@ -1,265 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`host and port should work using "::" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "::" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "::" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and port as string: page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack5 b/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack5 deleted file mode 100644 index 38355f35b6..0000000000 --- a/test/e2e/__snapshots__/host-and-port.test.js.snap.webpack5 +++ /dev/null @@ -1,265 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`host and port should work using "::" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "::" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "::" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "::1" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "::1" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "0.0.0.0" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "127.0.0.1" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "127.0.0.1" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ip" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ip" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv4" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv4" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "local-ipv6" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "local-ipv6" host and port as string: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and "auto" port: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and "auto" port: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and port as number: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and port as number: page errors 1`] = `Array []`; - -exports[`host and port should work using "localhost" host and port as string: console messages 1`] = ` -Array [ - "[HMR] Waiting for update signal from WDS...", - "Hey.", - "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", -] -`; - -exports[`host and port should work using "localhost" host and port as string: page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/host.test.js.snap.webpack4 b/test/e2e/__snapshots__/host.test.js.snap.webpack4 new file mode 100644 index 0000000000..4902afc848 --- /dev/null +++ b/test/e2e/__snapshots__/host.test.js.snap.webpack4 @@ -0,0 +1,331 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`host should work using "::" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "::" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "::" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and port as string: page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/host.test.js.snap.webpack5 b/test/e2e/__snapshots__/host.test.js.snap.webpack5 new file mode 100644 index 0000000000..4902afc848 --- /dev/null +++ b/test/e2e/__snapshots__/host.test.js.snap.webpack5 @@ -0,0 +1,331 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`host should work using "::" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "::" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "::" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "::1" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "::1" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "0.0.0.0" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "127.0.0.1" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "127.0.0.1" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ip" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ip" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv4" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv4" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "local-ipv6" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "local-ipv6" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "localhost" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "localhost" host and port as string: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and "auto" port: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and "auto" port: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and port as number: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and port as number: page errors 1`] = `Array []`; + +exports[`host should work using "undefined" host and port as string: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`host should work using "undefined" host and port as string: page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/port.test.js.snap.webpack4 b/test/e2e/__snapshots__/port.test.js.snap.webpack4 new file mode 100644 index 0000000000..18b8c48fb8 --- /dev/null +++ b/test/e2e/__snapshots__/port.test.js.snap.webpack4 @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`port should work using "" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "" port : page errors 1`] = `Array []`; + +exports[`port should work using "0" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "0" port : page errors 1`] = `Array []`; + +exports[`port should work using "8161" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "8161" port : console messages 2`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "8161" port : page errors 1`] = `Array []`; + +exports[`port should work using "8161" port : page errors 2`] = `Array []`; + +exports[`port should work using "auto" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "auto" port : page errors 1`] = `Array []`; + +exports[`port should work using "undefined" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "undefined" port : page errors 1`] = `Array []`; diff --git a/test/e2e/__snapshots__/port.test.js.snap.webpack5 b/test/e2e/__snapshots__/port.test.js.snap.webpack5 new file mode 100644 index 0000000000..18b8c48fb8 --- /dev/null +++ b/test/e2e/__snapshots__/port.test.js.snap.webpack5 @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`port should work using "" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "" port : page errors 1`] = `Array []`; + +exports[`port should work using "0" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "0" port : page errors 1`] = `Array []`; + +exports[`port should work using "8161" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "8161" port : console messages 2`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "8161" port : page errors 1`] = `Array []`; + +exports[`port should work using "8161" port : page errors 2`] = `Array []`; + +exports[`port should work using "auto" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "auto" port : page errors 1`] = `Array []`; + +exports[`port should work using "undefined" port : console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hey.", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`port should work using "undefined" port : page errors 1`] = `Array []`; diff --git a/test/e2e/host-and-port.test.js b/test/e2e/host.test.js similarity index 74% rename from test/e2e/host-and-port.test.js rename to test/e2e/host.test.js index b5ebbea7e6..44d95ef781 100644 --- a/test/e2e/host-and-port.test.js +++ b/test/e2e/host.test.js @@ -5,15 +5,18 @@ const internalIp = require("internal-ip"); const Server = require("../../lib/Server"); const config = require("../fixtures/client-config/webpack.config"); const runBrowser = require("../helpers/run-browser"); -const port = require("../ports-map")["host-and-port"]; +const port = require("../ports-map").host; const ipv4 = internalIp.v4.sync(); const ipv6 = internalIp.v6.sync(); // macos requires root for using ip v6 const isMacOS = process.platform === "darwin"; -describe("host and port", () => { +describe("host", () => { const hosts = [ + "", + // eslint-disable-next-line no-undefined + undefined, "0.0.0.0", "::", "localhost", @@ -38,13 +41,24 @@ describe("host and port", () => { } } - const server = new Server({ host, port }, compiler); + const devServerOptions = { port }; + + if (host !== "") { + devServerOptions.host = host; + } + + const server = new Server(devServerOptions, compiler); let hostname = host; if (hostname === "0.0.0.0") { hostname = "127.0.0.1"; - } else if (hostname === "::" || hostname === "::1") { + } else if ( + hostname === "" || + typeof hostname === "undefined" || + hostname === "::" || + hostname === "::1" + ) { hostname = "[::1]"; } else if (hostname === "local-ip" || hostname === "local-ipv4") { hostname = ipv4; @@ -94,13 +108,24 @@ describe("host and port", () => { } } - const server = new Server({ host, port: `${port}` }, compiler); + const devServerOptions = { port: `${port}` }; + + if (host !== "") { + devServerOptions.host = host; + } + + const server = new Server(devServerOptions, compiler); let hostname = host; if (hostname === "0.0.0.0") { hostname = "127.0.0.1"; - } else if (hostname === "::" || hostname === "::1") { + } else if ( + hostname === "" || + typeof hostname === "undefined" || + hostname === "::" || + hostname === "::1" + ) { hostname = "[::1]"; } else if (hostname === "local-ip" || hostname === "local-ipv4") { hostname = ipv4; @@ -152,13 +177,24 @@ describe("host and port", () => { } } - const server = new Server({ host, port: "auto" }, compiler); + const devServerOptions = { port: "auto" }; + + if (host !== "") { + devServerOptions.host = host; + } + + const server = new Server(devServerOptions, compiler); let hostname = host; if (hostname === "0.0.0.0") { hostname = "127.0.0.1"; - } else if (hostname === "::" || hostname === "::1") { + } else if ( + hostname === "" || + typeof hostname === "undefined" || + hostname === "::" || + hostname === "::1" + ) { hostname = "[::1]"; } else if (hostname === "local-ip" || hostname === "local-ipv4") { hostname = ipv4; @@ -198,4 +234,15 @@ describe("host and port", () => { await server.stop(); }); } + + // TODO need test on error + // it(`should throw an error on invalid host`, async () => { + // const compiler = webpack(config); + // const server = new Server({ port, host: "unknown.unknown" }, compiler); + // const runDevServer = async () => { + // await server.start(); + // }; + // + // return expect(runDevServer()).toBeDefined(); + // }); }); diff --git a/test/e2e/port.test.js b/test/e2e/port.test.js new file mode 100644 index 0000000000..c0b74cbb08 --- /dev/null +++ b/test/e2e/port.test.js @@ -0,0 +1,107 @@ +"use strict"; + +const webpack = require("webpack"); +const Server = require("../../lib/Server"); +const config = require("../fixtures/client-config/webpack.config"); +const runBrowser = require("../helpers/run-browser"); +const port = require("../ports-map").port; + +describe("port", () => { + const ports = [ + "", + // eslint-disable-next-line no-undefined + undefined, + "auto", + port, + `${port}`, + 0, + "-1", + "99999", + ]; + + for (const testedPort of ports) { + it(`should work using "${testedPort}" port `, async () => { + const compiler = webpack(config); + const devServerOptions = {}; + + let usedPort; + + if ( + testedPort === "" || + typeof testedPort === "undefined" + ) { + process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; + usedPort = port; + } else if (testedPort === "auto") { + process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; + devServerOptions.port = testedPort; + usedPort = port; + } else { + devServerOptions.port = testedPort; + usedPort = testedPort; + } + + const server = new Server(devServerOptions, compiler); + + let errored; + + try { + await server.start(); + } catch (error) { + errored = error; + } + + if (testedPort === "-1" || testedPort === "99999") { + const errorMessageRegExp = new RegExp( + `options.port should be >= 0 and < 65536. Received ${testedPort}.` + ); + + expect(errored.message).toMatch(errorMessageRegExp); + + await server.stop(); + + return; + } + + const address = server.server.address(); + + if (testedPort === 0) { + expect(typeof address.port).toBe("number"); + } else { + expect(address.port).toBe(Number(usedPort)); + } + + const { page, browser } = await runBrowser(); + + const pageErrors = []; + const consoleMessages = []; + + page + .on("console", (message) => { + consoleMessages.push(message); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + await page.goto(`http://127.0.0.1:${address.port}/main`, { + waitUntil: "networkidle0", + }); + + expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( + "console messages" + ); + expect(pageErrors).toMatchSnapshot("page errors"); + + await browser.close(); + await server.stop(); + + if ( + testedPort === "" || + typeof testedPort === "undefined" + ) { + delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; + } + }); + } +}); diff --git a/test/ports-map.js b/test/ports-map.js index 8a30d151e4..198d26ac9a 100644 --- a/test/ports-map.js +++ b/test/ports-map.js @@ -68,10 +68,11 @@ const listOfTests = { target: 1, entry: 1, "allowed-hosts": 2, - "host-and-port": 1, + host: 1, api: 1, "lazy-compilation": 1, "range-header": 1, + port: 1, }; let startPort = 8089; diff --git a/test/server/host-option.test.js b/test/server/host-option.test.js deleted file mode 100644 index b06293a3c2..0000000000 --- a/test/server/host-option.test.js +++ /dev/null @@ -1,290 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("webpack"); -const request = require("supertest"); -const internalIp = require("internal-ip"); -const Server = require("../../lib/Server"); -const config = require("../fixtures/simple-config/webpack.config"); -const port = require("../ports-map")["host-option"]; - -const staticDirectory = path.resolve(__dirname, "../fixtures/static-config"); -const internalIPv4 = internalIp.v4.sync(); - -describe("host option", () => { - let server = null; - let req = null; - - describe("is not be specified", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is undefined", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - // eslint-disable-next-line no-undefined - host: undefined, - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is 127.0.0.1 (IPv4)", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - host: "127.0.0.1", - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("127.0.0.1"); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is localhost", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - host: "localhost", - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("127.0.0.1"); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is 0.0.0.0", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - host: "0.0.0.0", - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("0.0.0.0"); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is local-ip", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - host: "local-ip", - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe(internalIPv4); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); - - describe("is local-ipv4", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false, - }, - host: "local-ipv4", - port, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe(internalIPv4); - expect(address.port).toBe(port); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.status).toEqual(200); - }); - }); -}); diff --git a/test/server/port-option.test.js b/test/server/port-option.test.js deleted file mode 100644 index b3b55390f7..0000000000 --- a/test/server/port-option.test.js +++ /dev/null @@ -1,221 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("webpack"); -const request = require("supertest"); -const Server = require("../../lib/Server"); -const config = require("../fixtures/simple-config/webpack.config"); -const port = require("../ports-map")["port-option"]; - -const staticDirectory = path.resolve(__dirname, "../fixtures/static-config"); - -describe('"port" option', () => { - let server = null; - let req = null; - - describe("is not be specified", () => { - beforeAll(async () => { - const compiler = webpack(config); - - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 10020; - - server = new Server( - { - port, - static: { - directory: staticDirectory, - watch: false, - }, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - // Random port - expect(address.port).toBeDefined(); - }); - - it("then Request to index", async () => { - const response = await req.get("/"); - - expect(response.statusCode).toEqual(200); - }); - }); - - describe("is undefined", () => { - beforeAll(async () => { - const compiler = webpack(config); - - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 10030; - - server = new Server( - { - // eslint-disable-next-line no-undefined - port: undefined, - static: { - directory: staticDirectory, - watch: false, - }, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - // Random port - expect(address.port).toBeDefined(); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.statusCode).toEqual(200); - }); - }); - - describe("is auto", () => { - beforeAll(async () => { - const compiler = webpack(config); - - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 10040; - - server = new Server( - { - port: "auto", - static: { - directory: staticDirectory, - watch: false, - }, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - // Random port - expect(address.port).toBeDefined(); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.statusCode).toEqual(200); - }); - }); - - describe('is "33333"', () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - port: "33333", - static: { - directory: staticDirectory, - watch: false, - }, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - expect(address.port).toBe(33333); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.statusCode).toEqual(200); - }); - }); - - describe("is 33333", () => { - beforeAll(async () => { - const compiler = webpack(config); - - server = new Server( - { - port: 33333, - static: { - directory: staticDirectory, - watch: false, - }, - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterAll(async () => { - await server.stop(); - }); - - it("server address", () => { - const address = server.server.address(); - - expect(address.address).toBe("::"); - expect(address.port).toBe(33333); - }); - - it("Request to index", async () => { - const response = await req.get("/"); - - expect(response.statusCode).toEqual(200); - }); - }); -}); diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 1711c59e7d..829ed40e84 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -359,8 +359,8 @@ const tests = { failure: ["", { foo: "bar" }, { target: 90 }, { app: true }], }, port: { - success: ["20000", 20001, "auto"], - failure: [false, null, ""], + success: ["20000", 20001, "auto", 0, 1, 65535], + failure: [false, null, "", -1, 65536], }, proxy: { success: [