From cda3ec16f90f3d4f59cc259cf74b9c082bbe7de3 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Sun, 15 Aug 2021 23:03:47 +0300 Subject: [PATCH] test: fix --- test/fixtures/client-config/webpack.config.js | 5 +- .../multi-compiler-config/webpack.config.js | 5 +- test/fixtures/overlay-config/foo.js | 3 - .../fixtures/overlay-config/webpack.config.js | 5 +- .../provide-plugin-custom/webpack.config.js | 5 +- .../provide-plugin-default/webpack.config.js | 5 +- .../webpack.config.js | 5 +- .../webpack.config.js | 5 +- .../reload-config-2/webpack.config.js | 5 +- test/fixtures/simple-config/webpack.config.js | 3 + test/server/Server.test.js | 45 ++++++- .../Server.test.js.snap.webpack4 | 116 ++++++++++++++---- .../Server.test.js.snap.webpack5 | 116 ++++++++++++++---- 13 files changed, 257 insertions(+), 66 deletions(-) diff --git a/test/fixtures/client-config/webpack.config.js b/test/fixtures/client-config/webpack.config.js index 2106890ec5..14aa069ddd 100644 --- a/test/fixtures/client-config/webpack.config.js +++ b/test/fixtures/client-config/webpack.config.js @@ -21,7 +21,10 @@ module.exports = { path: "/", }, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, plugins: [ { diff --git a/test/fixtures/multi-compiler-config/webpack.config.js b/test/fixtures/multi-compiler-config/webpack.config.js index 7b8c2320f1..28bcf73362 100644 --- a/test/fixtures/multi-compiler-config/webpack.config.js +++ b/test/fixtures/multi-compiler-config/webpack.config.js @@ -11,7 +11,10 @@ module.exports = [ }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }, ]; diff --git a/test/fixtures/overlay-config/foo.js b/test/fixtures/overlay-config/foo.js index 3c915dbcb8..e69de29bb2 100644 --- a/test/fixtures/overlay-config/foo.js +++ b/test/fixtures/overlay-config/foo.js @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/test/fixtures/overlay-config/webpack.config.js b/test/fixtures/overlay-config/webpack.config.js index f03898aa61..cd7b610d84 100644 --- a/test/fixtures/overlay-config/webpack.config.js +++ b/test/fixtures/overlay-config/webpack.config.js @@ -9,6 +9,9 @@ module.exports = { path: "/", }, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/provide-plugin-custom/webpack.config.js b/test/fixtures/provide-plugin-custom/webpack.config.js index 624dc8a648..f8bc3a9399 100644 --- a/test/fixtures/provide-plugin-custom/webpack.config.js +++ b/test/fixtures/provide-plugin-custom/webpack.config.js @@ -10,6 +10,9 @@ module.exports = { }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/provide-plugin-default/webpack.config.js b/test/fixtures/provide-plugin-default/webpack.config.js index 624dc8a648..f8bc3a9399 100644 --- a/test/fixtures/provide-plugin-default/webpack.config.js +++ b/test/fixtures/provide-plugin-default/webpack.config.js @@ -10,6 +10,9 @@ module.exports = { }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/provide-plugin-sockjs-config/webpack.config.js b/test/fixtures/provide-plugin-sockjs-config/webpack.config.js index 624dc8a648..f8bc3a9399 100644 --- a/test/fixtures/provide-plugin-sockjs-config/webpack.config.js +++ b/test/fixtures/provide-plugin-sockjs-config/webpack.config.js @@ -10,6 +10,9 @@ module.exports = { }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/provide-plugin-ws-config/webpack.config.js b/test/fixtures/provide-plugin-ws-config/webpack.config.js index 624dc8a648..f8bc3a9399 100644 --- a/test/fixtures/provide-plugin-ws-config/webpack.config.js +++ b/test/fixtures/provide-plugin-ws-config/webpack.config.js @@ -10,6 +10,9 @@ module.exports = { }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/reload-config-2/webpack.config.js b/test/fixtures/reload-config-2/webpack.config.js index e6b58b3802..e18fed2ab2 100644 --- a/test/fixtures/reload-config-2/webpack.config.js +++ b/test/fixtures/reload-config-2/webpack.config.js @@ -18,6 +18,9 @@ module.exports = { }, node: false, infrastructureLogging: { - level: "warn", + level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/fixtures/simple-config/webpack.config.js b/test/fixtures/simple-config/webpack.config.js index 338e8946cb..f8bc3a9399 100644 --- a/test/fixtures/simple-config/webpack.config.js +++ b/test/fixtures/simple-config/webpack.config.js @@ -11,5 +11,8 @@ module.exports = { node: false, infrastructureLogging: { level: "info", + stream: { + write: () => {}, + }, }, }; diff --git a/test/server/Server.test.js b/test/server/Server.test.js index 17ee65eed3..ddc07cf2b2 100644 --- a/test/server/Server.test.js +++ b/test/server/Server.test.js @@ -120,7 +120,7 @@ describe("Server", () => { }); }); - describe("normalizeOptions", () => { + describe.only("normalizeOptions", () => { const cases = [ { title: "no options", @@ -291,6 +291,9 @@ describe("Server", () => { webpackConfig: { infrastructureLogging: { level: "verbose", + stream: { + write: () => {}, + }, }, }, }, @@ -306,9 +309,30 @@ describe("Server", () => { webpackConfig: { infrastructureLogging: { level: "verbose", + stream: { + write: () => {}, + }, }, }, }, + { + title: + "multi compiler client.logging should respect infrastructureLogging.level", + multiCompiler: true, + options: {}, + webpackConfig: [ + { + target: "node", + }, + // infrastructureLogging is set on the second compiler + { + target: "web", + infrastructureLogging: { + level: "warn", + }, + }, + ], + }, { title: "multi compiler client.logging should respect infrastructureLogging.level", @@ -318,12 +342,28 @@ describe("Server", () => { {}, // infrastructureLogging is set on the second compiler { + devServer: {}, infrastructureLogging: { level: "warn", }, }, ], }, + { + title: + "multi compiler client.logging should respect infrastructureLogging.level", + multiCompiler: true, + options: {}, + webpackConfig: [ + // Fallback + { + infrastructureLogging: { + level: "warn", + }, + }, + {}, + ], + }, { title: "multi compiler client.logging should override infrastructureLogging.level", @@ -334,13 +374,12 @@ describe("Server", () => { }, }, webpackConfig: [ - {}, - // infrastructureLogging is set on the second compiler { infrastructureLogging: { level: "warn", }, }, + {}, ], }, { diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack4 b/test/server/__snapshots__/Server.test.js.snap.webpack4 index 500c088acf..0e65a8e566 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack4 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack4 @@ -36,24 +36,6 @@ Array [ ] `; -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", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - exports[`Server Server.getFreePort should throws the error when the port isn't found 1`] = `"busy"`; exports[`Server normalizeOptions allowedHosts is array 1`] = ` @@ -791,7 +773,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -832,7 +814,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -902,7 +884,7 @@ Object { } `; -exports[`Server normalizeOptions multi compiler watchOptions is set 1`] = ` +exports[`Server normalizeOptions multi compiler client.logging should respect infrastructureLogging.level 2`] = ` Object { "allowedHosts": "auto", "bonjour": false, @@ -930,9 +912,89 @@ Object { "icons": true, }, "staticOptions": Object {}, - "watch": Object { - "aggregateTimeout": 300, + "watch": Object {}, + }, + ], + "watchFiles": Array [], + "webSocketServer": Object { + "options": Object { + "path": "/ws", + }, + "type": "ws", + }, +} +`; + +exports[`Server normalizeOptions multi compiler client.logging should respect infrastructureLogging.level 3`] = ` +Object { + "allowedHosts": "auto", + "bonjour": false, + "client": Object { + "logging": "warn", + "overlay": true, + "webSocketURL": Object {}, + }, + "compress": true, + "devMiddleware": Object {}, + "historyApiFallback": false, + "host": undefined, + "hot": true, + "liveReload": true, + "open": Array [], + "port": "", + "setupExitSignals": true, + "static": Array [ + Object { + "directory": "/public", + "publicPath": Array [ + "/", + ], + "serveIndex": Object { + "icons": true, + }, + "staticOptions": Object {}, + "watch": Object {}, + }, + ], + "watchFiles": Array [], + "webSocketServer": Object { + "options": Object { + "path": "/ws", + }, + "type": "ws", + }, +} +`; + +exports[`Server normalizeOptions multi compiler watchOptions is set 1`] = ` +Object { + "allowedHosts": "auto", + "bonjour": false, + "client": Object { + "logging": "info", + "overlay": true, + "webSocketURL": Object {}, + }, + "compress": true, + "devMiddleware": Object {}, + "historyApiFallback": false, + "host": undefined, + "hot": true, + "liveReload": true, + "open": Array [], + "port": "", + "setupExitSignals": true, + "static": Array [ + Object { + "directory": "/public", + "publicPath": Array [ + "/", + ], + "serveIndex": Object { + "icons": true, }, + "staticOptions": Object {}, + "watch": Object {}, }, ], "watchFiles": Array [], @@ -998,7 +1060,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -1039,7 +1101,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -1266,7 +1328,9 @@ Object { "icons": true, }, "staticOptions": Object {}, - "watch": Object {}, + "watch": Object { + "aggregateTimeout": 300, + }, }, ], "watchFiles": Array [], diff --git a/test/server/__snapshots__/Server.test.js.snap.webpack5 b/test/server/__snapshots__/Server.test.js.snap.webpack5 index 500c088acf..0e65a8e566 100644 --- a/test/server/__snapshots__/Server.test.js.snap.webpack5 +++ b/test/server/__snapshots__/Server.test.js.snap.webpack5 @@ -36,24 +36,6 @@ Array [ ] `; -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", - ], - Array [ - "node_modules", - "webpack", - "hot", - "dev-server.js", - ], - Array [ - "foo.js", - ], -] -`; - exports[`Server Server.getFreePort should throws the error when the port isn't found 1`] = `"busy"`; exports[`Server normalizeOptions allowedHosts is array 1`] = ` @@ -791,7 +773,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -832,7 +814,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -902,7 +884,7 @@ Object { } `; -exports[`Server normalizeOptions multi compiler watchOptions is set 1`] = ` +exports[`Server normalizeOptions multi compiler client.logging should respect infrastructureLogging.level 2`] = ` Object { "allowedHosts": "auto", "bonjour": false, @@ -930,9 +912,89 @@ Object { "icons": true, }, "staticOptions": Object {}, - "watch": Object { - "aggregateTimeout": 300, + "watch": Object {}, + }, + ], + "watchFiles": Array [], + "webSocketServer": Object { + "options": Object { + "path": "/ws", + }, + "type": "ws", + }, +} +`; + +exports[`Server normalizeOptions multi compiler client.logging should respect infrastructureLogging.level 3`] = ` +Object { + "allowedHosts": "auto", + "bonjour": false, + "client": Object { + "logging": "warn", + "overlay": true, + "webSocketURL": Object {}, + }, + "compress": true, + "devMiddleware": Object {}, + "historyApiFallback": false, + "host": undefined, + "hot": true, + "liveReload": true, + "open": Array [], + "port": "", + "setupExitSignals": true, + "static": Array [ + Object { + "directory": "/public", + "publicPath": Array [ + "/", + ], + "serveIndex": Object { + "icons": true, + }, + "staticOptions": Object {}, + "watch": Object {}, + }, + ], + "watchFiles": Array [], + "webSocketServer": Object { + "options": Object { + "path": "/ws", + }, + "type": "ws", + }, +} +`; + +exports[`Server normalizeOptions multi compiler watchOptions is set 1`] = ` +Object { + "allowedHosts": "auto", + "bonjour": false, + "client": Object { + "logging": "info", + "overlay": true, + "webSocketURL": Object {}, + }, + "compress": true, + "devMiddleware": Object {}, + "historyApiFallback": false, + "host": undefined, + "hot": true, + "liveReload": true, + "open": Array [], + "port": "", + "setupExitSignals": true, + "static": Array [ + Object { + "directory": "/public", + "publicPath": Array [ + "/", + ], + "serveIndex": Object { + "icons": true, }, + "staticOptions": Object {}, + "watch": Object {}, }, ], "watchFiles": Array [], @@ -998,7 +1060,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -1039,7 +1101,7 @@ Object { "compress": true, "devMiddleware": Object {}, "historyApiFallback": false, - "host": "127.0.0.1", + "host": undefined, "hot": true, "liveReload": true, "open": Array [], @@ -1266,7 +1328,9 @@ Object { "icons": true, }, "staticOptions": Object {}, - "watch": Object {}, + "watch": Object { + "aggregateTimeout": 300, + }, }, ], "watchFiles": Array [],