diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 53573926873..d9521f83eac 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -61,11 +61,6 @@ jobs: node-version: [14.x, 16.x, 18.x] webpack-version: [latest] dev-server-version: [latest] - include: - - node-version: 16.x - os: ubuntu-latest - dev-server-version: version-3 - webpack-version: latest steps: - uses: actions/checkout@v3 @@ -81,10 +76,6 @@ jobs: - name: Install dependencies run: yarn --frozen-lockfile --ignore-engines - - name: Install webpack-dev-server ${{ matrix.dev-server-version }} - if: matrix.dev-server-version == 'version-3' - run: yarn add -W webpack-dev-server@${{ matrix.dev-server-version }} --ignore-engines - - name: Prepare environment for tests run: yarn build:ci diff --git a/test/serve/basic/function-with-argv.config.js b/test/serve/basic/function-with-argv.config.js index bd6df172702..1e4b9fd6f57 100644 --- a/test/serve/basic/function-with-argv.config.js +++ b/test/serve/basic/function-with-argv.config.js @@ -1,5 +1,4 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = (env, argv) => { console.log(argv); @@ -8,12 +7,10 @@ module.exports = (env, argv) => { mode: "development", devtool: false, plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; }; diff --git a/test/serve/basic/function-with-env.config.js b/test/serve/basic/function-with-env.config.js index b2b0d809e4d..84896976970 100644 --- a/test/serve/basic/function-with-env.config.js +++ b/test/serve/basic/function-with-env.config.js @@ -1,5 +1,4 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = (env) => { console.log(env); @@ -8,12 +7,10 @@ module.exports = (env) => { mode: "development", devtool: false, plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; }; diff --git a/test/serve/basic/helper/base-dev-server.config.js b/test/serve/basic/helper/base-dev-server.config.js index 6515a7f8c99..5125a9a9cbe 100644 --- a/test/serve/basic/helper/base-dev-server.config.js +++ b/test/serve/basic/helper/base-dev-server.config.js @@ -1,20 +1,10 @@ -const { isDevServer4 } = require("../../../utils/test-utils"); - -let devServerConfig = {}; - -if (isDevServer4) { - devServerConfig = { - devMiddleware: { - publicPath: "/dev-server-my-public-path/", - }, - client: { - logging: "info", - }, - }; -} else { - devServerConfig = { +const devServerConfig = { + devMiddleware: { publicPath: "/dev-server-my-public-path/", - }; -} + }, + client: { + logging: "info", + }, +}; module.exports = devServerConfig; diff --git a/test/serve/basic/log.config.js b/test/serve/basic/log.config.js index 2a882692b63..cd27c2a3aad 100644 --- a/test/serve/basic/log.config.js +++ b/test/serve/basic/log.config.js @@ -1,15 +1,11 @@ -const { isDevServer4 } = require("../../utils/test-utils"); - module.exports = { mode: "development", infrastructureLogging: { level: "log", }, - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/basic/multi-dev-server-output-public-path.config.js b/test/serve/basic/multi-dev-server-output-public-path.config.js index a397bcb27da..8cba5383127 100644 --- a/test/serve/basic/multi-dev-server-output-public-path.config.js +++ b/test/serve/basic/multi-dev-server-output-public-path.config.js @@ -1,6 +1,5 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); const { devServerConfig } = require("./helper/base-dev-server.config"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = [ { @@ -11,13 +10,11 @@ module.exports = [ output: { filename: "first-output/[name].js", }, - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")], }, { diff --git a/test/serve/basic/multi-output-public-path.config.js b/test/serve/basic/multi-output-public-path.config.js index 9ad11dbe0d6..8a07533b041 100644 --- a/test/serve/basic/multi-output-public-path.config.js +++ b/test/serve/basic/multi-output-public-path.config.js @@ -1,5 +1,4 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = [ { @@ -11,13 +10,11 @@ module.exports = [ filename: "first-output/[name].js", }, plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }, { name: "two", diff --git a/test/serve/basic/output-public-path.config.js b/test/serve/basic/output-public-path.config.js index 6b1a09c8571..473ec830343 100644 --- a/test/serve/basic/output-public-path.config.js +++ b/test/serve/basic/output-public-path.config.js @@ -1,5 +1,4 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = { mode: "development", @@ -8,11 +7,9 @@ module.exports = { publicPath: "/my-public-path/", }, plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index bbbdbf597ad..863bc8c6ee4 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -3,15 +3,9 @@ const path = require("path"); // eslint-disable-next-line node/no-unpublished-require const getPort = require("get-port"); -const { - runWatch, - normalizeStderr, - normalizeStdout, - isDevServer4, -} = require("../../utils/test-utils"); +const { runWatch, normalizeStderr, normalizeStdout } = require("../../utils/test-utils"); const testPath = path.resolve(__dirname); -const devServer4Test = isDevServer4 ? it : it.skip; describe("basic serve usage", () => { let port; @@ -24,13 +18,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -44,13 +32,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -66,41 +48,32 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); + expect(stdout).toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("WEBPACK_SERVE: true"); + expect(stdout).toContain("foo: 'bar'"); + expect(stdout).toContain("development"); + }); - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } + it('should work with the "--config" and "--env" options and expose dev server options', async () => { + const { stderr, stdout } = await runWatch(__dirname, [ + "serve", + "--config", + "function-with-argv.config.js", + "--env", + "foo=bar", + "--hot", + "--port", + port, + ]); + expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); + expect(stdout).toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("hot: true"); expect(stdout).toContain("WEBPACK_SERVE: true"); expect(stdout).toContain("foo: 'bar'"); expect(stdout).toContain("development"); }); - devServer4Test( - 'should work with the "--config" and "--env" options and expose dev server options', - async () => { - const { stderr, stdout } = await runWatch(__dirname, [ - "serve", - "--config", - "function-with-argv.config.js", - "--env", - "foo=bar", - "--hot", - "--port", - port, - ]); - - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).toContain("HotModuleReplacementPlugin"); - expect(stdout).toContain("hot: true"); - expect(stdout).toContain("WEBPACK_SERVE: true"); - expect(stdout).toContain("foo: 'bar'"); - expect(stdout).toContain("development"); - }, - ); - it("should work in multi compiler mode", async () => { const { stderr, stdout } = await runWatch(__dirname, [ "serve", @@ -111,13 +84,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("one"); expect(stdout).toContain("first-output/main.js"); expect(stdout).toContain("two"); @@ -133,13 +100,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("one"); expect(stdout).toContain("first-output/main.js"); expect(stdout).toContain("two"); @@ -150,13 +111,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("development"); expect(stdout).toContain("main.js"); }); @@ -165,13 +120,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--stats"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("compiled successfully"); }); @@ -179,12 +128,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--stats", "verbose"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } + expect(stdout).toContain("HotModuleReplacementPlugin"); const isMacOS = process.platform === "darwin"; @@ -198,13 +142,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--mode", "production"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("production"); expect(stdout).toContain("main.js"); }); @@ -213,12 +151,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--mode", "development"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("compiled successfully"); expect(stdout).toContain("development"); expect(stdout).toContain("main.js"); @@ -228,13 +161,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--progress"]); expect(stderr).toContain("webpack.Progress"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stderr).toContain("webpack.Progress"); expect(stdout).toContain("main.js"); }); @@ -243,31 +170,15 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--progress", "profile"]); expect(stderr).toContain("webpack.Progress"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); it('should work with the "--client-log-level" option', async () => { - const { stdout, stderr } = await runWatch(testPath, [ - "serve", - isDevServer4 ? "--client-logging" : "--client-log-level", - "info", - ]); + const { stdout, stderr } = await runWatch(testPath, ["serve", "--client-logging", "info"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -275,17 +186,11 @@ describe("basic serve usage", () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); - devServer4Test('should work with the "--hot" option', async () => { + it('should work with the "--hot" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ["serve", "--hot"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); @@ -293,7 +198,7 @@ describe("basic serve usage", () => { expect(stdout).toContain("main.js"); }); - devServer4Test('should work with the "--no-hot" option', async () => { + it('should work with the "--no-hot" option', async () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--no-hot"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); @@ -301,7 +206,7 @@ describe("basic serve usage", () => { expect(stdout).toContain("main.js"); }); - devServer4Test('should work with the "--hot" option using the "only" value', async () => { + it('should work with the "--hot" option using the "only" value', async () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--hot=only"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); @@ -309,7 +214,7 @@ describe("basic serve usage", () => { expect(stdout).toContain("main.js"); }); - devServer4Test('should work with "--hot" and "--port" options', async () => { + it('should work with "--hot" and "--port" options', async () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--hot"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); @@ -317,7 +222,7 @@ describe("basic serve usage", () => { expect(stdout).toContain("main.js"); }); - devServer4Test('should work with the "--hot" and "--progress" options', async () => { + it('should work with the "--hot" and "--progress" options', async () => { const { stdout, stderr } = await runWatch(testPath, [ "serve", "--port", @@ -335,13 +240,7 @@ describe("basic serve usage", () => { const { stderr, stdout } = await runWatch(__dirname, ["serve"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -356,13 +255,8 @@ describe("basic serve usage", () => { expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); expect(stdout).toContain("/my-public-path/"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - expect(stdout).toContain("main.js"); - } + expect(stdout).toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("main.js"); }); it('should respect the "publicPath" option from configuration', async () => { @@ -373,13 +267,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); expect(stdout).toContain("/my-public-path/"); }); @@ -394,13 +282,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("one"); expect(stdout).toContain("first-output/main.js"); expect(stdout).toContain("two"); @@ -416,43 +298,31 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); it('should work with the "--open" option', async () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--open", "--port", port]); - if (isDevServer4) { - let normalizedStderr = normalizeStderr(stderr); - - if (/wait until bundle finished/.test(normalizedStderr)) { - normalizedStderr = normalizedStderr.split("\n"); + let normalizedStderr = normalizeStderr(stderr); - const waitIndex = normalizedStderr.findIndex((item) => - /wait until bundle finished/.test(item), - ); + if (/wait until bundle finished/.test(normalizedStderr)) { + normalizedStderr = normalizedStderr.split("\n"); - if (waitIndex !== -1) { - normalizedStderr.splice(waitIndex, 1); - } + const waitIndex = normalizedStderr.findIndex((item) => + /wait until bundle finished/.test(item), + ); - normalizedStderr = normalizedStderr.join("\n"); + if (waitIndex !== -1) { + normalizedStderr.splice(waitIndex, 1); } - expect(normalizedStderr).toMatchSnapshot("stderr"); - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).not.toContain("HotModuleReplacementPlugin"); + normalizedStderr = normalizedStderr.join("\n"); } + expect(normalizedStderr).toMatchSnapshot("stderr"); + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -466,13 +336,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("one"); expect(stdout).toContain("first-output/main.js"); expect(stdout).toContain("two"); @@ -488,13 +352,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("development"); }); @@ -508,13 +366,7 @@ describe("basic serve usage", () => { ]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("development"); }); diff --git a/test/serve/basic/serve.config.js b/test/serve/basic/serve.config.js index d588f89dd95..90a3adb6cfd 100644 --- a/test/serve/basic/serve.config.js +++ b/test/serve/basic/serve.config.js @@ -1,15 +1,12 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = { mode: "development", devtool: false, plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/basic/stats.config.js b/test/serve/basic/stats.config.js index 26691e9bbed..3961181fb36 100644 --- a/test/serve/basic/stats.config.js +++ b/test/serve/basic/stats.config.js @@ -1,18 +1,12 @@ -const { isDevServer4 } = require("../../utils/test-utils"); - module.exports = { mode: "development", devtool: false, - devServer: isDevServer4 - ? { - devMiddleware: { - stats: "minimal", - }, - client: { - logging: "info", - }, - } - : { - stats: "minimal", - }, + devServer: { + devMiddleware: { + stats: "minimal", + }, + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/basic/watch.config.js b/test/serve/basic/watch.config.js index 937ddcc8a8a..aa4ce1f6967 100644 --- a/test/serve/basic/watch.config.js +++ b/test/serve/basic/watch.config.js @@ -1,16 +1,13 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = { mode: "development", devtool: false, plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")], watch: true, - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/basic/webpack.config.js b/test/serve/basic/webpack.config.js index d588f89dd95..90a3adb6cfd 100644 --- a/test/serve/basic/webpack.config.js +++ b/test/serve/basic/webpack.config.js @@ -1,15 +1,12 @@ const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); -const { isDevServer4 } = require("../../utils/test-utils"); module.exports = { mode: "development", devtool: false, plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")], - devServer: isDevServer4 - ? { - client: { - logging: "info", - }, - } - : {}, + devServer: { + client: { + logging: "info", + }, + }, }; diff --git a/test/serve/serve-variable/serve-variable.test.js b/test/serve/serve-variable/serve-variable.test.js index fb5ec31c85b..aa1194d346e 100644 --- a/test/serve/serve-variable/serve-variable.test.js +++ b/test/serve/serve-variable/serve-variable.test.js @@ -3,7 +3,7 @@ const path = require("path"); // eslint-disable-next-line node/no-unpublished-require const getPort = require("get-port"); -const { runWatch, normalizeStderr, isDevServer4 } = require("../../utils/test-utils"); +const { runWatch, normalizeStderr } = require("../../utils/test-utils"); const testPath = path.resolve(__dirname); @@ -19,13 +19,6 @@ describe("serve variable", () => { expect(normalizeStderr(stderr)).toMatchSnapshot(); expect(stdout).toContain("main.js"); - - if (isDevServer4) { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - } - expect(stdout).toContain("PASS"); }); }); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index b7c64db10a4..efc6ff39234 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -3,10 +3,9 @@ const path = require("path"); // eslint-disable-next-line node/no-unpublished-require const getPort = require("get-port"); -const { runWatch, normalizeStderr, isDevServer4 } = require("../../utils/test-utils"); +const { runWatch, normalizeStderr } = require("../../utils/test-utils"); const testPath = path.resolve(__dirname); -const devServer4Test = isDevServer4 ? it : it.skip; describe("serve with devServer in config", () => { let port; @@ -19,14 +18,7 @@ describe("serve with devServer in config", () => { const { stdout, stderr } = await runWatch(testPath, ["serve"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - expect(stdout).toContain("http://0.0.0.0:1234"); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); @@ -34,18 +26,11 @@ describe("serve with devServer in config", () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - - if (isDevServer4) { - expect(stdout).toContain("HotModuleReplacementPlugin"); - } else { - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - expect(stdout).toContain(`http://0.0.0.0:${port}`); - } - + expect(stdout).toContain("HotModuleReplacementPlugin"); expect(stdout).toContain("main.js"); }); - devServer4Test("Passing hot flag works alongside other server config", async () => { + it("Passing hot flag works alongside other server config", async () => { const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--hot"]); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); @@ -53,14 +38,11 @@ describe("serve with devServer in config", () => { expect(stdout).toContain("main.js"); }); - devServer4Test( - "works fine when no-hot flag is passed alongside other server config", - async () => { - const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--no-hot"]); + it("works fine when no-hot flag is passed alongside other server config", async () => { + const { stdout, stderr } = await runWatch(testPath, ["serve", "--port", port, "--no-hot"]); - expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(stdout).not.toContain("HotModuleReplacementPlugin"); - expect(stdout).toContain("main.js"); - }, - ); + expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); + expect(stdout).not.toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("main.js"); + }); });