Skip to content

Commit

Permalink
test: fix todo (#3713)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Aug 23, 2021
1 parent 7c4ab53 commit 4eb1ab8
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 7 deletions.
99 changes: 99 additions & 0 deletions test/e2e/__snapshots__/host-and-port.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
// 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...",
Expand Down Expand Up @@ -132,6 +198,39 @@ Array [

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...",
Expand Down
99 changes: 99 additions & 0 deletions test/e2e/__snapshots__/host-and-port.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
// 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...",
Expand Down Expand Up @@ -132,6 +198,39 @@ Array [

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...",
Expand Down
71 changes: 64 additions & 7 deletions test/e2e/host-and-port.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,49 @@ const config = require("../fixtures/client-config/webpack.config");
const runBrowser = require("../helpers/run-browser");
const port = require("../ports-map")["host-and-port"];

describe("host and port", () => {
// TODO: add "local-ipv6"
const hosts = ["0.0.0.0", "localhost", "127.0.0.1", "local-ip", "local-ipv4"];
const ipv4 = internalIp.v4.sync();
const ipv6 = internalIp.v6.sync();
// macos requires root for using ip v6
const isMacOS = process.platform === "darwin";

for (const host of hosts) {
describe("host and port", () => {
const hosts = [
"0.0.0.0",
"::",
"localhost",
"::1",
"127.0.0.1",
"local-ip",
"local-ipv4",
"local-ipv6",
];

for (let host of hosts) {
it(`should work using "${host}" host and port as number`, async () => {
const compiler = webpack(config);

if (!ipv6 || isMacOS) {
if (host === "::") {
host = "127.0.0.1";
} else if (host === "::1") {
host = "127.0.0.1";
} else if (host === "local-ipv6") {
host = "127.0.0.1";
}
}

const server = new Server({ host, port }, compiler);

let hostname = host;

if (hostname === "0.0.0.0") {
hostname = "127.0.0.1";
} else if (hostname === "::" || hostname === "::1") {
hostname = "[::1]";
} else if (hostname === "local-ip" || hostname === "local-ipv4") {
hostname = internalIp.v4.sync();
hostname = ipv4;
} else if (hostname === "local-ipv6") {
hostname = `[${ipv6}]`;
}

await server.start();
Expand Down Expand Up @@ -55,14 +83,29 @@ describe("host and port", () => {

it(`should work using "${host}" host and port as string`, async () => {
const compiler = webpack(config);

if (!ipv6 || isMacOS) {
if (host === "::") {
host = "127.0.0.1";
} else if (host === "::1") {
host = "127.0.0.1";
} else if (host === "local-ipv6") {
host = "127.0.0.1";
}
}

const server = new Server({ host, port: `${port}` }, compiler);

let hostname = host;

if (hostname === "0.0.0.0") {
hostname = "127.0.0.1";
} else if (hostname === "::" || hostname === "::1") {
hostname = "[::1]";
} else if (hostname === "local-ip" || hostname === "local-ipv4") {
hostname = internalIp.v4.sync();
hostname = ipv4;
} else if (hostname === "local-ipv6") {
hostname = `[${ipv6}]`;
}

await server.start();
Expand Down Expand Up @@ -99,14 +142,28 @@ describe("host and port", () => {

process.env.WEBPACK_DEV_SERVER_BASE_PORT = port;

if (!ipv6 || isMacOS) {
if (host === "::") {
host = "127.0.0.1";
} else if (host === "::1") {
host = "127.0.0.1";
} else if (host === "local-ipv6") {
host = "127.0.0.1";
}
}

const server = new Server({ host, port: "auto" }, compiler);

let hostname = host;

if (hostname === "0.0.0.0") {
hostname = "127.0.0.1";
} else if (hostname === "::" || hostname === "::1") {
hostname = "[::1]";
} else if (hostname === "local-ip" || hostname === "local-ipv4") {
hostname = internalIp.v4.sync();
hostname = ipv4;
} else if (hostname === "local-ipv6") {
hostname = `[${ipv6}]`;
}

await server.start();
Expand Down

0 comments on commit 4eb1ab8

Please sign in to comment.