diff --git a/client-src/index.js b/client-src/index.js index 63251d7992..eb2ff4bc1d 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -87,6 +87,7 @@ const onSocketMessage = { sendMessage("Invalid"); }, hash(hash) { + status.previousHash = status.currentHash; status.currentHash = hash; }, logging: setAllLogLevel, diff --git a/client-src/utils/reloadApp.js b/client-src/utils/reloadApp.js index adc976b20a..8dfbffde3d 100644 --- a/client-src/utils/reloadApp.js +++ b/client-src/utils/reloadApp.js @@ -8,23 +8,10 @@ function reloadApp({ hot, liveReload }, status) { return; } - // TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement plugin - const webpackHash = - // eslint-disable-next-line camelcase - typeof __webpack_hash__ !== "undefined" - ? // eslint-disable-next-line camelcase - __webpack_hash__ - : status.previousHash || ""; - const isInitial = status.currentHash.indexOf(webpackHash) >= 0; + const { currentHash, previousHash } = status; + const isInitial = currentHash.indexOf(previousHash) >= 0; if (isInitial) { - const isLegacyInitial = - webpackHash === "" && hot === false && liveReload === true; - - if (isLegacyInitial) { - status.previousHash = status.currentHash; - } - return; } diff --git a/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack4 b/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack4 index 5b7650e8a4..1daf8c6fca 100644 --- a/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack4 +++ b/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack4 @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`multi compiler should work with one web target configuration: console messages 1`] = ` +exports[`multi compiler should work with one web target configuration and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "Hey.", @@ -9,94 +9,269 @@ Array [ ] `; -exports[`multi compiler should work with one web target configuration: page errors 1`] = `Array []`; +exports[`multi compiler should work with one web target configuration and do nothing: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with hot and live reload: console messages 1`] = ` +exports[`multi compiler should work with universal configuration and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "one", + "Hello from the browser", "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with hot and live reload: console messages 2`] = ` +exports[`multi compiler should work with universal configuration and do nothing: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "two", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./browser.js is not accepted +Update propagation: ./browser.js -> 0 + ", + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with hot and live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with hot and live reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./browser.js is not accepted +Update propagation: ./browser.js -> 0 + at hotApplyInternal (http://127.0.0.1:8103/browser.js:508:30) + at hotApply (http://127.0.0.1:8103/browser.js:362:19) + at http://127.0.0.1:8103/browser.js:337:22", + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 1`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; -exports[`multi compiler should work with two web target configurations with only hot reload: console messages 1`] = ` +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 2`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 1`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 2`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with web target configurations and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "one", "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only hot reload: console messages 2`] = ` +exports[`multi compiler should work with web target configurations and do nothing: console messages 2`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "two", "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only hot reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations and do nothing: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only hot reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with web target configurations and do nothing: page errors 2`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: console messages 1`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "one", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./one.js is not accepted +Update propagation: ./one.js -> 0 + ", + "[HMR] Waiting for update signal from WDS...", + "one", + "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only live reload: console messages 2`] = ` +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: console messages 2`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "two", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./two.js is not accepted +Update propagation: ./two.js -> 0 + ", + "[HMR] Waiting for update signal from WDS...", + "two", + "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only live reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 2`] = `Array []`; -exports[`multi compiler should work with universal configurations with hot and live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", + "one", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./one.js is not accepted +Update propagation: ./one.js -> 0 + ", + "[HMR] Waiting for update signal from WDS...", + "one", "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with universal configurations with hot and live reload: page errors 1`] = `Array []`; - -exports[`multi compiler should work with universal configurations with only hot reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 2`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", + "two", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./two.js is not accepted +Update propagation: ./two.js -> 0 + ", + "[HMR] Waiting for update signal from WDS...", + "two", "[webpack-dev-server] Hot Module Replacement enabled.", ] `; -exports[`multi compiler should work with universal configurations with only hot reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 2`] = `Array []`; -exports[`multi compiler should work with universal configurations with only live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 1`] = ` Array [ - "Hello from the browser", + "one", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "one", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 2`] = ` +Array [ + "two", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "two", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 1`] = ` +Array [ + "one", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "one", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 2`] = ` +Array [ + "two", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "two", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with universal configurations with only live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 2`] = `Array []`; diff --git a/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 b/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 index 5b7650e8a4..781968f03c 100644 --- a/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 +++ b/test/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`multi compiler should work with one web target configuration: console messages 1`] = ` +exports[`multi compiler should work with one web target configuration and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "Hey.", @@ -9,94 +9,273 @@ Array [ ] `; -exports[`multi compiler should work with one web target configuration: page errors 1`] = `Array []`; +exports[`multi compiler should work with one web target configuration and do nothing: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with hot and live reload: console messages 1`] = ` +exports[`multi compiler should work with universal configuration and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "one", + "Hello from the browser", "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with hot and live reload: console messages 2`] = ` +exports[`multi compiler should work with universal configuration and do nothing: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "two", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./browser.js is not accepted +Update propagation: ./browser.js + ", + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with hot and live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with hot and live reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: console messages 1`] = ` +Array [ + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./browser.js is not accepted +Update propagation: ./browser.js + at applyHandler (http://127.0.0.1:8103/browser.js:1094:31) + at http://127.0.0.1:8103/browser.js:794:21 + at Array.map () + at internalApply (http://127.0.0.1:8103/browser.js:793:54) + at http://127.0.0.1:8103/browser.js:767:26 + at waitForBlockingPromises (http://127.0.0.1:8103/browser.js:720:55) + at http://127.0.0.1:8103/browser.js:765:24", + "[HMR] Waiting for update signal from WDS...", + "Hello from the browser", + "[webpack-dev-server] Hot Module Replacement enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 1`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; -exports[`multi compiler should work with two web target configurations with only hot reload: console messages 1`] = ` +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 2`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 1`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 2`] = ` +Array [ + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "Hello from the browser", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with web target configurations and do nothing: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "one", "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only hot reload: console messages 2`] = ` +exports[`multi compiler should work with web target configurations and do nothing: console messages 2`] = ` Array [ "[HMR] Waiting for update signal from WDS...", "two", "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only hot reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations and do nothing: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only hot reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with web target configurations and do nothing: page errors 2`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: console messages 1`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "one", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./one.js is not accepted +Update propagation: ./one.js + ", + "[HMR] Waiting for update signal from WDS...", + "one", + "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only live reload: console messages 2`] = ` +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: console messages 2`] = ` Array [ + "[HMR] Waiting for update signal from WDS...", "two", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./two.js is not accepted +Update propagation: ./two.js + ", + "[HMR] Waiting for update signal from WDS...", + "two", + "[webpack-dev-server] Hot Module Replacement enabled.", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with two web target configurations with only live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 1`] = `Array []`; -exports[`multi compiler should work with two web target configurations with only live reload: page errors 2`] = `Array []`; +exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 2`] = `Array []`; -exports[`multi compiler should work with universal configurations with hot and live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 1`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", + "one", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./one.js is not accepted +Update propagation: ./one.js + ", + "[HMR] Waiting for update signal from WDS...", + "one", "[webpack-dev-server] Hot Module Replacement enabled.", - "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with universal configurations with hot and live reload: page errors 1`] = `Array []`; - -exports[`multi compiler should work with universal configurations with only hot reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 2`] = ` Array [ "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", + "two", + "[webpack-dev-server] Hot Module Replacement enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App hot update...", + "[HMR] Checking for updates on the server...", + "[HMR] Cannot apply update. Need to do a full reload!", + "[HMR] Error: Aborted because ./two.js is not accepted +Update propagation: ./two.js + ", + "[HMR] Waiting for update signal from WDS...", + "two", "[webpack-dev-server] Hot Module Replacement enabled.", ] `; -exports[`multi compiler should work with universal configurations with only hot reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 2`] = `Array []`; -exports[`multi compiler should work with universal configurations with only live reload: console messages 1`] = ` +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 1`] = ` Array [ - "Hello from the browser", + "one", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "one", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 2`] = ` +Array [ + "two", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "two", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 2`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 1`] = ` +Array [ + "one", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "one", + "[webpack-dev-server] Live Reloading enabled.", +] +`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 2`] = ` +Array [ + "two", + "[webpack-dev-server] Live Reloading enabled.", + "[webpack-dev-server] App updated. Recompiling...", + "[webpack-dev-server] App updated. Reloading...", + "two", "[webpack-dev-server] Live Reloading enabled.", ] `; -exports[`multi compiler should work with universal configurations with only live reload: page errors 1`] = `Array []`; +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 1`] = `Array []`; + +exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 2`] = `Array []`; diff --git a/test/e2e/multi-compiler.test.js b/test/e2e/multi-compiler.test.js index b4e5749afe..2146f4dcff 100644 --- a/test/e2e/multi-compiler.test.js +++ b/test/e2e/multi-compiler.test.js @@ -1,5 +1,7 @@ "use strict"; +const path = require("path"); +const fs = require("graceful-fs"); const webpack = require("webpack"); const Server = require("../../lib/Server"); const oneWebTargetConfiguration = require("../fixtures/multi-compiler-one-configuration/webpack.config"); @@ -9,7 +11,7 @@ const runBrowser = require("../helpers/run-browser"); const port = require("../ports-map")["multi-compiler"]; describe("multi compiler", () => { - it(`should work with one web target configuration`, async () => { + it(`should work with one web target configuration and do nothing`, async () => { const compiler = webpack(oneWebTargetConfiguration); const devServerOptions = { port, @@ -42,7 +44,7 @@ describe("multi compiler", () => { await server.stop(); }); - it(`should work with two web target configurations with hot and live reload`, async () => { + it(`should work with web target configurations and do nothing`, async () => { const compiler = webpack(twoWebTargetConfiguration); const devServerOptions = { port, @@ -52,12 +54,12 @@ describe("multi compiler", () => { await server.start(); - const { page: pageOne, browser } = await runBrowser(); + const { page, browser } = await runBrowser(); let pageErrors = []; let consoleMessages = []; - pageOne + page .on("console", (message) => { consoleMessages.push(message.text()); }) @@ -65,7 +67,7 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await pageOne.goto(`http://127.0.0.1:${port}/one-main`, { + await page.goto(`http://127.0.0.1:${port}/one-main`, { waitUntil: "networkidle0", }); @@ -75,7 +77,7 @@ describe("multi compiler", () => { pageErrors = []; consoleMessages = []; - await pageOne.goto(`http://127.0.0.1:${port}/two-main`, { + await page.goto(`http://127.0.0.1:${port}/two-main`, { waitUntil: "networkidle0", }); @@ -86,70 +88,184 @@ describe("multi compiler", () => { await server.stop(); }); - it(`should work with two web target configurations with only hot reload`, async () => { + it(`should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries`, async () => { + const compiler = webpack(twoWebTargetConfiguration); + const devServerOptions = { + port, + hot: true, + liveReload: true, + }; + const pathToOneEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/one.js" + ); + const originalOneEntryContent = fs.readFileSync(pathToOneEntry); + const pathToTwoEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/two.js" + ); + const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); + + const server = new Server(devServerOptions, compiler); + + await server.start(); + + const { page, browser } = await runBrowser(); + + let pageErrors = []; + let consoleMessages = []; + + page + .on("console", (message) => { + let text = message.text(); + + if (/Error: Aborted because/.test(text)) { + const splittedText = text.split("\n"); + + text = `${splittedText[0]}\n${splittedText[1]}\n `; + } + + consoleMessages.push(text); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + await page.goto(`http://127.0.0.1:${port}/one-main`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + + pageErrors = []; + consoleMessages = []; + + await page.goto(`http://127.0.0.1:${port}/two-main`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + + await browser.close(); + await server.stop(); + + fs.writeFileSync(pathToOneEntry, originalOneEntryContent); + fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); + }); + + it(`should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries`, async () => { const compiler = webpack(twoWebTargetConfiguration); const devServerOptions = { port, hot: true, liveReload: false, }; + const pathToOneEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/one.js" + ); + const originalOneEntryContent = fs.readFileSync(pathToOneEntry); + const pathToTwoEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/two.js" + ); + const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); const server = new Server(devServerOptions, compiler); await server.start(); - const { page: pageOne, browser } = await runBrowser(); + const { page, browser } = await runBrowser(); let pageErrors = []; let consoleMessages = []; - pageOne + page .on("console", (message) => { - consoleMessages.push(message.text()); + let text = message.text(); + + if (/Error: Aborted because/.test(text)) { + const splittedText = text.split("\n"); + + text = `${splittedText[0]}\n${splittedText[1]}\n `; + } + + consoleMessages.push(text); }) .on("pageerror", (error) => { pageErrors.push(error); }); - await pageOne.goto(`http://127.0.0.1:${port}/one-main`, { + await page.goto(`http://127.0.0.1:${port}/one-main`, { waitUntil: "networkidle0", }); + fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); pageErrors = []; consoleMessages = []; - await pageOne.goto(`http://127.0.0.1:${port}/two-main`, { + await page.goto(`http://127.0.0.1:${port}/two-main`, { waitUntil: "networkidle0", }); + fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); await browser.close(); await server.stop(); + + fs.writeFileSync(pathToOneEntry, originalOneEntryContent); + fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); }); - it(`should work with two web target configurations with only live reload`, async () => { + it(`should work with web target configurations when only live reload is enabled, and do live reload when changing own entries`, async () => { const compiler = webpack(twoWebTargetConfiguration); const devServerOptions = { port, hot: false, liveReload: true, }; + const pathToOneEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/one.js" + ); + const originalOneEntryContent = fs.readFileSync(pathToOneEntry); + const pathToTwoEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/two.js" + ); + const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); const server = new Server(devServerOptions, compiler); await server.start(); - const { page: pageOne, browser } = await runBrowser(); + const { page, browser } = await runBrowser(); let pageErrors = []; let consoleMessages = []; - pageOne + page .on("console", (message) => { consoleMessages.push(message.text()); }) @@ -157,40 +273,64 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await pageOne.goto(`http://127.0.0.1:${port}/one-main`, { + await page.goto(`http://127.0.0.1:${port}/one-main`, { waitUntil: "networkidle0", }); + fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); pageErrors = []; consoleMessages = []; - await pageOne.goto(`http://127.0.0.1:${port}/two-main`, { + await page.goto(`http://127.0.0.1:${port}/two-main`, { waitUntil: "networkidle0", }); + fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); await browser.close(); await server.stop(); + + fs.writeFileSync(pathToOneEntry, originalOneEntryContent); + fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); }); - it("should work with universal configurations with hot and live reload", async () => { - const compiler = webpack(universalConfiguration); + it(`should work with web target configurations when only live reload is enabled and do live reload when changing other entries`, async () => { + const compiler = webpack(twoWebTargetConfiguration); const devServerOptions = { port, + hot: false, + liveReload: true, }; + const pathToOneEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/one.js" + ); + const originalOneEntryContent = fs.readFileSync(pathToOneEntry); + const pathToTwoEntry = path.resolve( + __dirname, + "../fixtures/multi-compiler-two-configurations/two.js" + ); + const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); + const server = new Server(devServerOptions, compiler); await server.start(); const { page, browser } = await runBrowser(); - const pageErrors = []; - const consoleMessages = []; + let pageErrors = []; + let consoleMessages = []; page .on("console", (message) => { @@ -200,13 +340,49 @@ describe("multi compiler", () => { pageErrors.push(error); }); - await page.goto(`http://127.0.0.1:${port}/browser`, { + await page.goto(`http://127.0.0.1:${port}/one-main`, { waitUntil: "networkidle0", }); + fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); + pageErrors = []; + consoleMessages = []; + + await page.goto(`http://127.0.0.1:${port}/two-main`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + + await browser.close(); + await server.stop(); + + fs.writeFileSync(pathToOneEntry, originalOneEntryContent); + fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); + }); + + it("should work with universal configuration and do nothing", async () => { + const compiler = webpack(universalConfiguration); + const devServerOptions = { + port, + }; + const server = new Server(devServerOptions, compiler); + + await server.start(); + + const { page, browser } = await runBrowser(); + const serverResponse = await page.goto( `http://127.0.0.1:${port}/server.js`, { @@ -219,29 +395,78 @@ describe("multi compiler", () => { expect(serverResponseText).toContain("Hello from the server"); expect(serverResponseText).not.toContain("WebsocketServer"); + const pageErrors = []; + const consoleMessages = []; + + page + .on("console", (message) => { + consoleMessages.push(message.text()); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + await page.goto(`http://127.0.0.1:${port}/browser`, { + waitUntil: "networkidle0", + }); + await browser.close(); await server.stop(); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); }); - it("should work with universal configurations with only hot reload", async () => { + it(`should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed`, async () => { const compiler = webpack(universalConfiguration); const devServerOptions = { port, hot: true, - liveReload: false, + liveReload: true, }; + const pathToBrowserEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/browser.js" + ); + const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); + const pathToServerEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/server.js" + ); + const originalServerEntryContent = fs.readFileSync(pathToServerEntry); + const server = new Server(devServerOptions, compiler); await server.start(); const { page, browser } = await runBrowser(); + const serverResponse = await page.goto( + `http://127.0.0.1:${port}/server.js`, + { + waitUntil: "networkidle0", + } + ); + + const serverResponseText = await serverResponse.text(); + + expect(serverResponseText).toContain("Hello from the server"); + expect(serverResponseText).not.toContain("WebsocketServer"); + const pageErrors = []; const consoleMessages = []; page .on("console", (message) => { - consoleMessages.push(message.text()); + let text = message.text(); + + if (/Error: Aborted because/.test(text)) { + const splittedText = text.split("\n"); + + text = `${splittedText[0]}\n${splittedText[1]}\n `; + } + + consoleMessages.push(text); }) .on("pageerror", (error) => { pageErrors.push(error); @@ -251,9 +476,42 @@ describe("multi compiler", () => { waitUntil: "networkidle0", }); + fs.writeFileSync( + pathToBrowserEntry, + `${originalBrowserEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); + await browser.close(); + await server.stop(); + + fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); + fs.writeFileSync(pathToServerEntry, originalServerEntryContent); + }); + + it(`should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed`, async () => { + const compiler = webpack(universalConfiguration); + const devServerOptions = { + port, + hot: true, + liveReload: false, + }; + const pathToBrowserEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/browser.js" + ); + const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); + + const server = new Server(devServerOptions, compiler); + + await server.start(); + + const { page, browser } = await runBrowser(); + const serverResponse = await page.goto( `http://127.0.0.1:${port}/server.js`, { @@ -266,25 +524,83 @@ describe("multi compiler", () => { expect(serverResponseText).toContain("Hello from the server"); expect(serverResponseText).not.toContain("WebsocketServer"); + const pageErrors = []; + const consoleMessages = []; + + page + .on("console", (message) => { + let text = message.text(); + + if (/Error: Aborted because/.test(text)) { + const splittedText = text.split("\n"); + + text = `${splittedText[0]}\n${splittedText[1]}\n `; + } + + consoleMessages.push(message.text()); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + await page.goto(`http://127.0.0.1:${port}/browser`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync( + pathToBrowserEntry, + `${originalBrowserEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + await browser.close(); await server.stop(); + + fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); }); - it("should work with universal configurations with only live reload", async () => { + it(`should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries`, async () => { const compiler = webpack(universalConfiguration); const devServerOptions = { port, hot: false, liveReload: true, }; + const pathToBrowserEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/browser.js" + ); + const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); + const pathToServerEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/server.js" + ); + const originalServerEntryContent = fs.readFileSync(pathToServerEntry); + const server = new Server(devServerOptions, compiler); await server.start(); const { page, browser } = await runBrowser(); - const pageErrors = []; - const consoleMessages = []; + const serverResponse = await page.goto( + `http://127.0.0.1:${port}/server.js`, + { + waitUntil: "networkidle0", + } + ); + + const serverResponseText = await serverResponse.text(); + + expect(serverResponseText).toContain("Hello from the server"); + expect(serverResponseText).not.toContain("WebsocketServer"); + + let pageErrors = []; + let consoleMessages = []; page .on("console", (message) => { @@ -298,9 +614,64 @@ describe("multi compiler", () => { waitUntil: "networkidle0", }); + fs.writeFileSync( + pathToBrowserEntry, + `${originalBrowserEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + expect(consoleMessages).toMatchSnapshot("console messages"); expect(pageErrors).toMatchSnapshot("page errors"); + pageErrors = []; + consoleMessages = []; + + await page.goto(`http://127.0.0.1:${port}/browser`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync( + pathToServerEntry, + `${originalServerEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + + await browser.close(); + await server.stop(); + + fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); + fs.writeFileSync(pathToServerEntry, originalServerEntryContent); + }); + + it(`should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries`, async () => { + const compiler = webpack(universalConfiguration); + const devServerOptions = { + port, + hot: false, + liveReload: true, + }; + const pathToBrowserEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/browser.js" + ); + const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); + const pathToServerEntry = path.resolve( + __dirname, + "../fixtures/universal-compiler-config/server.js" + ); + const originalServerEntryContent = fs.readFileSync(pathToServerEntry); + + const server = new Server(devServerOptions, compiler); + + await server.start(); + + const { page, browser } = await runBrowser(); + const serverResponse = await page.goto( `http://127.0.0.1:${port}/server.js`, { @@ -313,7 +684,52 @@ describe("multi compiler", () => { expect(serverResponseText).toContain("Hello from the server"); expect(serverResponseText).not.toContain("WebsocketServer"); + let pageErrors = []; + let consoleMessages = []; + + page + .on("console", (message) => { + consoleMessages.push(message.text()); + }) + .on("pageerror", (error) => { + pageErrors.push(error); + }); + + await page.goto(`http://127.0.0.1:${port}/browser`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync( + pathToServerEntry, + `${originalServerEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + + pageErrors = []; + consoleMessages = []; + + await page.goto(`http://127.0.0.1:${port}/browser`, { + waitUntil: "networkidle0", + }); + + fs.writeFileSync( + pathToBrowserEntry, + `${originalBrowserEntryContent}// comment` + ); + + await page.waitForNavigation({ waitUntil: "networkidle0" }); + + expect(consoleMessages).toMatchSnapshot("console messages"); + expect(pageErrors).toMatchSnapshot("page errors"); + await browser.close(); await server.stop(); + + fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); + fs.writeFileSync(pathToServerEntry, originalServerEntryContent); }); }); diff --git a/test/fixtures/universal-compiler-config/webpack.config.js b/test/fixtures/universal-compiler-config/webpack.config.js index 04159afcc6..99e5348143 100644 --- a/test/fixtures/universal-compiler-config/webpack.config.js +++ b/test/fixtures/universal-compiler-config/webpack.config.js @@ -6,6 +6,7 @@ const isWebpack5 = webpack.version.startsWith("5"); module.exports = [ { + name: "browser", mode: "development", context: __dirname, stats: "none", @@ -26,6 +27,7 @@ module.exports = [ }, }, { + name: "server", mode: "development", context: __dirname, target: "node",