Skip to content

Commit

Permalink
test: fix stability (#3676)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Aug 18, 2021
1 parent cdcabb2 commit 18bf369
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
3 changes: 1 addition & 2 deletions test/cli/__snapshots__/bonjour-option.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"bonjour" CLI option should work using "--bonjour and --https" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
3 changes: 1 addition & 2 deletions test/cli/__snapshots__/bonjour-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"bonjour" CLI option should work using "--bonjour and --https" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
3 changes: 1 addition & 2 deletions test/cli/__snapshots__/http2-option.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"http2" CLI option should work using "--http2" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
3 changes: 1 addition & 2 deletions test/cli/__snapshots__/http2-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"http2" CLI option should work using "--http2" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
9 changes: 3 additions & 6 deletions test/cli/__snapshots__/https-option.test.js.snap.webpack4
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"https" CLI option should work using "--https" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand All @@ -27,8 +26,7 @@ exports[`"https" CLI option should work using "--https-key <path> --https-pfx <p
`;

exports[`"https" CLI option should work using "--https-request-cert" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand All @@ -45,8 +43,7 @@ exports[`"https" CLI option should work using "--no-https" 1`] = `
`;

exports[`"https" CLI option should work using "--no-https-request-cert" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
9 changes: 3 additions & 6 deletions test/cli/__snapshots__/https-option.test.js.snap.webpack5
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`"https" CLI option should work using "--https" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand All @@ -27,8 +26,7 @@ exports[`"https" CLI option should work using "--https-key <path> --https-pfx <p
`;

exports[`"https" CLI option should work using "--https-request-cert" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand All @@ -45,8 +43,7 @@ exports[`"https" CLI option should work using "--no-https" 1`] = `
`;

exports[`"https" CLI option should work using "--no-https-request-cert" 1`] = `
"<i> [webpack-dev-server] Generating SSL Certificate...
<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
"<i> [webpack-dev-server] SSL certificate: <cwd>/node_modules/.cache/webpack-dev-server/server.pem
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): https://<ip-v4>:<port>/
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/test-bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ const normalizeStderr = (stderr, options = {}) => {
if (options.https) {
// We have deprecation warning on windows in some cases
normalizedStderr = normalizedStderr.split("\n");
normalizedStderr = normalizedStderr.filter(
(item) => !/Generating SSL Certificate/g.test(item)
);
normalizedStderr = normalizedStderr.filter(
(item) =>
!/DeprecationWarning: The legacy HTTP parser is deprecated/g.test(item)
Expand Down
24 changes: 17 additions & 7 deletions test/server/setupExitSignals-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const port = require("../ports-map")["setup-exit-signals-option"];

describe("setupExitSignals option", () => {
let server;
let doExit;
let exitSpy;
let stopCallbackSpy;
let stdinResumeSpy;
Expand All @@ -26,7 +27,11 @@ describe("setupExitSignals option", () => {

await server.start();

exitSpy = jest.spyOn(process, "exit").mockImplementation(() => {});
doExit = false;

exitSpy = jest.spyOn(process, "exit").mockImplementation(() => {
doExit = true;
});
stdinResumeSpy = jest
.spyOn(process.stdin, "resume")
.mockImplementation(() => {});
Expand All @@ -44,14 +49,19 @@ describe("setupExitSignals option", () => {
await server.stop();
});

it.each(signals)("should close and exit on %s", (signal, done) => {
it.each(signals)("should close and exit on %s", async (signal) => {
process.emit(signal);

setTimeout(() => {
expect(stopCallbackSpy.mock.calls.length).toEqual(1);
expect(exitSpy.mock.calls.length).toEqual(1);
await new Promise((resolve) => {
const interval = setInterval(() => {
if (doExit) {
expect(stopCallbackSpy.mock.calls.length).toEqual(1);

done();
}, 1000);
clearInterval(interval);

resolve();
}
}, 100);
});
});
});

0 comments on commit 18bf369

Please sign in to comment.