From 748eb25c10daec4208f4bae14e49804874525879 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 24 Mar 2021 10:34:42 +0530 Subject: [PATCH 1/4] chore: make client overlay default to be true --- lib/utils/normalizeOptions.js | 5 +++++ package-lock.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/utils/normalizeOptions.js b/lib/utils/normalizeOptions.js index 3534947759..9706911c91 100644 --- a/lib/utils/normalizeOptions.js +++ b/lib/utils/normalizeOptions.js @@ -98,6 +98,11 @@ function normalizeOptions(compiler, options) { options.client = {}; } + // Enable client overlay by default + if (typeof options.client.overlay === 'undefined') { + options.client.overlay = true; + } + options.client.path = `/${ options.client.path ? options.client.path.replace(/^\/|\/$/g, '') : 'ws' }`; diff --git a/package-lock.json b/package-lock.json index 1dfbc59d94..b0c835fbae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "requires": true, "packages": { "": { - "version": "4.0.0-beta.0", + "version": "4.0.0-beta.1", "license": "MIT", "dependencies": { "ansi-html": "^0.0.7", From 924f975dd05b33edc3b09dbab61bafe3fce851b9 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 24 Mar 2021 10:56:31 +0530 Subject: [PATCH 2/4] test: defaults for overlay --- .../__snapshots__/TransportMode.test.js.snap | 1 + test/server/clientOptions-option.test.js | 4 ++ .../normalizeOptions.test.js.snap | 37 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/test/e2e/__snapshots__/TransportMode.test.js.snap b/test/e2e/__snapshots__/TransportMode.test.js.snap index a353f22048..141e201c4e 100644 --- a/test/e2e/__snapshots__/TransportMode.test.js.snap +++ b/test/e2e/__snapshots__/TransportMode.test.js.snap @@ -6,6 +6,7 @@ Array [ "open", "liveReload", "[webpack-dev-server] Live Reloading enabled.", + "overlay", "hash", "ok", "close", diff --git a/test/server/clientOptions-option.test.js b/test/server/clientOptions-option.test.js index ecc12a3771..0c49408493 100644 --- a/test/server/clientOptions-option.test.js +++ b/test/server/clientOptions-option.test.js @@ -34,6 +34,10 @@ describe('client option', () => { ).toBeTruthy(); }); + it ('overlay true by default', () => { + expect(server.options.client.overlay).toBe(true); + }) + it('responds with a 200', (done) => { req.get('/ws').expect(200, done); }); diff --git a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap index 3a0b3d6f6f..629ddb411d 100644 --- a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap +++ b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap @@ -4,6 +4,7 @@ exports[`normalizeOptions client host and port should set correct options 1`] = Object { "client": Object { "host": "my.host", + "overlay": true, "path": "/ws", "port": 9000, }, @@ -35,6 +36,7 @@ Object { exports[`normalizeOptions client path should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/custom/path", }, "dev": Object {}, @@ -65,6 +67,7 @@ Object { exports[`normalizeOptions client path without leading/ending slashes should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/custom/path", }, "dev": Object {}, @@ -95,6 +98,7 @@ Object { exports[`normalizeOptions dev is set should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object { @@ -127,6 +131,7 @@ Object { exports[`normalizeOptions firewall is set should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -157,6 +162,7 @@ Object { exports[`normalizeOptions hot is false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -187,6 +193,7 @@ Object { exports[`normalizeOptions hot is only should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -217,6 +224,7 @@ Object { exports[`normalizeOptions hot is true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -247,6 +255,7 @@ Object { exports[`normalizeOptions liveReload is false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -277,6 +286,7 @@ Object { exports[`normalizeOptions liveReload is true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -307,6 +317,7 @@ Object { exports[`normalizeOptions multi compiler watchOptions is set should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -339,6 +350,7 @@ Object { exports[`normalizeOptions no options should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -369,6 +381,7 @@ Object { exports[`normalizeOptions single compiler watchOptions is object should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -401,6 +414,7 @@ Object { exports[`normalizeOptions single compiler watchOptions is object with static watch overriding it should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -433,6 +447,7 @@ Object { exports[`normalizeOptions single compiler watchOptions is object with static watch true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -465,6 +480,7 @@ Object { exports[`normalizeOptions single compiler watchOptions is object with watch false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -495,6 +511,7 @@ Object { exports[`normalizeOptions static is an array of static objects should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -536,6 +553,7 @@ Object { exports[`normalizeOptions static is an array of strings and static objects should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -577,6 +595,7 @@ Object { exports[`normalizeOptions static is an array of strings should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -618,6 +637,7 @@ Object { exports[`normalizeOptions static is an object should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -648,6 +668,7 @@ Object { exports[`normalizeOptions static is false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -666,6 +687,7 @@ Object { exports[`normalizeOptions static is string should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -696,6 +718,7 @@ Object { exports[`normalizeOptions static is true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -726,6 +749,7 @@ Object { exports[`normalizeOptions static publicPath is a string should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -756,6 +780,7 @@ Object { exports[`normalizeOptions static publicPath is an array should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -787,6 +812,7 @@ Object { exports[`normalizeOptions static serveIndex is an object should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -817,6 +843,7 @@ Object { exports[`normalizeOptions static serveIndex is false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -845,6 +872,7 @@ Object { exports[`normalizeOptions static serveIndex is true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -875,6 +903,7 @@ Object { exports[`normalizeOptions static watch is an object should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -907,6 +936,7 @@ Object { exports[`normalizeOptions static watch is false should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -937,6 +967,7 @@ Object { exports[`normalizeOptions static watch is true should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -967,6 +998,7 @@ Object { exports[`normalizeOptions transportMode custom client path should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -997,6 +1029,7 @@ Object { exports[`normalizeOptions transportMode custom server class should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -1027,6 +1060,7 @@ Object { exports[`normalizeOptions transportMode custom server path should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -1057,6 +1091,7 @@ Object { exports[`normalizeOptions transportMode sockjs string should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -1087,6 +1122,7 @@ Object { exports[`normalizeOptions transportMode ws object should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, @@ -1117,6 +1153,7 @@ Object { exports[`normalizeOptions transportMode ws string should set correct options 1`] = ` Object { "client": Object { + "overlay": true, "path": "/ws", }, "dev": Object {}, From cda0df8a881b64e9c052f993d0a7a833b7277223 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 24 Mar 2021 11:17:41 +0530 Subject: [PATCH 3/4] chore: lint files --- test/server/clientOptions-option.test.js | 2 +- test/server/transportMode-option.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/server/clientOptions-option.test.js b/test/server/clientOptions-option.test.js index 0c49408493..a9b7de93eb 100644 --- a/test/server/clientOptions-option.test.js +++ b/test/server/clientOptions-option.test.js @@ -34,7 +34,7 @@ describe('client option', () => { ).toBeTruthy(); }); - it ('overlay true by default', () => { + it('overlay true by default', () => { expect(server.options.client.overlay).toBe(true); }) diff --git a/test/server/transportMode-option.test.js b/test/server/transportMode-option.test.js index eff136c60c..3d15d938f4 100644 --- a/test/server/transportMode-option.test.js +++ b/test/server/transportMode-option.test.js @@ -482,7 +482,7 @@ describe('transportMode', () => { expect(MockWebsocketServer.mock.calls[0][0].options.port).toEqual(port); expect(mockServerInstance.onConnection.mock.calls).toMatchSnapshot(); - expect(mockServerInstance.send.mock.calls.length).toEqual(4); + expect(mockServerInstance.send.mock.calls.length).toEqual(5); // call 0 to the send() method is hot expect(mockServerInstance.send.mock.calls[0]).toMatchSnapshot(); // call 1 to the send() method is liveReload From 3910e37c9e6f56a1a77939da5f291be9cd48c8c5 Mon Sep 17 00:00:00 2001 From: Rishabh Chawla Date: Wed, 24 Mar 2021 11:35:16 +0530 Subject: [PATCH 4/4] chore: update snapshots --- test/server/__snapshots__/transportMode-option.test.js.snap | 2 +- test/server/clientOptions-option.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/server/__snapshots__/transportMode-option.test.js.snap b/test/server/__snapshots__/transportMode-option.test.js.snap index cb0a1037ca..cfedaa88dc 100644 --- a/test/server/__snapshots__/transportMode-option.test.js.snap +++ b/test/server/__snapshots__/transportMode-option.test.js.snap @@ -105,7 +105,7 @@ Array [ Object { "foo": "bar", }, - "{\\"type\\":\\"ok\\"}", + "{\\"type\\":\\"hash\\",\\"data\\":\\"e2e9c089dba8a484b550\\"}", ] `; diff --git a/test/server/clientOptions-option.test.js b/test/server/clientOptions-option.test.js index a9b7de93eb..8debb1ce3b 100644 --- a/test/server/clientOptions-option.test.js +++ b/test/server/clientOptions-option.test.js @@ -36,7 +36,7 @@ describe('client option', () => { it('overlay true by default', () => { expect(server.options.client.overlay).toBe(true); - }) + }); it('responds with a 200', (done) => { req.get('/ws').expect(200, done);