Skip to content

Commit 0aba203

Browse files
committed
feat: update labels for host.test.js
1 parent 73c7b04 commit 0aba203

File tree

1 file changed

+68
-64
lines changed

1 file changed

+68
-64
lines changed

test/e2e/host.test.js

+68-64
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function getAddress(host, hostname) {
3131
return { address };
3232
}
3333

34-
describe("host", { tag: "@flaky" }, () => {
34+
describe("host", { tag: ["@flaky", "@fails"] }, () => {
3535
const hosts = [
3636
"<not-specified>",
3737
// eslint-disable-next-line no-undefined
@@ -47,77 +47,81 @@ describe("host", { tag: "@flaky" }, () => {
4747
];
4848

4949
for (let host of hosts) {
50-
test(`should work using "${host}" host and port as number`, { tag: "@fails" }, async ({
51-
page,
52-
}) => {
53-
const compiler = webpack(config);
54-
55-
if (!ipv6 || isMacOS) {
56-
if (host === "::") {
57-
host = "127.0.0.1";
58-
} else if (host === "::1") {
59-
host = "127.0.0.1";
60-
} else if (host === "local-ipv6") {
61-
host = "127.0.0.1";
50+
test(
51+
`should work using "${host}" host and port as number`,
52+
{ tag: "@fails" },
53+
async ({ page }) => {
54+
const compiler = webpack(config);
55+
56+
if (!ipv6 || isMacOS) {
57+
if (host === "::") {
58+
host = "127.0.0.1";
59+
} else if (host === "::1") {
60+
host = "127.0.0.1";
61+
} else if (host === "local-ipv6") {
62+
host = "127.0.0.1";
63+
}
6264
}
63-
}
6465

65-
const devServerOptions = { port };
66+
const devServerOptions = { port };
6667

67-
if (host !== "<not-specified>") {
68-
devServerOptions.host = host;
69-
}
70-
71-
const server = new Server(devServerOptions, compiler);
68+
if (host !== "<not-specified>") {
69+
devServerOptions.host = host;
70+
}
7271

73-
let hostname = host;
72+
const server = new Server(devServerOptions, compiler);
73+
74+
let hostname = host;
75+
76+
if (hostname === "0.0.0.0") {
77+
hostname = "127.0.0.1";
78+
} else if (
79+
hostname === "<not-specified>" ||
80+
typeof hostname === "undefined" ||
81+
hostname === "::" ||
82+
hostname === "::1"
83+
) {
84+
hostname = "[::1]";
85+
} else if (hostname === "local-ip" || hostname === "local-ipv4") {
86+
hostname = ipv4;
87+
} else if (hostname === "local-ipv6") {
88+
hostname = `[${ipv6}]`;
89+
}
7490

75-
if (hostname === "0.0.0.0") {
76-
hostname = "127.0.0.1";
77-
} else if (
78-
hostname === "<not-specified>" ||
79-
typeof hostname === "undefined" ||
80-
hostname === "::" ||
81-
hostname === "::1"
82-
) {
83-
hostname = "[::1]";
84-
} else if (hostname === "local-ip" || hostname === "local-ipv4") {
85-
hostname = ipv4;
86-
} else if (hostname === "local-ipv6") {
87-
hostname = `[${ipv6}]`;
88-
}
91+
await server.start();
8992

90-
await server.start();
93+
expect(server.server.address()).toMatchObject(
94+
getAddress(host, hostname),
95+
);
9196

92-
expect(server.server.address()).toMatchObject(getAddress(host, hostname));
97+
try {
98+
const pageErrors = [];
99+
const consoleMessages = [];
93100

94-
try {
95-
const pageErrors = [];
96-
const consoleMessages = [];
101+
page
102+
.on("console", (message) => {
103+
consoleMessages.push(message);
104+
})
105+
.on("pageerror", (error) => {
106+
pageErrors.push(error);
107+
});
97108

98-
page
99-
.on("console", (message) => {
100-
consoleMessages.push(message);
101-
})
102-
.on("pageerror", (error) => {
103-
pageErrors.push(error);
109+
await page.goto(`http://${hostname}:${port}/`, {
110+
waitUntil: "networkidle0",
104111
});
105112

106-
await page.goto(`http://${hostname}:${port}/`, {
107-
waitUntil: "networkidle0",
108-
});
113+
expect(
114+
consoleMessages.map((message) => message.text()),
115+
).toMatchSnapshotWithArray();
109116

110-
expect(
111-
consoleMessages.map((message) => message.text()))
112-
.toMatchSnapshotWithArray();
113-
114-
expect(pageErrors).toMatchSnapshotWithArray();
115-
} catch (error) {
116-
throw error;
117-
} finally {
118-
await server.stop();
119-
}
120-
});
117+
expect(pageErrors).toMatchSnapshotWithArray();
118+
} catch (error) {
119+
throw error;
120+
} finally {
121+
await server.stop();
122+
}
123+
},
124+
);
121125

122126
test(`should work using "${host}" host and port as string`, async ({
123127
page,
@@ -180,8 +184,8 @@ describe("host", { tag: "@flaky" }, () => {
180184
});
181185

182186
expect(
183-
consoleMessages.map((message) => message.text()))
184-
.toMatchSnapshotWithArray();
187+
consoleMessages.map((message) => message.text()),
188+
).toMatchSnapshotWithArray();
185189

186190
expect(pageErrors).toMatchSnapshotWithArray();
187191
} catch (error) {
@@ -256,8 +260,8 @@ describe("host", { tag: "@flaky" }, () => {
256260
});
257261

258262
expect(
259-
consoleMessages.map((message) => message.text()))
260-
.toMatchSnapshotWithArray();
263+
consoleMessages.map((message) => message.text()),
264+
).toMatchSnapshotWithArray();
261265

262266
expect(pageErrors).toMatchSnapshotWithArray();
263267
} catch (error) {

0 commit comments

Comments
 (0)