diff --git a/lib/Server.js b/lib/Server.js index 8301581d01..3185b34586 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -726,13 +726,21 @@ class Server { options.server.options.requestCert = false; } - // TODO remove the `cacert` option in favor `ca` in the next major release for (const property of ["cacert", "ca", "cert", "crl", "key", "pfx"]) { if (typeof options.server.options[property] === "undefined") { // eslint-disable-next-line no-continue continue; } + if (property === "cacert") { + // TODO remove the `cacert` option in favor `ca` in the next major release + util.deprecate( + () => {}, + "The 'cacert' option is deprecated. Please use the 'ca' option.", + "DEP_WEBPACK_DEV_SERVER_CACERT" + )(); + } + const value = options.server.options[property]; const readFile = (item) => { if ( diff --git a/test/e2e/https.test.js b/test/e2e/https.test.js index 4ab76466f9..dee1a9b3c8 100644 --- a/test/e2e/https.test.js +++ b/test/e2e/https.test.js @@ -655,11 +655,13 @@ describe("https option", () => { let browser; let pageErrors; let consoleMessages; + let utilSpy; beforeEach(async () => { compiler = webpack(config); createServerSpy = jest.spyOn(https, "createServer"); + utilSpy = jest.spyOn(util, "deprecate"); server = new Server( { @@ -697,6 +699,7 @@ describe("https option", () => { afterEach(async () => { createServerSpy.mockRestore(); + utilSpy.mockRestore(); await browser.close(); await server.stop(); @@ -715,6 +718,9 @@ describe("https option", () => { waitUntil: "networkidle0", }); + expect(utilSpy.mock.calls[1][1]).toBe( + "The 'cacert' option is deprecated. Please use the 'ca' option." + ); expect( normalizeOptions(createServerSpy.mock.calls[0][0]) ).toMatchSnapshot("https options"); diff --git a/test/e2e/server.test.js b/test/e2e/server.test.js index 7b77e8d629..f24a46e2dd 100644 --- a/test/e2e/server.test.js +++ b/test/e2e/server.test.js @@ -2,6 +2,7 @@ const https = require("https"); const path = require("path"); +const util = require("util"); const fs = require("graceful-fs"); const request = require("supertest"); const spdy = require("spdy"); @@ -871,11 +872,13 @@ describe("server option", () => { let browser; let pageErrors; let consoleMessages; + let utilSpy; beforeEach(async () => { compiler = webpack(config); createServerSpy = jest.spyOn(https, "createServer"); + utilSpy = jest.spyOn(util, "deprecate"); server = new Server( { @@ -916,6 +919,7 @@ describe("server option", () => { afterEach(async () => { createServerSpy.mockRestore(); + utilSpy.mockRestore(); await browser.close(); await server.stop(); @@ -934,6 +938,9 @@ describe("server option", () => { waitUntil: "networkidle0", }); + expect(utilSpy.mock.calls[0][1]).toBe( + "The 'cacert' option is deprecated. Please use the 'ca' option." + ); expect( normalizeOptions(createServerSpy.mock.calls[0][0]) ).toMatchSnapshot("https options");