From 2c465149f833dde8ef7b63f099e619973364f45e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 10 Dec 2021 15:27:37 +0530 Subject: [PATCH 1/3] fix: update `listen` and `close` deprecation warning message --- lib/Server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index baf8502445..8401dba91d 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -2404,7 +2404,7 @@ class Server { listen(port, hostname, fn) { util.deprecate( () => {}, - "'listen' is deprecated. Please use async 'start' or 'startCallback' methods.", + "'listen' is deprecated. Please use the async 'start' or 'startCallback' method.", "DEP_WEBPACK_DEV_SERVER_LISTEN" )(); @@ -2464,7 +2464,7 @@ class Server { close(callback) { util.deprecate( () => {}, - "'close' is deprecated. Please use async 'stop' or 'stopCallback' methods.", + "'close' is deprecated. Please use the async 'stop' or 'stopCallback' method.", "DEP_WEBPACK_DEV_SERVER_CLOSE" )(); From a815f057d526e5093c04a42120ad6f383a9522e9 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 10 Dec 2021 17:01:34 +0530 Subject: [PATCH 2/3] test: add snapshots --- test/e2e/__snapshots__/api.test.js.snap.webpack5 | 8 +++++--- test/e2e/api.test.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/e2e/__snapshots__/api.test.js.snap.webpack5 b/test/e2e/__snapshots__/api.test.js.snap.webpack5 index 4192afa46f..092e5ef6e8 100644 --- a/test/e2e/__snapshots__/api.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/api.test.js.snap.webpack5 @@ -55,7 +55,9 @@ Array [ exports[`API should work with callback API: page errors 1`] = `Array []`; -exports[`API should work with deprecated API ('listen' and \`close\` methods): console messages 1`] = ` +exports[`API should work with deprecated API ('listen' and 'close' methods): close deprecation log 1`] = `"'close' is deprecated. Please use the async 'stop' or 'stopCallback' method."`; + +exports[`API should work with deprecated API ('listen' and 'close' methods): console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "Hey.", @@ -64,9 +66,9 @@ Array [ ] `; -exports[`API should work with deprecated API ('listen' and \`close\` methods): deprecation log 1`] = `"'listen' is deprecated. Please use async 'start' or 'startCallback' methods."`; +exports[`API should work with deprecated API ('listen' and 'close' methods): listen deprecation log 1`] = `"'listen' is deprecated. Please use the async 'start' or 'startCallback' method."`; -exports[`API should work with deprecated API ('listen' and \`close\` methods): page errors 1`] = `Array []`; +exports[`API should work with deprecated API ('listen' and 'close' methods): page errors 1`] = `Array []`; exports[`API should work with deprecated API (only compiler in constructor): console messages 1`] = ` Array [ diff --git a/test/e2e/api.test.js b/test/e2e/api.test.js index 5294625e78..6807932bb9 100644 --- a/test/e2e/api.test.js +++ b/test/e2e/api.test.js @@ -204,7 +204,7 @@ describe("API", () => { await server.stop(); }); - it("should work with deprecated API ('listen' and `close` methods)", async () => { + it("should work with deprecated API ('listen' and 'close' methods)", async () => { const compiler = webpack(config); const devServerOptions = { port }; const utilSpy = jest.spyOn(util, "deprecate"); @@ -239,19 +239,24 @@ describe("API", () => { waitUntil: "networkidle0", }); - expect(utilSpy.mock.calls[0][1]).toMatchSnapshot("deprecation log"); + expect(utilSpy.mock.calls[0][1]).toMatchSnapshot("listen deprecation log"); expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( "console messages" ); expect(pageErrors).toMatchSnapshot("page errors"); - utilSpy.mockRestore(); await browser.close(); await new Promise((resolve) => { server.close(() => { resolve(); }); }); + + expect( + utilSpy.mock.calls[utilSpy.mock.calls.length - 1][1] + ).toMatchSnapshot("close deprecation log"); + + utilSpy.mockRestore(); }); it(`should work with deprecated API (the order of the arguments in the constructor)`, async () => { From 9b67774849bf8c614636fd40a63e13fa07098f2b Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 10 Dec 2021 17:26:42 +0530 Subject: [PATCH 3/3] test: update webpack 4 snapshot --- test/e2e/__snapshots__/api.test.js.snap.webpack4 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/e2e/__snapshots__/api.test.js.snap.webpack4 b/test/e2e/__snapshots__/api.test.js.snap.webpack4 index 4192afa46f..092e5ef6e8 100644 --- a/test/e2e/__snapshots__/api.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/api.test.js.snap.webpack4 @@ -55,7 +55,9 @@ Array [ exports[`API should work with callback API: page errors 1`] = `Array []`; -exports[`API should work with deprecated API ('listen' and \`close\` methods): console messages 1`] = ` +exports[`API should work with deprecated API ('listen' and 'close' methods): close deprecation log 1`] = `"'close' is deprecated. Please use the async 'stop' or 'stopCallback' method."`; + +exports[`API should work with deprecated API ('listen' and 'close' methods): console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "Hey.", @@ -64,9 +66,9 @@ Array [ ] `; -exports[`API should work with deprecated API ('listen' and \`close\` methods): deprecation log 1`] = `"'listen' is deprecated. Please use async 'start' or 'startCallback' methods."`; +exports[`API should work with deprecated API ('listen' and 'close' methods): listen deprecation log 1`] = `"'listen' is deprecated. Please use the async 'start' or 'startCallback' method."`; -exports[`API should work with deprecated API ('listen' and \`close\` methods): page errors 1`] = `Array []`; +exports[`API should work with deprecated API ('listen' and 'close' methods): page errors 1`] = `Array []`; exports[`API should work with deprecated API (only compiler in constructor): console messages 1`] = ` Array [