diff --git a/test/server/Server.test.js b/test/server/Server.test.js deleted file mode 100644 index 225e45b7d8..0000000000 --- a/test/server/Server.test.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; - -const { relative, sep } = require("path"); -const webpack = require("webpack"); -const Server = require("../../lib/Server"); -const config = require("../fixtures/simple-config/webpack.config"); -const port = require("../ports-map").server; -const isWebpack5 = require("../helpers/isWebpack5"); - -const baseDevConfig = { - port, - host: "localhost", - static: false, -}; - -describe("Server", () => { - describe("DevServerPlugin", () => { - let entries; - - function getEntries(server) { - if (isWebpack5) { - server.middleware.context.compiler.hooks.afterEmit.tap( - "webpack-dev-server", - (compilation) => { - const mainDeps = compilation.entries.get("main").dependencies; - const globalDeps = compilation.globalEntry.dependencies; - - entries = globalDeps - .concat(mainDeps) - .map((dep) => relative(".", dep.request).split(sep)); - } - ); - } else { - entries = server.middleware.context.compiler.options.entry.map((p) => - relative(".", p).split(sep) - ); - } - } - - it("add hot option", (done) => { - const compiler = webpack(config); - const server = new Server({ ...baseDevConfig, hot: true }, compiler); - - compiler.hooks.done.tap("webpack-dev-server", () => { - expect(entries).toMatchSnapshot(); - - server.stopCallback(done); - }); - - server.startCallback((error) => { - if (error) { - throw error; - } - - getEntries(server); - }); - }); - - it("add hot-only option", (done) => { - const compiler = webpack(config); - const server = new Server({ ...baseDevConfig, hot: "only" }, compiler); - - compiler.hooks.done.tap("webpack-dev-server", () => { - expect(entries).toMatchSnapshot(); - - server.stopCallback(done); - }); - - server.startCallback((error) => { - if (error) { - throw error; - } - - getEntries(server); - }); - }); - - // TODO: remove this after plugin support is published - it("should create and run server with old parameters order and log deprecation warning", (done) => { - const compiler = webpack(config); - const util = require("util"); - const utilSpy = jest.spyOn(util, "deprecate"); - - const server = new Server(compiler, baseDevConfig); - - expect(utilSpy.mock.calls[0][1]).toBe( - "Using 'compiler' as the first argument is deprecated. Please use 'options' as the first argument and 'compiler' as the second argument." - ); - - compiler.hooks.done.tap("webpack-dev-server", () => { - expect(entries).toMatchSnapshot("oldparam"); - - server.stopCallback(done); - }); - - server.startCallback((error) => { - if (error) { - throw error; - } - - getEntries(server); - }); - - utilSpy.mockRestore(); - }); - }); -}); diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack4 b/test/server/__snapshots__/Server.test.js.snap.webpack4 deleted file mode 100644 index 91db318c1d..0000000000 --- a/test/server/__snapshots__/Server.test.js.snap.webpack4 +++ /dev/null @@ -1,55 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Server DevServerPlugin add hot option 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - -exports[`Server DevServerPlugin add hot-only option 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "only-dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - -exports[`Server DevServerPlugin should create and run server with old parameters order and log deprecation warning: oldparam 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack5 b/test/server/__snapshots__/Server.test.js.snap.webpack5 deleted file mode 100644 index 91db318c1d..0000000000 --- a/test/server/__snapshots__/Server.test.js.snap.webpack5 +++ /dev/null @@ -1,55 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Server DevServerPlugin add hot option 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - -exports[`Server DevServerPlugin add hot-only option 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "only-dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - -exports[`Server DevServerPlugin should create and run server with old parameters order and log deprecation warning: oldparam 1`] = ` -Array [ - Array [ - "client", - "index.js?protocol=ws%3A&hostname=localhost&port=8124&pathname=%2Fws&logging=info&reconnect=10", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`;