Skip to content

Commit b217a19

Browse files
authored
fix: update listen and close deprecation warning message (#4097)
* fix: update `listen` and `close` deprecation warning message * test: add snapshots * test: update webpack 4 snapshot
1 parent 693c28a commit b217a19

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

lib/Server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,7 +2405,7 @@ class Server {
24052405
listen(port, hostname, fn) {
24062406
util.deprecate(
24072407
() => {},
2408-
"'listen' is deprecated. Please use async 'start' or 'startCallback' methods.",
2408+
"'listen' is deprecated. Please use the async 'start' or 'startCallback' method.",
24092409
"DEP_WEBPACK_DEV_SERVER_LISTEN"
24102410
)();
24112411

@@ -2465,7 +2465,7 @@ class Server {
24652465
close(callback) {
24662466
util.deprecate(
24672467
() => {},
2468-
"'close' is deprecated. Please use async 'stop' or 'stopCallback' methods.",
2468+
"'close' is deprecated. Please use the async 'stop' or 'stopCallback' method.",
24692469
"DEP_WEBPACK_DEV_SERVER_CLOSE"
24702470
)();
24712471

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ Array [
5555

5656
exports[`API should work with callback API: page errors 1`] = `Array []`;
5757

58-
exports[`API should work with deprecated API ('listen' and \`close\` methods): console messages 1`] = `
58+
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."`;
59+
60+
exports[`API should work with deprecated API ('listen' and 'close' methods): console messages 1`] = `
5961
Array [
6062
"[HMR] Waiting for update signal from WDS...",
6163
"Hey.",
@@ -64,9 +66,9 @@ Array [
6466
]
6567
`;
6668

67-
exports[`API should work with deprecated API ('listen' and \`close\` methods): deprecation log 1`] = `"'listen' is deprecated. Please use async 'start' or 'startCallback' methods."`;
69+
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."`;
6870

69-
exports[`API should work with deprecated API ('listen' and \`close\` methods): page errors 1`] = `Array []`;
71+
exports[`API should work with deprecated API ('listen' and 'close' methods): page errors 1`] = `Array []`;
7072

7173
exports[`API should work with deprecated API (only compiler in constructor): console messages 1`] = `
7274
Array [

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ Array [
5555

5656
exports[`API should work with callback API: page errors 1`] = `Array []`;
5757

58-
exports[`API should work with deprecated API ('listen' and \`close\` methods): console messages 1`] = `
58+
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."`;
59+
60+
exports[`API should work with deprecated API ('listen' and 'close' methods): console messages 1`] = `
5961
Array [
6062
"[HMR] Waiting for update signal from WDS...",
6163
"Hey.",
@@ -64,9 +66,9 @@ Array [
6466
]
6567
`;
6668

67-
exports[`API should work with deprecated API ('listen' and \`close\` methods): deprecation log 1`] = `"'listen' is deprecated. Please use async 'start' or 'startCallback' methods."`;
69+
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."`;
6870

69-
exports[`API should work with deprecated API ('listen' and \`close\` methods): page errors 1`] = `Array []`;
71+
exports[`API should work with deprecated API ('listen' and 'close' methods): page errors 1`] = `Array []`;
7072

7173
exports[`API should work with deprecated API (only compiler in constructor): console messages 1`] = `
7274
Array [

test/e2e/api.test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe("API", () => {
204204
await server.stop();
205205
});
206206

207-
it("should work with deprecated API ('listen' and `close` methods)", async () => {
207+
it("should work with deprecated API ('listen' and 'close' methods)", async () => {
208208
const compiler = webpack(config);
209209
const devServerOptions = { port };
210210
const utilSpy = jest.spyOn(util, "deprecate");
@@ -239,19 +239,24 @@ describe("API", () => {
239239
waitUntil: "networkidle0",
240240
});
241241

242-
expect(utilSpy.mock.calls[0][1]).toMatchSnapshot("deprecation log");
242+
expect(utilSpy.mock.calls[0][1]).toMatchSnapshot("listen deprecation log");
243243
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
244244
"console messages"
245245
);
246246
expect(pageErrors).toMatchSnapshot("page errors");
247247

248-
utilSpy.mockRestore();
249248
await browser.close();
250249
await new Promise((resolve) => {
251250
server.close(() => {
252251
resolve();
253252
});
254253
});
254+
255+
expect(
256+
utilSpy.mock.calls[utilSpy.mock.calls.length - 1][1]
257+
).toMatchSnapshot("close deprecation log");
258+
259+
utilSpy.mockRestore();
255260
});
256261

257262
it(`should work with deprecated API (the order of the arguments in the constructor)`, async () => {

0 commit comments

Comments
 (0)