Skip to content

Commit 4810909

Browse files
committed
fixup!
1 parent 78d3f88 commit 4810909

5 files changed

Lines changed: 39 additions & 43 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/__snapshots__/api.test.js.snap.webpack5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exports[`API > Invalidate callback > should use the provided \`callback\` functi
3131
`;
3232

3333
exports[`API > Server.checkHostHeader > should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object 1`] = `
34-
"ws://test.host:8156/ws"
34+
"ws://test.host:8157/ws"
3535
`;
3636

3737
exports[`API > Server.checkHostHeader > should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object 2`] = `
@@ -43,7 +43,7 @@ exports[`API > Server.checkHostHeader > should allow URLs with scheme for checki
4343
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
4444
"[HMR] Waiting for update signal from WDS...",
4545
"Hey.",
46-
"WebSocket connection to 'ws://test.host:8156/ws' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED",
46+
"WebSocket connection to 'ws://test.host:8157/ws' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED",
4747
"[webpack-dev-server] JSHandle@object",
4848
"[webpack-dev-server] Disconnected!",
4949
"[webpack-dev-server] Trying to reconnect...",

test/e2e/__snapshots__/client-reconnect.test.js.snap.webpack5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ exports[`client.reconnect option > specified as number > should try to reconnect
2626
"Hey.",
2727
"[webpack-dev-server] Disconnected!",
2828
"[webpack-dev-server] Trying to reconnect...",
29-
"WebSocket connection to 'ws://localhost:8161/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED",
29+
"WebSocket connection to 'ws://localhost:8162/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED",
3030
"[webpack-dev-server] JSHandle@object",
3131
"[webpack-dev-server] Trying to reconnect...",
32-
"WebSocket connection to 'ws://localhost:8161/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED",
32+
"WebSocket connection to 'ws://localhost:8162/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED",
3333
"[webpack-dev-server] JSHandle@object",
3434
]
3535
`;

test/e2e/__snapshots__/port.test.js.snap.webpack5

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ exports[`port > should work using "0" port 2`] = `
1010
[]
1111
`;
1212

13-
exports[`port > should work using "8159" port 1`] = `
13+
exports[`port > should work using "8160" port 1`] = `
1414
[
1515
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
1616
"[HMR] Waiting for update signal from WDS...",
1717
"Hey.",
1818
]
1919
`;
2020

21-
exports[`port > should work using "8159" port 2`] = `
21+
exports[`port > should work using "8160" port 2`] = `
2222
[]
2323
`;
2424

25-
exports[`port > should work using "8159" port 3`] = `
25+
exports[`port > should work using "8160" port 3`] = `
2626
[
2727
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
2828
"[HMR] Waiting for update signal from WDS...",
2929
"Hey.",
3030
]
3131
`;
3232

33-
exports[`port > should work using "8159" port 4`] = `
33+
exports[`port > should work using "8160" port 4`] = `
3434
[]
3535
`;
3636

test/server/proxy-option.test.js

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ describe("proxy option", () => {
618618

619619
const BACKEND_MESSAGE_TYPE = "backend-message";
620620

621-
beforeAll(async () => {
621+
before(async () => {
622622
backendUpgradeCount = 0;
623623

624624
backend = http.createServer();
@@ -654,7 +654,7 @@ describe("proxy option", () => {
654654
await server.start();
655655
});
656656

657-
afterAll(async () => {
657+
after(async () => {
658658
for (const client of backendWss.clients) {
659659
client.terminate();
660660
}
@@ -716,10 +716,8 @@ describe("proxy option", () => {
716716
let backend;
717717
let stderrSpy;
718718

719-
beforeAll(async () => {
720-
stderrSpy = jest
721-
.spyOn(process.stderr, "write")
722-
.mockImplementation(() => true);
719+
before(async () => {
720+
stderrSpy = spyOn(process.stderr, "write").mockImplementation(() => true);
723721

724722
backend = http.createServer();
725723
backend.on("upgrade", (req, socket) => {
@@ -751,7 +749,7 @@ describe("proxy option", () => {
751749
await server.start();
752750
});
753751

754-
afterAll(async () => {
752+
after(async () => {
755753
stderrSpy.mockRestore();
756754
backend.closeAllConnections();
757755
await server.stop();
@@ -897,22 +895,16 @@ describe("proxy option", () => {
897895

898896
// Behavior shared by every WebSocket server implementation: the HMR socket
899897
// is served locally and never forwarded, while any path the HMR server does
900-
// not own falls through to the user proxy. SockJS serves its transport under
901-
// `/<prefix>/<server>/<session>/websocket`, not the bare `/ws`.
898+
// not own falls through to the user proxy.
902899
const serverTypes = [
903900
{ type: "ws", hmrPath: "/ws", nonHmrPath: "/not-hmr" },
904-
{
905-
type: "sockjs",
906-
hmrPath: "/ws/000/abcd1234/websocket",
907-
nonHmrPath: "/not-hmr",
908-
},
909901
];
910902

911903
for (const { type, hmrPath, nonHmrPath } of serverTypes) {
912904
describe(`with webSocketServerType: ${type}`, () => {
913-
beforeAll(() => setup({ webSocketServer: type }));
905+
before(() => setup({ webSocketServer: type }));
914906

915-
afterAll(teardown);
907+
after(teardown);
916908

917909
it("serves the HMR upgrade locally and does not forward it to the proxy", async () => {
918910
const { opened, forwarded } = await probe(hmrPath);
@@ -933,42 +925,46 @@ describe("proxy option", () => {
933925
// `WebSocketServer#shouldHandle` does, so only the configured path (query
934926
// stripped) is the HMR socket; every other variant is forwarded.
935927
describe("with the `ws` server, path matching is exact", () => {
936-
beforeAll(() => setup({ webSocketServer: "ws" }));
928+
before(() => setup({ webSocketServer: "ws" }));
937929

938-
afterAll(teardown);
930+
after(teardown);
939931

940-
it.each([
932+
for (const [label, path] of [
941933
["exact path", "/ws"],
942934
["path with query string", "/ws?token=1"],
943-
])("treats %s (%s) as the HMR upgrade path", async (_label, path) => {
944-
const { forwarded } = await probe(path);
935+
]) {
936+
it(`treats ${label} (${path}) as the HMR upgrade path`, async () => {
937+
const { forwarded } = await probe(path);
945938

946-
expect(forwarded).toBe(false);
947-
});
939+
expect(forwarded).toBe(false);
940+
});
941+
}
948942

949-
it.each([
943+
for (const [label, path] of [
950944
["leading double slash", "//ws"],
951945
["trailing slash", "/ws/"],
952946
["uppercase", "/WS"],
953947
["mixed case", "/wS"],
954948
["percent-encoded path", "/%77%73"],
955-
])("forwards %s (%s) to the user proxy", async (_label, path) => {
956-
const { forwarded } = await probe(path);
949+
]) {
950+
it(`forwards ${label} (${path}) to the user proxy`, async () => {
951+
const { forwarded } = await probe(path);
957952

958-
expect(forwarded).toBe(true);
959-
});
953+
expect(forwarded).toBe(true);
954+
});
955+
}
960956
});
961957

962958
// The HMR path is read from the configured `webSocketServer` options, not a
963959
// hardcoded `/ws`.
964960
describe("with a custom `ws` path", () => {
965-
beforeAll(() =>
961+
before(() =>
966962
setup({
967963
webSocketServer: { type: "ws", options: { path: "/custom-hmr" } },
968964
}),
969965
);
970966

971-
afterAll(teardown);
967+
after(teardown);
972968

973969
it("treats the configured path (/custom-hmr) as the HMR upgrade path", async () => {
974970
const { forwarded } = await probe("/custom-hmr");
@@ -986,11 +982,11 @@ describe("proxy option", () => {
986982
// With no HMR server there is no socket to protect, so the filter never
987983
// engages and even `/ws` is forwarded to the user proxy.
988984
describe("without a webSocketServer", () => {
989-
beforeAll(() =>
985+
before(() =>
990986
setup({ hot: false, liveReload: false, webSocketServer: false }),
991987
);
992988

993-
afterAll(teardown);
989+
after(teardown);
994990

995991
it("forwards /ws to the user proxy because there is no HMR socket to protect", async () => {
996992
const { forwarded } = await probe("/ws");

0 commit comments

Comments
 (0)