Skip to content

Commit 734f8c3

Browse files
test: stability (#3599)
1 parent f663deb commit 734f8c3

File tree

6 files changed

+28
-86
lines changed

6 files changed

+28
-86
lines changed

test/cli/basic.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ describe("basic", () => {
181181

182182
let killed = false;
183183

184+
cp.on("error", (error) => {
185+
done(error);
186+
});
187+
188+
cp.stdin.on("error", (error) => {
189+
done(error);
190+
});
191+
184192
cp.stdout.on("data", () => {
185193
if (!killed) {
186194
expect(cp.pid !== 0).toBe(true);

test/e2e/__snapshots__/host-and-port.test.js.snap.webpack4

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`host and port should work using "0.0.0.0" host and "auto" port: console messages 1`] = `
4-
Array [
5-
"[HMR] Waiting for update signal from WDS...",
6-
"Hey.",
7-
"[webpack-dev-server] Hot Module Replacement enabled.",
8-
"[webpack-dev-server] Live Reloading enabled.",
9-
]
10-
`;
11-
12-
exports[`host and port should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`;
13-
14-
exports[`host and port should work using "0.0.0.0" host and port as number: console messages 1`] = `
15-
Array [
16-
"[HMR] Waiting for update signal from WDS...",
17-
"Hey.",
18-
"[webpack-dev-server] Hot Module Replacement enabled.",
19-
"[webpack-dev-server] Live Reloading enabled.",
20-
]
21-
`;
22-
23-
exports[`host and port should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`;
24-
25-
exports[`host and port should work using "0.0.0.0" host and port as string: console messages 1`] = `
26-
Array [
27-
"[HMR] Waiting for update signal from WDS...",
28-
"Hey.",
29-
"[webpack-dev-server] Hot Module Replacement enabled.",
30-
"[webpack-dev-server] Live Reloading enabled.",
31-
]
32-
`;
33-
34-
exports[`host and port should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`;
35-
363
exports[`host and port should work using "127.0.0.1" host and "auto" port: console messages 1`] = `
374
Array [
385
"[HMR] Waiting for update signal from WDS...",

test/e2e/__snapshots__/host-and-port.test.js.snap.webpack5

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`host and port should work using "0.0.0.0" host and "auto" port: console messages 1`] = `
4-
Array [
5-
"[HMR] Waiting for update signal from WDS...",
6-
"Hey.",
7-
"[webpack-dev-server] Hot Module Replacement enabled.",
8-
"[webpack-dev-server] Live Reloading enabled.",
9-
]
10-
`;
11-
12-
exports[`host and port should work using "0.0.0.0" host and "auto" port: page errors 1`] = `Array []`;
13-
14-
exports[`host and port should work using "0.0.0.0" host and port as number: console messages 1`] = `
15-
Array [
16-
"[HMR] Waiting for update signal from WDS...",
17-
"Hey.",
18-
"[webpack-dev-server] Hot Module Replacement enabled.",
19-
"[webpack-dev-server] Live Reloading enabled.",
20-
]
21-
`;
22-
23-
exports[`host and port should work using "0.0.0.0" host and port as number: page errors 1`] = `Array []`;
24-
25-
exports[`host and port should work using "0.0.0.0" host and port as string: console messages 1`] = `
26-
Array [
27-
"[HMR] Waiting for update signal from WDS...",
28-
"Hey.",
29-
"[webpack-dev-server] Hot Module Replacement enabled.",
30-
"[webpack-dev-server] Live Reloading enabled.",
31-
]
32-
`;
33-
34-
exports[`host and port should work using "0.0.0.0" host and port as string: page errors 1`] = `Array []`;
35-
363
exports[`host and port should work using "127.0.0.1" host and "auto" port: console messages 1`] = `
374
Array [
385
"[HMR] Waiting for update signal from WDS...",

test/e2e/host-and-port.test.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ const runBrowser = require("../helpers/run-browser");
88
const port = require("../ports-map")["host-and-port"];
99

1010
describe("host and port", () => {
11-
// TODO: add local-ipv6
12-
const hosts = ["0.0.0.0", "localhost", "127.0.0.1", "local-ip", "local-ipv4"];
11+
// TODO: add "0.0.0.0" and "local-ipv6"
12+
const hosts = ["localhost", "127.0.0.1", "local-ip", "local-ipv4"];
1313

1414
for (const host of hosts) {
1515
it(`should work using "${host}" host and port as number`, async () => {
1616
const compiler = webpack(config);
17-
const devServerOptions = {
18-
host,
19-
port,
20-
};
21-
const server = new Server(devServerOptions, compiler);
17+
const server = new Server({ host, port }, compiler);
2218

2319
let hostname = host;
2420

@@ -77,11 +73,7 @@ describe("host and port", () => {
7773

7874
it(`should work using "${host}" host and port as string`, async () => {
7975
const compiler = webpack(config);
80-
const devServerOptions = {
81-
host,
82-
port: `${port}`,
83-
};
84-
const server = new Server(devServerOptions, compiler);
76+
const server = new Server({ host, port: `${port}` }, compiler);
8577

8678
let hostname = host;
8779

@@ -140,11 +132,10 @@ describe("host and port", () => {
140132

141133
it(`should work using "${host}" host and "auto" port`, async () => {
142134
const compiler = webpack(config);
143-
const devServerOptions = {
144-
host,
145-
port: "auto",
146-
};
147-
const server = new Server(devServerOptions, compiler);
135+
136+
process.env.WEBPACK_DEV_SERVER_BASE_PORT = port;
137+
138+
const server = new Server({ host, port: "auto" }, compiler);
148139

149140
let hostname = host;
150141

@@ -188,6 +179,8 @@ describe("host and port", () => {
188179

189180
expect(pageErrors).toMatchSnapshot("page errors");
190181

182+
delete process.env.WEBPACK_DEV_SERVER_BASE_PORT;
183+
191184
await browser.close();
192185
await new Promise((resolve, reject) => {
193186
server.close((error) => {

test/e2e/hot-and-live-reload.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,16 @@ describe("hot and live reload", () => {
425425
const pageErrors = [];
426426

427427
let doneHotUpdate = false;
428+
let hasDisconnectedMessage = false;
428429

429430
page
430431
.on("console", (message) => {
431-
consoleMessages.push(message.text());
432+
if (!hasDisconnectedMessage) {
433+
const text = message.text();
434+
435+
hasDisconnectedMessage = /Disconnected!/.test(text);
436+
consoleMessages.push(text);
437+
}
432438
})
433439
.on("pageerror", (error) => {
434440
pageErrors.push(error);

test/helpers/test-bin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ const normalizeStderr = (stderr, options = {}) => {
8282
normalizedStderr = normalizedStderr.filter(
8383
(item) => !/.+wait until bundle finished.*(\n)?/g.test(item)
8484
);
85-
8685
normalizedStderr = normalizedStderr.join("\n");
87-
8886
normalizedStderr = normalizedStderr.replace(/:[0-9]+\//g, ":<port>/");
8987

9088
if (options.https) {
9189
// We have deprecation warning on windows in some cases
9290
normalizedStderr = normalizedStderr.split("\n");
91+
normalizedStderr = normalizedStderr.filter(
92+
(item) => !/Generating SSL Certificate/g.test(item)
93+
);
9394
normalizedStderr = normalizedStderr.filter(
9495
(item) =>
9596
!/DeprecationWarning: The legacy HTTP parser is deprecated/g.test(item)

0 commit comments

Comments
 (0)