diff --git a/.babelrc b/.babelrc
index 1320b9a327..f3e7eb83de 100644
--- a/.babelrc
+++ b/.babelrc
@@ -1,3 +1,8 @@
{
- "presets": ["@babel/preset-env"]
+ "presets": ["@babel/preset-env"],
+ "env": {
+ "test": {
+ "plugins": ["@babel/plugin-transform-runtime"]
+ }
+ }
}
diff --git a/.versionrc b/.versionrc
new file mode 100644
index 0000000000..ed7220daaa
--- /dev/null
+++ b/.versionrc
@@ -0,0 +1,7 @@
+{
+ "types": [
+ {"type":"feat","section":"Features"},
+ {"type":"fix","section":"Bug Fixes"},
+ {"type":"test", "hidden": true}
+ ]
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c4ec5da25..4a0c5d4181 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+### [3.7.2](https://github.com/webpack/webpack-dev-server/compare/v3.7.1...v3.7.2) (2019-06-17)
+
+
+### Bug Fixes
+
+* **client:** add default fallback for client ([#2015](https://github.com/webpack/webpack-dev-server/issues/2015)) ([d26b444](https://github.com/webpack/webpack-dev-server/commit/d26b444))
+* **open:** set `wait: false` to run server.close successfully ([#2001](https://github.com/webpack/webpack-dev-server/issues/2001)) ([2b4cb52](https://github.com/webpack/webpack-dev-server/commit/2b4cb52))
+* **test:** fixed ProvidePlugin.test.js ([#2002](https://github.com/webpack/webpack-dev-server/issues/2002)) ([47453cb](https://github.com/webpack/webpack-dev-server/commit/47453cb))
+
+
+
### [3.7.1](https://github.com/webpack/webpack-dev-server/compare/v3.7.0...v3.7.1) (2019-06-07)
@@ -11,7 +22,7 @@ All notable changes to this project will be documented in this file. See [standa
-## [3.7.0](https://github.com/webpack/webpack-dev-server/compare/v3.5.1...v3.7.0) (2019-06-06)
+## [3.7.0](https://github.com/webpack/webpack-dev-server/compare/v3.6.0...v3.7.0) (2019-06-06)
### Bug Fixes
@@ -20,11 +31,6 @@ All notable changes to this project will be documented in this file. See [standa
* es6 syntax in client ([#1982](https://github.com/webpack/webpack-dev-server/issues/1982)) ([802aa30](https://github.com/webpack/webpack-dev-server/commit/802aa30))
-### Features
-
-* **server:** add serverMode option ([#1937](https://github.com/webpack/webpack-dev-server/issues/1937)) ([44a8cde](https://github.com/webpack/webpack-dev-server/commit/44a8cde))
-
-
## [3.6.0](https://github.com/webpack/webpack-dev-server/compare/v3.5.1...v3.6.0) (2019-06-05)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index cdf5d9097e..7f1d5e8722 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -56,6 +56,12 @@ Pull requests often need some real-world testing.
The pull request is now ready to be tested.
+## Contributor License Agreement
+
+When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the [CLA](https://cla.js.foundation/webpack/webpack-dev-server). If it is your first time, it will link you to the right place to sign it. However, if you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution.
+
+Run `git config user.email` to see your Git email, and verify it with [your GitHub email](https://github.com/settings/emails).
+
---
_Many thanks to [create-react-app](https://github.com/facebookincubator/create-react-app/blob/master/CONTRIBUTING.md) for the inspiration with this contributing guide_
diff --git a/client-src/default/overlay.js b/client-src/default/overlay.js
index 8ffd84323e..a1bb6cef2b 100644
--- a/client-src/default/overlay.js
+++ b/client-src/default/overlay.js
@@ -4,10 +4,9 @@
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
const ansiHTML = require('ansi-html');
-const Entities = require('html-entities').AllHtmlEntities;
-
-const entities = new Entities();
+const { AllHtmlEntities } = require('html-entities');
+const entities = new AllHtmlEntities();
const colors = {
reset: ['transparent', 'transparent'],
black: '181818',
@@ -20,6 +19,11 @@ const colors = {
lightgrey: 'EBE7E3',
darkgrey: '6D7891',
};
+
+let overlayIframe = null;
+let overlayDiv = null;
+let lastOnOverlayDivReady = null;
+
ansiHTML.setColors(colors);
function createOverlayIframe(onIframeLoad) {
@@ -62,10 +66,6 @@ function addOverlayDivTo(iframe) {
return div;
}
-let overlayIframe = null;
-let overlayDiv = null;
-let lastOnOverlayDivReady = null;
-
function ensureOverlayDivExists(onOverlayDivReady) {
if (overlayDiv) {
// Everything is ready, call the callback right away.
@@ -78,7 +78,7 @@ function ensureOverlayDivExists(onOverlayDivReady) {
lastOnOverlayDivReady = onOverlayDivReady;
if (overlayIframe) {
- // We're already creating it.
+ // We've already created it.
return;
}
@@ -95,16 +95,8 @@ function ensureOverlayDivExists(onOverlayDivReady) {
document.body.appendChild(overlayIframe);
}
-function showMessageOverlay(message) {
- ensureOverlayDivExists((div) => {
- // Make it look similar to our terminal.
- div.innerHTML = `Failed to compile.
${ansiHTML(entities.encode(message))}`;
- });
-}
-
-function destroyErrorOverlay() {
+// Successful compilation.
+function clear() {
if (!overlayDiv) {
// It is not there in the first place.
return;
@@ -117,12 +109,19 @@ function destroyErrorOverlay() {
lastOnOverlayDivReady = null;
}
-// Successful compilation.
-exports.clear = function handleSuccess() {
- destroyErrorOverlay();
-};
-
// Compilation with errors (e.g. syntax error or missing modules).
-exports.showMessage = function handleMessage(messages) {
- showMessageOverlay(messages[0]);
+function showMessage(messages) {
+ ensureOverlayDivExists((div) => {
+ // Make it look similar to our terminal.
+ div.innerHTML = `Failed to compile.
${ansiHTML(
+ entities.encode(messages[0])
+ )}`;
+ });
+}
+
+module.exports = {
+ clear,
+ showMessage,
};
diff --git a/client-src/default/socket.js b/client-src/default/socket.js
index 4c8bcbba20..7752ffea8a 100644
--- a/client-src/default/socket.js
+++ b/client-src/default/socket.js
@@ -4,7 +4,19 @@
/* eslint-disable
camelcase
*/
-const Client = __webpack_dev_server_client__;
+
+// this SockJSClient is here as a default fallback, in case inline mode
+// is off or the client is not injected. This will be switched to
+// WebsocketClient when it becomes the default
+
+// important: the path to SockJSClient here is made to work in the 'client'
+// directory, but is updated via the webpack compilation when compiled from
+// the 'client-src' directory
+const Client =
+ typeof __webpack_dev_server_client__ !== 'undefined'
+ ? __webpack_dev_server_client__
+ : // eslint-disable-next-line import/no-unresolved
+ require('./clients/SockJSClient');
let retries = 0;
let client = null;
diff --git a/client-src/default/webpack.config.js b/client-src/default/webpack.config.js
index a0b70901ca..ac001f26d7 100644
--- a/client-src/default/webpack.config.js
+++ b/client-src/default/webpack.config.js
@@ -1,5 +1,7 @@
'use strict';
+const webpack = require('webpack');
+
module.exports = {
mode: 'production',
module: {
@@ -15,4 +17,12 @@ module.exports = {
},
],
},
+ plugins: [
+ new webpack.NormalModuleReplacementPlugin(/\/clients\//, (resource) => {
+ resource.request = resource.request.replace(
+ /\/clients\//,
+ '/../clients/'
+ );
+ }),
+ ],
};
diff --git a/client-src/live/webpack.config.js b/client-src/live/webpack.config.js
index 75e693210a..3887b38b2b 100644
--- a/client-src/live/webpack.config.js
+++ b/client-src/live/webpack.config.js
@@ -1,6 +1,7 @@
'use strict';
const path = require('path');
+const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
@@ -33,5 +34,11 @@ module.exports = {
to: path.resolve(__dirname, '../../client/live.html'),
},
]),
+ new webpack.NormalModuleReplacementPlugin(/\/clients\//, (resource) => {
+ resource.request = resource.request.replace(
+ /\/clients\//,
+ '/../clients/'
+ );
+ }),
],
};
diff --git a/examples/cli/overlay/app.js b/examples/cli/overlay/app.js
index f5e44a9844..c78c71d97e 100644
--- a/examples/cli/overlay/app.js
+++ b/examples/cli/overlay/app.js
@@ -6,4 +6,4 @@ target.classList.add('pass');
target.innerHTML = 'Success!';
// This results in an error:
-// if(!window) require("test");
+// if (!window) require('test');
diff --git a/globalSetupTest.js b/globalSetupTest.js
new file mode 100644
index 0000000000..c82cbb1432
--- /dev/null
+++ b/globalSetupTest.js
@@ -0,0 +1,32 @@
+'use strict';
+
+// eslint-disable-next-line import/no-extraneous-dependencies
+const tcpPortUsed = require('tcp-port-used');
+const ports = require('./test/ports-map');
+
+async function validatePorts() {
+ const samples = [];
+
+ Object.keys(ports).forEach((key) => {
+ const value = ports[key];
+ const arr = Array.isArray(value) ? value : [value];
+
+ arr.forEach((port) => {
+ const check = tcpPortUsed.check(port, 'localhost').then((inUse) => {
+ if (inUse) throw new Error(`${port} has already used. [${key}]`);
+ });
+
+ samples.push(check);
+ });
+ });
+
+ try {
+ await Promise.all(samples);
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error(e);
+ process.exit(1);
+ }
+}
+
+module.exports = validatePorts;
diff --git a/jest.config.js b/jest.config.js
index 322de40ff2..47f4bfd4e7 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -7,4 +7,5 @@ module.exports = {
moduleFileExtensions: ['js', 'json'],
testMatch: ['**/test/**/*.test.js'],
setupFilesAfterEnv: ['/setupTest.js'],
+ globalSetup: '/globalSetupTest.js',
};
diff --git a/lib/options.json b/lib/options.json
index 72e89c8136..349973498b 100644
--- a/lib/options.json
+++ b/lib/options.json
@@ -389,7 +389,7 @@
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
"ca": "should be {String|Buffer}",
"cert": "should be {String|Buffer}",
- "clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
+ "clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'silent', 'info', 'debug', 'trace', 'error', 'warning', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
diff --git a/lib/utils/runOpen.js b/lib/utils/runOpen.js
index b499888356..cf4de34279 100644
--- a/lib/utils/runOpen.js
+++ b/lib/utils/runOpen.js
@@ -3,11 +3,12 @@
const open = require('opn');
function runOpen(uri, options, log) {
- let openOptions = {};
+ // https://github.com/webpack/webpack-dev-server/issues/1990
+ let openOptions = { wait: false };
let openMessage = 'Unable to open browser';
if (typeof options.open === 'string') {
- openOptions = { app: options.open };
+ openOptions = Object.assign({}, openOptions, { app: options.open });
openMessage += `: ${options.open}`;
}
diff --git a/package-lock.json b/package-lock.json
index ec3333ea0a..c01bf0aa50 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "webpack-dev-server",
- "version": "3.7.1",
+ "version": "3.7.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -652,6 +652,26 @@
"@babel/helper-plugin-utils": "^7.0.0"
}
},
+ "@babel/plugin-transform-runtime": {
+ "version": "7.4.4",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.4.4.tgz",
+ "integrity": "sha512-aMVojEjPszvau3NRg+TIH14ynZLvPewH4xhlCW1w6A3rkxTS1m4uwzRclYR9oS+rl/dr+kT+pzbfHuAWP/lc7Q==",
+ "dev": true,
+ "requires": {
+ "@babel/helper-module-imports": "^7.0.0",
+ "@babel/helper-plugin-utils": "^7.0.0",
+ "resolve": "^1.8.1",
+ "semver": "^5.5.1"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "5.7.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
+ "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==",
+ "dev": true
+ }
+ }
+ },
"@babel/plugin-transform-shorthand-properties": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz",
@@ -849,15 +869,15 @@
}
},
"@commitlint/cli": {
- "version": "7.6.1",
- "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-7.6.1.tgz",
- "integrity": "sha512-HEJwQ/aK0AOcAwn77ZKbb/GZhlGxBSPhtVp07uoJFVqM12l2Ia2JHA+MTpfHCFdVahKyYGREZgxde6LyKyG8aQ==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-8.0.0.tgz",
+ "integrity": "sha512-wFu+g9v73I2rMRTv27ItIbcrhWqge0ZpUNUIJ9fw8TF7XpmhaUFvGqa2kU6st1F0TyEOrq5ZMzwI8kQZNVLuXg==",
"dev": true,
"requires": {
- "@commitlint/format": "^7.6.1",
- "@commitlint/lint": "^7.6.0",
- "@commitlint/load": "^7.6.1",
- "@commitlint/read": "^7.6.0",
+ "@commitlint/format": "^8.0.0",
+ "@commitlint/lint": "^8.0.0",
+ "@commitlint/load": "^8.0.0",
+ "@commitlint/read": "^8.0.0",
"babel-polyfill": "6.26.0",
"chalk": "2.3.1",
"get-stdin": "7.0.0",
@@ -896,43 +916,42 @@
}
},
"@commitlint/config-conventional": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-7.6.0.tgz",
- "integrity": "sha512-1Gnv5p3tc1VsEK25oTIRBO86czLtX6s/jeLNPAQRzdCnyEmsxkbx/sfoUJ1dwv7v8W++xckVnnuvdZv2Hp8yCw==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-8.0.0.tgz",
+ "integrity": "sha512-umg1irroowOV+x8oZPBw8woCogZO5MFKUYQq+fRZvhowoSwDHXYILP3ETcdHUgvytw/K/a8Xvu7iCypK6oZQ+g==",
"dev": true
},
"@commitlint/ensure": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-7.6.0.tgz",
- "integrity": "sha512-pSUrNud5L/8y+cLWo3LEa8Ce4bAAR33xMderFUhuNPHj7TwpNS7L4ROMnhL4ZlCYRazCRDlnPaJLPikMoWThfA==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-8.0.0.tgz",
+ "integrity": "sha512-rhBO79L9vXeb26JU+14cxZQq46KyyVqlo31C33VIe7oJndUtWrDhZTvMjJeB1pdXh4EU4XWdMo+yzBmuypFgig==",
"dev": true,
"requires": {
"lodash": "4.17.11"
}
},
"@commitlint/execute-rule": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-7.6.0.tgz",
- "integrity": "sha512-0inGOIlLefPDtiDOaZ6WoE1p+GEZZIj2VwUftUozD3C71TiwP9UfKAVVtUDFPIeL6RgSqCkCf7zsy6NKNxwkBg==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-8.0.0.tgz",
+ "integrity": "sha512-E/A2xHqx3syclXAFl8vJY2o/+xtL9axrqbFFF42Bzke+Eflf0mOJviPxDodu2xP0wXMRQ9UokAi/reK9dMtA/A==",
"dev": true,
"requires": {
"babel-runtime": "6.26.0"
}
},
"@commitlint/format": {
- "version": "7.6.1",
- "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.6.1.tgz",
- "integrity": "sha512-Ldzf5N2Sr9RQqvlYwaQn4vz1WOZ7byYinspC/WCrbfcETGy28j7QE4OueZU6nNB9TjwwEorKm13uy7tDWPR7dg==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-8.0.0.tgz",
+ "integrity": "sha512-dFxKGLp1T4obi7+YZ2NcSAebJA/dBQwnerRJGz0hWtsO6pheJRe+qC50+GCb2fYGWUc5lIWawaRts0m7RkFGUw==",
"dev": true,
"requires": {
- "babel-runtime": "^6.23.0",
"chalk": "^2.0.1"
}
},
"@commitlint/is-ignored": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-7.6.0.tgz",
- "integrity": "sha512-By/mLNhz+6Rtix9+Kyof1gdKiELchAnQHpdeKIHIOe9sjbvd3HqDoFHh/mGMMRnGIPMZOX5TO8Fqy3A/2HqlTw==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-8.0.0.tgz",
+ "integrity": "sha512-geWr/NXGMrZ3qc3exDM+S1qV+nMDxp1LwN3rLpEN2gXTwW3rIXq49RQQUkn0n3BHcpqJJ9EBhjqFoMU1TYx7Ng==",
"dev": true,
"requires": {
"semver": "6.0.0"
@@ -947,26 +966,26 @@
}
},
"@commitlint/lint": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-7.6.0.tgz",
- "integrity": "sha512-aUIFX0lPRZL7WmT8W8qzogJD4LmHk6JPG3XUAX+K0pOHGjC/0ALvSAytvoLXy4fvmSnGJkXmWhzSW7c0Spa14Q==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-8.0.0.tgz",
+ "integrity": "sha512-5nKiJpBDR2iei+fre4+6M7FUrSX1cIMoxXKdrnb1GMOXkw9CsZSF5OvdrX08zHAFmOAeDaohoCV+XN/UN/vWYg==",
"dev": true,
"requires": {
- "@commitlint/is-ignored": "^7.6.0",
- "@commitlint/parse": "^7.6.0",
- "@commitlint/rules": "^7.6.0",
+ "@commitlint/is-ignored": "^8.0.0",
+ "@commitlint/parse": "^8.0.0",
+ "@commitlint/rules": "^8.0.0",
"babel-runtime": "^6.23.0",
"lodash": "4.17.11"
}
},
"@commitlint/load": {
- "version": "7.6.2",
- "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-7.6.2.tgz",
- "integrity": "sha512-I+xk+BkXAG1roXNrPsR1eOd5hEa+oLc6HLYnHAT/HLGKKB3E01IGg3O5SGlg7lpf1yiAaYI+wAnNTr3f3sIbWQ==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/load/-/load-8.0.0.tgz",
+ "integrity": "sha512-JXC3YjO7hN7Rv2Z/SaYz+oIvShsQWLL7gnOCe8+YgI1EusBqjV4mPI0HnBXVe9volfdxbl+Af/GoQZs2dvyOFA==",
"dev": true,
"requires": {
- "@commitlint/execute-rule": "^7.6.0",
- "@commitlint/resolve-extends": "^7.6.0",
+ "@commitlint/execute-rule": "^8.0.0",
+ "@commitlint/resolve-extends": "^8.0.0",
"babel-runtime": "^6.23.0",
"cosmiconfig": "^5.2.0",
"lodash": "4.17.11",
@@ -982,15 +1001,15 @@
}
},
"@commitlint/message": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-7.6.0.tgz",
- "integrity": "sha512-PtP4jhBYGXLaQQC5jel+RQczG2tS3Cy6rRxQioUfCUaEg/LV029ao/KcL1kHEBJ8hSW/SUmnvDaD9Y6nozLQMA==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/message/-/message-8.0.0.tgz",
+ "integrity": "sha512-2oGUV8630nzsj17t6akq3mFguzWePADO069IwKJi+CN5L0YRBQj9zGRCB0P+zvh4EngjqMnuMwhEhaBEM8TTzA==",
"dev": true
},
"@commitlint/parse": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-7.6.0.tgz",
- "integrity": "sha512-1x60kTqz2VBCjYE+8MV5BhE+ShPo7MgVlrMWSlxiiJDWP5CvWa+SBbUayDJ7rtOXimjTASZ9ZNZTuFPdJE/Y7A==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-8.0.0.tgz",
+ "integrity": "sha512-6CyweJrBkI+Jqx7qkpYgVx2muBMoUZAZHWhUTgqHIDDmI+3d4UPZ2plGS2G0969KkHCgjtlwnwTjWqA9HLMwPA==",
"dev": true,
"requires": {
"conventional-changelog-angular": "^1.3.3",
@@ -999,21 +1018,21 @@
}
},
"@commitlint/read": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-7.6.0.tgz",
- "integrity": "sha512-OyligtK/e4xnQklrQqTcSMM27eNhq+LqXfoeVouuPx059oDEw9wZYNN4HGzyxs4Pb6GdMpzRHLdeMQ24M+AiYw==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/read/-/read-8.0.0.tgz",
+ "integrity": "sha512-IhNMiKPqkB5yxphe/FiOKgX2uCysbR8fGK6KOXON3uJaVND0dctxnfdv+vY9gDv2CtjIXgNFO+v6FLnqMfIvwA==",
"dev": true,
"requires": {
- "@commitlint/top-level": "^7.6.0",
+ "@commitlint/top-level": "^8.0.0",
"@marionebl/sander": "^0.6.0",
"babel-runtime": "^6.23.0",
"git-raw-commits": "^1.3.0"
}
},
"@commitlint/resolve-extends": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-7.6.0.tgz",
- "integrity": "sha512-fk8KvNiEbRc+p8nPFuysVP2O95+sb8vlIDTjqtGVObqrzFINRfERXwqBmTBtcu556BoDAR2hwRVXmuwhns+Duw==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-8.0.0.tgz",
+ "integrity": "sha512-SPkH+dXMCpYboVwpIhtOhpg1xYdE7L77fuHmEJWveXSmgfi0GosFm4aJ7Cer9DjNjW+KbD0TUfzZU0TrYUESjQ==",
"dev": true,
"requires": {
"babel-runtime": "6.26.0",
@@ -1032,27 +1051,27 @@
}
},
"@commitlint/rules": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-7.6.0.tgz",
- "integrity": "sha512-shLJdMUwdVeE5UgOE8E+c+PFS7+0FFGfheMa3s6ZK+xX8pTUxseXZu9iCF4mwF+WWkVk518xPuNLvmYE96salQ==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-8.0.0.tgz",
+ "integrity": "sha512-s9BehZQP5uAc/V4lMaUxwxFabVZTw5fZ18Ase1e5tbMKVIwq/7E00Ny1czN7xSFXfgffukWznsexpfFXYpbVsg==",
"dev": true,
"requires": {
- "@commitlint/ensure": "^7.6.0",
- "@commitlint/message": "^7.6.0",
- "@commitlint/to-lines": "^7.6.0",
+ "@commitlint/ensure": "^8.0.0",
+ "@commitlint/message": "^8.0.0",
+ "@commitlint/to-lines": "^8.0.0",
"babel-runtime": "^6.23.0"
}
},
"@commitlint/to-lines": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-7.6.0.tgz",
- "integrity": "sha512-L/Vl5ThRuBHnSNZBtc+p2LCs2ayxWodC+I/X3NKUywSmr6kKpJJCFqHHHqPu+yXwGUPwqCMQhogIGLuv9TtWWw==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-8.0.0.tgz",
+ "integrity": "sha512-qqgNeyj+NJ1Xffwv6hGsipKlVFj30NmfPup751MS/me0GV8IBd//njTjiqHvf/3sKm/OcGn4Re4D7YXwTcC2RA==",
"dev": true
},
"@commitlint/top-level": {
- "version": "7.6.0",
- "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-7.6.0.tgz",
- "integrity": "sha512-R2RzJZDuT2TU2dZMrRd7olax5IDVcUB/O8k76d1LW13CQ9/2ArJi3TCFXSZIaGpCUnyAYA5KiCZ+c1opnyQuog==",
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-8.0.0.tgz",
+ "integrity": "sha512-If9hwfISHV8HXGKeXUKsUvOo4DuISWiU/VC2qHsKpeHSREAxkWESmQzzwYvOtyBjMiOTfAXfzgth18g36Fz2ow==",
"dev": true,
"requires": {
"find-up": "^2.1.0"
@@ -2050,12 +2069,6 @@
"regenerator-runtime": "^0.10.5"
},
"dependencies": {
- "core-js": {
- "version": "2.6.5",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
- "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==",
- "dev": true
- },
"regenerator-runtime": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz",
@@ -2082,14 +2095,6 @@
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
- },
- "dependencies": {
- "core-js": {
- "version": "2.6.5",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.5.tgz",
- "integrity": "sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A==",
- "dev": true
- }
}
},
"balanced-match": {
@@ -3479,6 +3484,12 @@
}
}
},
+ "core-js": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
+ "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
+ "dev": true
+ },
"core-js-compat": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.1.2.tgz",
@@ -4322,9 +4333,9 @@
}
},
"eslint-config-prettier": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-4.3.0.tgz",
- "integrity": "sha512-sZwhSTHVVz78+kYD3t5pCWSYEdVSBR0PXnwjDRsUs8ytIrK8PLXw+6FKp8r3Z7rx4ZszdetWlXYKOHoUrrwPlA==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-5.0.0.tgz",
+ "integrity": "sha512-c17Aqiz5e8LEqoc/QPmYnaxQFAHTx2KlCZBPxXXjEMmNchOLnV/7j0HoPZuC+rL/tDC9bazUYOKJW9bOhftI/w==",
"dev": true,
"requires": {
"get-stdin": "^6.0.0"
@@ -6578,9 +6589,9 @@
}
},
"husky": {
- "version": "2.4.0",
- "resolved": "https://registry.npmjs.org/husky/-/husky-2.4.0.tgz",
- "integrity": "sha512-3k1wuZU20gFkphNWMjh2ISCFaqfbaLY7R9FST2Mj9HeRhUK9ydj9qQR8qfXlog3EctVGsyeilcZkIT7uBZDDVA==",
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-2.4.1.tgz",
+ "integrity": "sha512-ZRwMWHr7QruR22dQ5l3rEGXQ7rAQYsJYqaeCd+NyOsIFczAtqaApZQP3P4HwLZjCtFbm3SUNYoKuoBXX3AYYfw==",
"dev": true,
"requires": {
"cosmiconfig": "^5.2.0",
@@ -6746,12 +6757,6 @@
"integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=",
"dev": true
},
- "indexof": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz",
- "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
- "dev": true
- },
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@@ -7109,6 +7114,12 @@
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
+ "is-url": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz",
+ "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==",
+ "dev": true
+ },
"is-utf8": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
@@ -7125,6 +7136,17 @@
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz",
"integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0="
},
+ "is2": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is2/-/is2-2.0.1.tgz",
+ "integrity": "sha512-+WaJvnaA7aJySz2q/8sLjMb2Mw14KTplHmSwcSpZ/fWJPkUmqw3YTzSWbPJ7OAwRvdYTWF2Wg+yYJ1AdP5Z8CA==",
+ "dev": true,
+ "requires": {
+ "deep-is": "^0.1.3",
+ "ip-regex": "^2.1.0",
+ "is-url": "^1.2.2"
+ }
+ },
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@@ -7908,9 +7930,9 @@
}
},
"lint-staged": {
- "version": "8.2.0",
- "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-8.2.0.tgz",
- "integrity": "sha512-DxguyxGOIfb67wZ6EOrqzjAbw6ZH9XK3YS74HO+erJf6+SAQeJJPN//GBOG5xhdt2THeuXjVPaHcCYOWGZwRbA==",
+ "version": "8.2.1",
+ "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-8.2.1.tgz",
+ "integrity": "sha512-n0tDGR/rTCgQNwXnUf/eWIpPNddGWxC32ANTNYsj2k02iZb7Cz5ox2tytwBu+2r0zDXMEMKw7Y9OD/qsav561A==",
"dev": true,
"requires": {
"chalk": "^2.3.1",
@@ -7987,9 +8009,9 @@
}
},
"ms": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
- "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==",
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"p-map": {
@@ -8256,9 +8278,9 @@
}
},
"loglevel": {
- "version": "1.6.2",
- "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.2.tgz",
- "integrity": "sha512-Jt2MHrCNdtIe1W6co3tF5KXGRkzF+TYffiQstfXa04mrss9IKXzAAXYWak8LbZseAQY03sH2GzMCMU0ZOUc9bg=="
+ "version": "1.6.3",
+ "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.3.tgz",
+ "integrity": "sha512-LoEDv5pgpvWgPF4kNYuIp0qqSJVWak/dML0RY74xlzMZiT9w77teNAwKYKWBTYjlokMirg+o3jBwp+vlLrcfAA=="
},
"loose-envify": {
"version": "1.4.0",
@@ -8717,9 +8739,9 @@
"dev": true
},
"node-libs-browser": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.0.tgz",
- "integrity": "sha512-5MQunG/oyOaBdttrL40dA7bUfPORLRWMUJLQtMg7nluxUvk5XwnLdL9twQHFAjRx/y7mIMkLKT9++qPbbk6BZA==",
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz",
+ "integrity": "sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==",
"dev": true,
"requires": {
"assert": "^1.1.1",
@@ -8732,7 +8754,7 @@
"events": "^3.0.0",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
- "path-browserify": "0.0.0",
+ "path-browserify": "0.0.1",
"process": "^0.11.10",
"punycode": "^1.2.4",
"querystring-es3": "^0.2.0",
@@ -8744,7 +8766,7 @@
"tty-browserify": "0.0.0",
"url": "^0.11.0",
"util": "^0.11.0",
- "vm-browserify": "0.0.4"
+ "vm-browserify": "^1.0.1"
},
"dependencies": {
"punycode": {
@@ -9242,9 +9264,9 @@
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ="
},
"path-browserify": {
- "version": "0.0.0",
- "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
- "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
+ "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
"dev": true
},
"path-dirname": {
@@ -9489,9 +9511,9 @@
"dev": true
},
"prettier": {
- "version": "1.18.0",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.0.tgz",
- "integrity": "sha512-YsdAD29M0+WY2xXZk3i0PA16olY9qZss+AuODxglXcJ+2ZBwFv+6k5tE8GS8/HKAthaajlS/WqhdgcjumOrPlg==",
+ "version": "1.18.2",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz",
+ "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==",
"dev": true
},
"pretty-error": {
@@ -11295,6 +11317,33 @@
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==",
"dev": true
},
+ "tcp-port-used": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/tcp-port-used/-/tcp-port-used-1.0.1.tgz",
+ "integrity": "sha512-rwi5xJeU6utXoEIiMvVBMc9eJ2/ofzB+7nLOdnZuFTmNCLqRiQh2sMG9MqCxHU/69VC/Fwp5dV9306Qd54ll1Q==",
+ "dev": true,
+ "requires": {
+ "debug": "4.1.0",
+ "is2": "2.0.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz",
+ "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==",
+ "dev": true,
+ "requires": {
+ "ms": "^2.1.1"
+ }
+ },
+ "ms": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "dev": true
+ }
+ }
+ },
"terser": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.0.0.tgz",
@@ -11883,13 +11932,10 @@
}
},
"vm-browserify": {
- "version": "0.0.4",
- "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
- "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
- "dev": true,
- "requires": {
- "indexof": "0.0.1"
- }
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz",
+ "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==",
+ "dev": true
},
"w3c-hr-time": {
"version": "1.0.1",
@@ -11935,9 +11981,9 @@
"dev": true
},
"webpack": {
- "version": "4.33.0",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.33.0.tgz",
- "integrity": "sha512-ggWMb0B2QUuYso6FPZKUohOgfm+Z0sVFs8WwWuSH1IAvkWs428VDNmOlAxvHGTB9Dm/qOB/qtE5cRx5y01clxw==",
+ "version": "4.34.0",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.34.0.tgz",
+ "integrity": "sha512-ry2IQy1wJjOefLe1uJLzn5tG/DdIKzQqNlIAd2L84kcaADqNvQDTBlo8UcCNyDaT5FiaB+16jhAkb63YeG3H8Q==",
"dev": true,
"requires": {
"@webassemblyjs/ast": "1.8.5",
@@ -11967,9 +12013,9 @@
}
},
"webpack-cli": {
- "version": "3.3.3",
- "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.3.tgz",
- "integrity": "sha512-/qBxTvsxZ7bIFQtSa08QRY5BZuiJb27cbJM/nzmgXg9NEaudP20D7BruKKIuWfABqWoMEJQcNYYq/OxxSbPHlg==",
+ "version": "3.3.4",
+ "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.4.tgz",
+ "integrity": "sha512-ubJGQEKMtBSpT+LiL5hXvn2GIOWiRWItR1DGUqJRhwRBeGhpRXjvF5f0erqdRJLErkfqS5/Ldkkedh4AL5Q1ZQ==",
"dev": true,
"requires": {
"chalk": "^2.4.1",
diff --git a/package.json b/package.json
index 7d28030ae0..715246c308 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "webpack-dev-server",
- "version": "3.7.1",
+ "version": "3.7.2",
"description": "Serves a webpack app. Updates the browser on changes.",
"bin": "bin/webpack-dev-server.js",
"main": "lib/Server.js",
@@ -19,7 +19,7 @@
"lint": "npm-run-all -l -p \"lint:**\"",
"commitlint": "commitlint --from=master",
"security": "npm audit",
- "test:only": "jest --runInBand",
+ "test:only": "jest",
"test:coverage": "npm run test:only -- --coverage",
"test:watch": "npm run test:coverage --watch",
"test": "npm run test:coverage",
@@ -49,7 +49,7 @@
"internal-ip": "^4.3.0",
"ip": "^1.1.5",
"killable": "^1.0.1",
- "loglevel": "^1.6.2",
+ "loglevel": "^1.6.3",
"opn": "^5.5.0",
"p-retry": "^3.0.1",
"portfinder": "^1.0.20",
@@ -70,41 +70,43 @@
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
+ "@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
- "@commitlint/cli": "^7.6.1",
- "@commitlint/config-conventional": "^7.6.0",
+ "@commitlint/cli": "^8.0.0",
+ "@commitlint/config-conventional": "^8.0.0",
"babel-loader": "^8.0.6",
"body-parser": "^1.19.0",
"commitlint-azure-pipelines-cli": "^1.0.2",
"copy-webpack-plugin": "^5.0.3",
"css-loader": "^2.1.1",
"eslint": "^5.16.0",
- "eslint-config-prettier": "^4.3.0",
+ "eslint-config-prettier": "^5.0.0",
"eslint-config-webpack": "^1.2.5",
"eslint-plugin-import": "^2.17.3",
"execa": "^1.0.0",
"file-loader": "^3.0.1",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
- "husky": "^2.4.0",
+ "husky": "^2.4.1",
"jest": "^24.8.0",
"jest-junit": "^6.4.0",
"jquery": "^3.4.1",
"less": "^3.9.0",
"less-loader": "^5.0.0",
- "lint-staged": "^8.2.0",
+ "lint-staged": "^8.2.1",
"marked": "^0.6.2",
"memfs": "^2.15.4",
"npm-run-all": "^4.1.5",
- "prettier": "^1.18.0",
+ "prettier": "^1.18.2",
"puppeteer": "^1.17.0",
"rimraf": "^2.6.3",
"standard-version": "^6.0.1",
"style-loader": "^0.23.1",
"supertest": "^4.0.2",
+ "tcp-port-used": "^1.0.1",
"url-loader": "^1.1.2",
- "webpack": "^4.33.0",
- "webpack-cli": "^3.3.3",
+ "webpack": "^4.34.0",
+ "webpack-cli": "^3.3.4",
"ws": "^6.2.1"
},
"peerDependencies": {
diff --git a/renovate.json b/renovate.json
index acca69e7d4..3cc63bb62c 100644
--- a/renovate.json
+++ b/renovate.json
@@ -1,5 +1,6 @@
{
"extends": ["config:base", ":semanticCommitTypeAll(chore)"],
+ "baseBranches": ["master", "next"],
"labels": ["renovate"],
"minor": {
"groupName": "all minor dependencies"
@@ -13,6 +14,11 @@
{
"depTypeList": ["peerDependencies"],
"enabled": false
+ },
+ {
+ "baseBranchList": ["next"],
+ "updateTypes": ["digest", "pin", "patch", "minor"],
+ "enabled": false
}
]
}
diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js
index 0a009c3503..8bd1e04ddd 100644
--- a/test/cli/cli.test.js
+++ b/test/cli/cli.test.js
@@ -162,8 +162,10 @@ describe('CLI', () => {
const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js');
const examplePath = resolve(__dirname, '../../examples/cli/public');
- const cp = execa('node', [cliPath], { cwd: examplePath });
- const cp2 = execa('node', [cliPath], { cwd: examplePath });
+ const cp = execa('node', [cliPath, '--colors=false'], { cwd: examplePath });
+ const cp2 = execa('node', [cliPath, '--colors=false'], {
+ cwd: examplePath,
+ });
const runtime = {
cp: {
diff --git a/test/client/__snapshots__/overlay.test.js.snap b/test/client/__snapshots__/overlay.test.js.snap
new file mode 100644
index 0000000000..3262ac5631
--- /dev/null
+++ b/test/client/__snapshots__/overlay.test.js.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`overlay should run clear 1`] = `"Failed to compile.
test!
"`;
+
+exports[`overlay should run clear 2`] = `""`;
+
+exports[`overlay should run showMessage 1`] = `""`;
+
+exports[`overlay should run showMessage 2`] = `"Failed to compile.
test!
"`;
diff --git a/test/client/clients/SockJSClient.test.js b/test/client/clients/SockJSClient.test.js
index ceb6fdc26e..a5b667c03a 100644
--- a/test/client/clients/SockJSClient.test.js
+++ b/test/client/clients/SockJSClient.test.js
@@ -4,6 +4,7 @@ const http = require('http');
const express = require('express');
const sockjs = require('sockjs');
const SockJSClient = require('../../../client-src/clients/SockJSClient');
+const port = require('../../ports-map').sockJSClient;
describe('SockJSClient', () => {
let socketServer;
@@ -14,7 +15,7 @@ describe('SockJSClient', () => {
const app = new express();
listeningApp = http.createServer(app);
- listeningApp.listen(8080, 'localhost', () => {
+ listeningApp.listen(port, 'localhost', () => {
socketServer = sockjs.createServer();
socketServer.installHandlers(listeningApp, {
prefix: '/sockjs-node',
@@ -33,7 +34,7 @@ describe('SockJSClient', () => {
}, 1000);
});
- const client = new SockJSClient('http://localhost:8080/sockjs-node');
+ const client = new SockJSClient(`http://localhost:${port}/sockjs-node`);
const data = [];
client.onOpen(() => {
diff --git a/test/client/overlay.test.js b/test/client/overlay.test.js
new file mode 100644
index 0000000000..0dbb32b7e5
--- /dev/null
+++ b/test/client/overlay.test.js
@@ -0,0 +1,27 @@
+'use strict';
+
+const overlay = require('../../client-src/default/overlay');
+
+describe('overlay', () => {
+ it('should run showMessage', () => {
+ expect(document.body.innerHTML).toMatchSnapshot();
+
+ overlay.showMessage(['test!']);
+
+ expect(
+ document.getElementsByTagName('iframe')[0].contentDocument.body.innerHTML
+ ).toMatchSnapshot();
+ });
+
+ it('should run clear', () => {
+ overlay.showMessage(['test!']);
+
+ expect(
+ document.getElementsByTagName('iframe')[0].contentDocument.body.innerHTML
+ ).toMatchSnapshot();
+
+ overlay.clear();
+
+ expect(document.body.innerHTML).toMatchSnapshot();
+ });
+});
diff --git a/test/e2e/Client.test.js b/test/e2e/Client.test.js
index 855d76b1e1..90eb2ffe5a 100644
--- a/test/e2e/Client.test.js
+++ b/test/e2e/Client.test.js
@@ -8,6 +8,7 @@ const { resolve } = require('path');
const testServer = require('../helpers/test-server');
const reloadConfig = require('../fixtures/reload-config/webpack.config');
const runBrowser = require('../helpers/run-browser');
+const port = require('../ports-map').Client;
const cssFilePath = resolve(__dirname, '../fixtures/reload-config/main.css');
@@ -19,7 +20,7 @@ describe('reload', () => {
'body { background-color: rgb(0, 0, 255); }'
);
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: true,
hot: true,
@@ -47,14 +48,12 @@ describe('reload', () => {
return bgColor;
})
.then((color) => {
- expect(color).toEqual('rgb(0, 0, 255)');
-
page.setRequestInterception(true).then(() => {
page.on('request', (req) => {
if (
req.isNavigationRequest() &&
req.frame() === page.mainFrame() &&
- req.url() === 'http://localhost:9000/main'
+ req.url() === `http://localhost:${port}/main`
) {
refreshed = true;
}
@@ -65,8 +64,6 @@ describe('reload', () => {
'body { background-color: rgb(255, 0, 0); }'
);
page.waitFor(10000).then(() => {
- expect(refreshed).toBeFalsy();
-
page
.evaluate(() => {
const body = document.body;
@@ -76,15 +73,19 @@ describe('reload', () => {
return bgColor;
})
.then((color2) => {
- expect(color2).toEqual('rgb(255, 0, 0)');
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(color).toEqual('rgb(0, 0, 255)');
+ expect(color2).toEqual('rgb(255, 0, 0)');
+ expect(refreshed).toBeFalsy();
+ done();
+ });
});
});
});
});
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port}/main`);
});
});
});
@@ -97,7 +98,7 @@ describe('reload', () => {
'body { background-color: rgb(0, 0, 255); }'
);
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: true,
hot: false,
@@ -125,14 +126,12 @@ describe('reload', () => {
return bgColor;
})
.then((color) => {
- expect(color).toEqual('rgb(0, 0, 255)');
-
page.setRequestInterception(true).then(() => {
page.on('request', (req) => {
if (
req.isNavigationRequest() &&
req.frame() === page.mainFrame() &&
- req.url() === 'http://localhost:9000/main'
+ req.url() === `http://localhost:${port}/main`
) {
refreshed = true;
}
@@ -143,8 +142,6 @@ describe('reload', () => {
'body { background-color: rgb(255, 0, 0); }'
);
page.waitFor(10000).then(() => {
- expect(refreshed).toBeTruthy();
-
page
.evaluate(() => {
const body = document.body;
@@ -154,15 +151,19 @@ describe('reload', () => {
return bgColor;
})
.then((color2) => {
- expect(color2).toEqual('rgb(255, 0, 0)');
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(color).toEqual('rgb(0, 0, 255)');
+ expect(color2).toEqual('rgb(255, 0, 0)');
+ expect(refreshed).toBeTruthy();
+ done();
+ });
});
});
});
});
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port}/main`);
});
});
});
diff --git a/test/e2e/ClientOptions.test.js b/test/e2e/ClientOptions.test.js
index 2e643c516f..07d3bba8d9 100644
--- a/test/e2e/ClientOptions.test.js
+++ b/test/e2e/ClientOptions.test.js
@@ -6,6 +6,7 @@ const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/client-config/webpack.config');
const runBrowser = require('../helpers/run-browser');
+const [port1, port2, port3] = require('../ports-map').ClientOptions;
describe('Client code', () => {
function startProxy(port) {
@@ -13,7 +14,7 @@ describe('Client code', () => {
proxy.use(
'/',
httpProxy({
- target: 'http://localhost:9001',
+ target: `http://localhost:${port1}`,
ws: true,
changeOrigin: true,
})
@@ -24,7 +25,7 @@ describe('Client code', () => {
beforeAll((done) => {
const options = {
compress: true,
- port: 9001,
+ port: port1,
host: '0.0.0.0',
disableHostCheck: true,
inline: true,
@@ -38,12 +39,12 @@ describe('Client code', () => {
afterAll(testServer.close);
- // [HPM] Proxy created: / -> http://localhost:9001
+ // [HPM] Proxy created: / -> http://localhost:{port1}
describe('behind a proxy', () => {
let proxy;
beforeAll(() => {
- proxy = startProxy(9000);
+ proxy = startProxy(port2);
});
afterAll((done) => {
@@ -54,11 +55,11 @@ describe('Client code', () => {
it('responds with a 200', (done) => {
{
- const req = request('http://localhost:9000');
+ const req = request(`http://localhost:${port2}`);
req.get('/sockjs-node').expect(200, 'Welcome to SockJS!\n', done);
}
{
- const req = request('http://localhost:9001');
+ const req = request(`http://localhost:${port1}`);
req.get('/sockjs-node').expect(200, 'Welcome to SockJS!\n', done);
}
});
@@ -68,12 +69,16 @@ describe('Client code', () => {
page
.waitForRequest((requestObj) => requestObj.url().match(/sockjs-node/))
.then((requestObj) => {
- expect(requestObj.url()).toMatch(
- /^http:\/\/localhost:9001\/sockjs-node/
- );
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(
+ requestObj
+ .url()
+ .includes(`http://localhost:${port1}/sockjs-node`)
+ ).toBeTruthy();
+ done();
+ });
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port2}/main`);
});
});
});
@@ -82,7 +87,7 @@ describe('Client code', () => {
describe('Client complex inline script path', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port: port2,
host: '0.0.0.0',
inline: true,
watchOptions: {
@@ -104,12 +109,16 @@ describe('Client complex inline script path', () => {
requestObj.url().match(/foo\/test\/bar/)
)
.then((requestObj) => {
- expect(requestObj.url()).toMatch(
- /^http:\/\/myhost\.test:9000\/foo\/test\/bar/
- );
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(
+ requestObj
+ .url()
+ .includes(`http://myhost.test:${port2}/foo/test/bar/`)
+ ).toBeTruthy();
+ done();
+ });
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port2}/main`);
});
});
});
@@ -118,14 +127,14 @@ describe('Client complex inline script path', () => {
describe('Client complex inline script path with sockPort', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port: port2,
host: '0.0.0.0',
inline: true,
watchOptions: {
poll: true,
},
sockPath: '/foo/test/bar/',
- sockPort: 8080,
+ sockPort: port3,
};
testServer.startAwaitingCompilation(config, options, done);
});
@@ -140,30 +149,35 @@ describe('Client complex inline script path with sockPort', () => {
requestObj.url().match(/foo\/test\/bar/)
)
.then((requestObj) => {
- expect(requestObj.url()).toMatch(
- /^http:\/\/localhost:8080\/foo\/test\/bar/
- );
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(
+ requestObj
+ .url()
+ .includes(`http://localhost:${port3}/foo/test/bar`)
+ ).toBeTruthy();
+ done();
+ });
});
- page.goto('http://localhost:9000/main');
+
+ page.goto(`http://localhost:${port2}/main`);
});
});
});
});
// previously, using sockPort without sockPath had the ability
-// to alter the sockPath (based on a bug in client-src/index.js)
+// to alter the sockPath (based on a bug in client-src/default/index.js)
// so we need to make sure sockPath is not altered in this case
describe('Client complex inline script path with sockPort, no sockPath', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port: port2,
host: '0.0.0.0',
inline: true,
watchOptions: {
poll: true,
},
- sockPort: 8080,
+ sockPort: port3,
};
testServer.startAwaitingCompilation(config, options, done);
});
@@ -176,12 +190,16 @@ describe('Client complex inline script path with sockPort, no sockPath', () => {
page
.waitForRequest((requestObj) => requestObj.url().match(/sockjs-node/))
.then((requestObj) => {
- expect(requestObj.url()).toMatch(
- /^http:\/\/localhost:8080\/sockjs-node/
- );
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(
+ requestObj
+ .url()
+ .includes(`http://localhost:${port3}/sockjs-node`)
+ ).toBeTruthy();
+ done();
+ });
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port2}/main`);
});
});
});
@@ -190,7 +208,7 @@ describe('Client complex inline script path with sockPort, no sockPath', () => {
describe('Client complex inline script path with sockHost', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port: port2,
host: '0.0.0.0',
inline: true,
watchOptions: {
@@ -209,12 +227,16 @@ describe('Client complex inline script path with sockHost', () => {
page
.waitForRequest((requestObj) => requestObj.url().match(/sockjs-node/))
.then((requestObj) => {
- expect(requestObj.url()).toMatch(
- /^http:\/\/myhost\.test:9000\/sockjs-node/
- );
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(
+ requestObj
+ .url()
+ .includes(`http://myhost.test:${port2}/sockjs-node`)
+ ).toBeTruthy();
+ done();
+ });
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port2}/main`);
});
});
});
@@ -222,7 +244,7 @@ describe('Client complex inline script path with sockHost', () => {
describe('Client console.log', () => {
const baseOptions = {
- port: 9000,
+ port: port2,
host: '0.0.0.0',
};
const cases = [
@@ -273,14 +295,16 @@ describe('Client console.log', () => {
.then(runBrowser)
.then(({ page, browser }) => {
return new Promise((resolve) => {
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port2}/main`);
page.on('console', ({ _text }) => {
res.push(_text);
});
setTimeout(() => {
- expect(res).toMatchSnapshot();
- browser.close().then(resolve);
- }, 3000);
+ browser.close().then(() => {
+ expect(res).toMatchSnapshot();
+ resolve();
+ });
+ }, 1000);
});
})
.then(() => {
diff --git a/test/e2e/ProvidePlugin.test.js b/test/e2e/ProvidePlugin.test.js
index bdb7f52d32..99d44cf910 100644
--- a/test/e2e/ProvidePlugin.test.js
+++ b/test/e2e/ProvidePlugin.test.js
@@ -3,12 +3,13 @@
const testServer = require('../helpers/test-server');
const config = require('../fixtures/provide-plugin-config/webpack.config');
const runBrowser = require('../helpers/run-browser');
+const port = require('../ports-map').ProvidePlugin;
-describe.skip('ProvidePlugin', () => {
+describe('ProvidePlugin', () => {
describe('inline', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: true,
watchOptions: {
@@ -29,11 +30,13 @@ describe.skip('ProvidePlugin', () => {
return window.injectedClient === window.expectedClient;
})
.then((isCorrectClient) => {
- expect(isCorrectClient).toBeTruthy();
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(isCorrectClient).toBeTruthy();
+ done();
+ });
});
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port}/main`);
});
});
});
@@ -42,7 +45,7 @@ describe.skip('ProvidePlugin', () => {
describe('not inline', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: false,
watchOptions: {
@@ -64,11 +67,13 @@ describe.skip('ProvidePlugin', () => {
return window.injectedClient === undefined;
})
.then((isCorrectClient) => {
- expect(isCorrectClient).toBeTruthy();
- browser.close().then(done);
+ browser.close().then(() => {
+ expect(isCorrectClient).toBeTruthy();
+ done();
+ });
});
});
- page.goto('http://localhost:9000/main');
+ page.goto(`http://localhost:${port}/main`);
});
});
});
diff --git a/test/fixtures/provide-plugin-config/foo.js b/test/fixtures/provide-plugin-config/foo.js
index 08bdffd71e..4b70afc8ca 100644
--- a/test/fixtures/provide-plugin-config/foo.js
+++ b/test/fixtures/provide-plugin-config/foo.js
@@ -1,6 +1,7 @@
'use strict';
-const SockJSClient = require('../../../client-src/clients/SockJSClient');
+// 'npm run prepare' must be run for this to work during testing
+const SockJSClient = require('../../../client/clients/SockJSClient');
window.expectedClient = SockJSClient;
// eslint-disable-next-line camelcase, no-undef
diff --git a/test/integration/MultiCompiler.test.js b/test/integration/MultiCompiler.test.js
index 2b203a7065..5d9cc9c15b 100644
--- a/test/integration/MultiCompiler.test.js
+++ b/test/integration/MultiCompiler.test.js
@@ -3,13 +3,14 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/multi-compiler-config/webpack.config');
+const port = require('../ports-map').MultiCompiler;
describe('multi compiler', () => {
let server;
let req;
beforeAll((done) => {
- server = testServer.start(config, {}, done);
+ server = testServer.start(config, { port }, done);
req = request(server.app);
});
diff --git a/test/integration/UniversalCompiler.test.js b/test/integration/UniversalCompiler.test.js
index 1eaec5ed70..81225c3ad1 100644
--- a/test/integration/UniversalCompiler.test.js
+++ b/test/integration/UniversalCompiler.test.js
@@ -3,13 +3,14 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/universal-compiler-config/webpack.config');
+const port = require('../ports-map').UniversalCompiler;
describe('universal compiler', () => {
let server;
let req;
beforeAll((done) => {
- server = testServer.start(config, { inline: true }, done);
+ server = testServer.start(config, { inline: true, port }, done);
req = request(server.app);
});
diff --git a/test/options.test.js b/test/options.test.js
index 11e118718b..7e59879bb0 100644
--- a/test/options.test.js
+++ b/test/options.test.js
@@ -10,6 +10,8 @@ const SockJSServer = require('../lib/servers/SockJSServer');
const config = require('./fixtures/simple-config/webpack.config');
describe('options', () => {
+ jest.setTimeout(20000);
+
it('should match properties and errorMessage', () => {
const properties = Object.keys(options.properties);
const messages = Object.keys(options.errorMessage.properties);
diff --git a/test/ports-map.js b/test/ports-map.js
new file mode 100644
index 0000000000..eee60008e4
--- /dev/null
+++ b/test/ports-map.js
@@ -0,0 +1,52 @@
+'use strict';
+
+// test-file-name: the number of ports
+const portsList = {
+ cli: 2,
+ sockJSClient: 1,
+ SockJSServer: 1,
+ Client: 1,
+ ClientOptions: 3,
+ MultiCompiler: 1,
+ UniversalCompiler: 1,
+ Server: 1,
+ routes: 1,
+ createDomain: 2,
+ 'after-option': 1,
+ 'before-option': 1,
+ 'compress-option': 1,
+ 'contentBase-option': 1,
+ 'headers-option': 1,
+ 'historyApiFallback-option': 1,
+ 'host-option': 1,
+ 'hot-option': 1,
+ 'hotOnly-option': 1,
+ 'http2-option': 1,
+ 'https-option': 1,
+ 'inline-option': 1,
+ 'lazy-option': 1,
+ 'liveReload-option': 1,
+ 'mineTypes-option': 1,
+ 'onListening-option': 1,
+ 'open-option': 1,
+ 'port-option': 1,
+ 'proxy-option': 4,
+ 'serverMode-option': 1,
+ 'sockPath-option': 1,
+ 'stats-option': 1,
+ ProvidePlugin: 1,
+};
+
+let startPort = 8079;
+const ports = {};
+
+Object.keys(portsList).forEach((key) => {
+ const value = portsList[key];
+
+ ports[key] =
+ value === 1
+ ? (startPort += 1)
+ : [...new Array(value)].map(() => (startPort += 1));
+});
+
+module.exports = ports;
diff --git a/test/server/Server.test.js b/test/server/Server.test.js
index b2b44731e2..487942e212 100644
--- a/test/server/Server.test.js
+++ b/test/server/Server.test.js
@@ -6,6 +6,7 @@ const sockjs = require('sockjs/lib/transport');
const { noop } = require('webpack-dev-middleware/lib/util');
const Server = require('../../lib/Server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map').Server;
jest.mock('sockjs/lib/transport');
@@ -23,6 +24,7 @@ describe('Server', () => {
const compiler = webpack(config);
const server = new Server(compiler, {
hot: true,
+ port,
});
expect(
@@ -45,6 +47,7 @@ describe('Server', () => {
const compiler = webpack(config);
const server = new Server(compiler, {
hotOnly: true,
+ port,
});
expect(
@@ -92,7 +95,7 @@ describe('Server', () => {
});
const compiler = webpack(config);
- const server = new Server(compiler);
+ const server = new Server(compiler, { port });
compiler.hooks.done.tap('webpack-dev-server', (s) => {
const output = server.getStats(s);
@@ -102,7 +105,7 @@ describe('Server', () => {
});
compiler.run(() => {});
- server.listen(8080, 'localhost');
+ server.listen(port, 'localhost');
});
});
@@ -136,7 +139,7 @@ describe('Server', () => {
describe('Testing callback functions on calling invalidate without callback', () => {
it('should be `noop` (the default callback function)', (done) => {
const compiler = webpack(config);
- const server = new Server(compiler);
+ const server = new Server(compiler, { port });
server.invalidate();
expect(server.middleware.context.callbacks[0]).toBe(noop);
@@ -153,7 +156,7 @@ describe('Server', () => {
it('should be `callback` function', (done) => {
const compiler = webpack(config);
const callback = jest.fn();
- const server = new Server(compiler);
+ const server = new Server(compiler, { port });
server.invalidate(callback);
diff --git a/test/server/__snapshots__/Server.test.js.snap b/test/server/__snapshots__/Server.test.js.snap
index b606b0561f..8d2d66684b 100644
--- a/test/server/__snapshots__/Server.test.js.snap
+++ b/test/server/__snapshots__/Server.test.js.snap
@@ -5,7 +5,7 @@ Array [
Array [
"client",
"index.js?http:",
- "localhost",
+ "localhost:8090",
],
Array [
"node_modules",
@@ -35,7 +35,7 @@ Array [
Array [
"client",
"index.js?http:",
- "localhost",
+ "localhost:8090",
],
Array [
"node_modules",
diff --git a/test/server/after-option.test.js b/test/server/after-option.test.js
index 69f0b48f1a..b9d57616d0 100644
--- a/test/server/after-option.test.js
+++ b/test/server/after-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['after-option'];
describe('after option', () => {
let server;
@@ -29,6 +30,7 @@ describe('after option', () => {
response.send('after');
});
},
+ port,
},
done
);
diff --git a/test/server/before-option.test.js b/test/server/before-option.test.js
index 0966d28e18..3da0ecfd54 100644
--- a/test/server/before-option.test.js
+++ b/test/server/before-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['before-option'];
describe('before option', () => {
let server;
@@ -29,6 +30,7 @@ describe('before option', () => {
response.send('before');
});
},
+ port,
},
done
);
diff --git a/test/server/compress-option.test.js b/test/server/compress-option.test.js
index 451639fa79..0a04d1466f 100644
--- a/test/server/compress-option.test.js
+++ b/test/server/compress-option.test.js
@@ -8,6 +8,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config-other/webpack.config');
+const port = require('../ports-map')['compress-option'];
describe('compress option', () => {
let server;
@@ -15,7 +16,7 @@ describe('compress option', () => {
describe('not specify', () => {
beforeAll((done) => {
- server = testServer.start(config, {}, done);
+ server = testServer.start(config, { port }, done);
req = request(server.app);
});
@@ -39,6 +40,7 @@ describe('compress option', () => {
config,
{
compress: true,
+ port,
},
done
);
@@ -61,6 +63,7 @@ describe('compress option', () => {
config,
{
compress: false,
+ port,
},
done
);
diff --git a/test/server/contentBase-option.test.js b/test/server/contentBase-option.test.js
index 9187c16e77..baa4111124 100644
--- a/test/server/contentBase-option.test.js
+++ b/test/server/contentBase-option.test.js
@@ -5,6 +5,7 @@ const fs = require('fs');
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/contentbase-config/webpack.config');
+const port = require('../ports-map')['contentBase-option'];
const contentBasePublic = path.resolve(
__dirname,
@@ -28,6 +29,7 @@ describe('contentBase option', () => {
{
contentBase: contentBasePublic,
watchContentBase: true,
+ port,
},
done
);
@@ -93,6 +95,7 @@ describe('contentBase option', () => {
contentBase: contentBasePublic,
watchContentBase: true,
serveIndex: false,
+ port,
},
done
);
@@ -122,6 +125,7 @@ describe('contentBase option', () => {
contentBase: contentBasePublic,
watchContentBase: true,
serveIndex: true,
+ port,
},
done
);
@@ -150,6 +154,7 @@ describe('contentBase option', () => {
{
contentBase: contentBasePublic,
watchContentBase: true,
+ port,
},
done
);
@@ -177,6 +182,7 @@ describe('contentBase option', () => {
config,
{
contentBase: [contentBasePublic, contentBaseOther],
+ port,
},
done
);
@@ -204,6 +210,7 @@ describe('contentBase option', () => {
config,
{
contentBase: 9099999,
+ port,
},
done
);
@@ -230,6 +237,7 @@ describe('contentBase option', () => {
config,
{
contentBase: 'http://example.com/',
+ port,
},
done
);
@@ -288,6 +296,7 @@ describe('contentBase option', () => {
config,
{
contentBase: false,
+ port,
},
done
);
@@ -311,6 +320,7 @@ describe('contentBase option', () => {
config,
{
contentBase: [contentBasePublic],
+ port,
},
done
);
diff --git a/test/server/headers-option.test.js b/test/server/headers-option.test.js
index 813635511f..1f3f7ad6fa 100644
--- a/test/server/headers-option.test.js
+++ b/test/server/headers-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['headers-option'];
describe('headers option', () => {
let server;
@@ -14,6 +15,7 @@ describe('headers option', () => {
config,
{
headers: { 'X-Foo': '1' },
+ port,
},
done
);
@@ -36,6 +38,7 @@ describe('headers option', () => {
config,
{
headers: { 'X-Bar': ['key1=value1', 'key2=value2'] },
+ port,
},
done
);
diff --git a/test/server/historyApiFallback-option.test.js b/test/server/historyApiFallback-option.test.js
index 51ad09c506..cc600e7a4a 100644
--- a/test/server/historyApiFallback-option.test.js
+++ b/test/server/historyApiFallback-option.test.js
@@ -6,6 +6,7 @@ const testServer = require('../helpers/test-server');
const config = require('../fixtures/historyapifallback-config/webpack.config');
const config2 = require('../fixtures/historyapifallback-2-config/webpack.config');
const config3 = require('../fixtures/historyapifallback-3-config/webpack.config');
+const port = require('../ports-map')['historyApiFallback-option'];
describe('historyApiFallback option', () => {
let server;
@@ -19,6 +20,7 @@ describe('historyApiFallback option', () => {
config,
{
historyApiFallback: true,
+ port,
},
done
);
@@ -41,6 +43,7 @@ describe('historyApiFallback option', () => {
historyApiFallback: {
index: '/bar.html',
},
+ port,
},
done
);
@@ -67,6 +70,7 @@ describe('historyApiFallback option', () => {
historyApiFallback: {
index: '/bar.html',
},
+ port,
},
done
);
@@ -113,6 +117,7 @@ describe('historyApiFallback option', () => {
historyApiFallback: {
index: '/bar.html',
},
+ port,
},
done
);
@@ -132,6 +137,7 @@ describe('historyApiFallback option', () => {
server = testServer.start(
config2,
{
+ port,
contentBase: path.resolve(
__dirname,
'../fixtures/historyapifallback-2-config'
@@ -186,6 +192,7 @@ describe('historyApiFallback option', () => {
'../fixtures/historyapifallback-3-config'
),
historyApiFallback: true,
+ port,
},
done
);
diff --git a/test/server/host-option.test.js b/test/server/host-option.test.js
index 043c7d5536..009379062a 100644
--- a/test/server/host-option.test.js
+++ b/test/server/host-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const config = require('../fixtures/simple-config/webpack.config');
const testServer = require('../helpers/test-server');
+const port = require('../ports-map')['host-option'];
describe('host option', () => {
let server = null;
@@ -10,7 +11,7 @@ describe('host option', () => {
describe('is not be specified', () => {
beforeAll((done) => {
- server = testServer.start(config, {}, done);
+ server = testServer.start(config, { port }, done);
req = request(server.app);
});
@@ -18,7 +19,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('127.0.0.1');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
@@ -35,6 +36,7 @@ describe('host option', () => {
{
// eslint-disable-next-line no-undefined
host: undefined,
+ port,
},
done
);
@@ -45,7 +47,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('::');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
@@ -61,6 +63,7 @@ describe('host option', () => {
config,
{
host: null,
+ port,
},
done
);
@@ -71,7 +74,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('::');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
@@ -87,6 +90,7 @@ describe('host option', () => {
config,
{
host: '127.0.0.1',
+ port,
},
done
);
@@ -97,7 +101,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('127.0.0.1');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
@@ -113,6 +117,7 @@ describe('host option', () => {
config,
{
host: 'localhost',
+ port,
},
done
);
@@ -123,7 +128,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('127.0.0.1');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
@@ -139,6 +144,7 @@ describe('host option', () => {
config,
{
host: '0.0.0.0',
+ port,
},
done
);
@@ -149,7 +155,7 @@ describe('host option', () => {
const address = server.listeningApp.address();
expect(address.address).toBe('0.0.0.0');
- expect(address.port).toBe(8080);
+ expect(address.port).toBe(port);
});
it('Request to index', (done) => {
diff --git a/test/server/hot-option.test.js b/test/server/hot-option.test.js
index 3754e6ea7d..979bbad12c 100644
--- a/test/server/hot-option.test.js
+++ b/test/server/hot-option.test.js
@@ -4,6 +4,7 @@ const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/client-config/webpack.config');
const multiCompilerConfig = require('../fixtures/multi-compiler-config/webpack.config');
+const port = require('../ports-map')['hot-option'];
describe('hot option', () => {
let server;
@@ -12,7 +13,7 @@ describe('hot option', () => {
describe('simple hot config entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
inline: true,
hot: true,
watchOptions: {
@@ -33,7 +34,7 @@ describe('hot option', () => {
describe('multi compiler hot config entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
inline: true,
hot: true,
watchOptions: {
@@ -58,7 +59,7 @@ describe('hot option', () => {
describe('hot disabled entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
inline: true,
hot: false,
watchOptions: {
@@ -89,7 +90,7 @@ describe('hot option', () => {
it('should register the HMR plugin before compilation is complete', (done) => {
let pluginFound = false;
const options = {
- port: 9000,
+ port,
inline: true,
hot: true,
watchOptions: {
@@ -123,7 +124,7 @@ describe('hot option', () => {
it('should register the HMR plugin before compilation is complete', (done) => {
let pluginFound = false;
const options = {
- port: 9000,
+ port,
inline: true,
hot: true,
watchOptions: {
@@ -157,7 +158,7 @@ describe('hot option', () => {
it('should NOT register the HMR plugin before compilation is complete', (done) => {
let pluginFound = false;
const options = {
- port: 9000,
+ port,
inline: true,
hot: false,
watchOptions: {
diff --git a/test/server/hotOnly-option.test.js b/test/server/hotOnly-option.test.js
index 0e48019381..e601325fd3 100644
--- a/test/server/hotOnly-option.test.js
+++ b/test/server/hotOnly-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/client-config/webpack.config');
+const port = require('../ports-map')['hotOnly-option'];
describe('hotOnly options', () => {
let server;
@@ -11,7 +12,7 @@ describe('hotOnly options', () => {
describe('simple hotOnly config entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
inline: true,
hotOnly: true,
watchOptions: {
@@ -35,7 +36,7 @@ describe('hotOnly options', () => {
it('should register the HMR plugin before compilation is complete', (done) => {
let pluginFound = false;
const options = {
- port: 9000,
+ port,
inline: true,
hotOnly: true,
watchOptions: {
diff --git a/test/server/http2-option.test.js b/test/server/http2-option.test.js
index 1dd74c68e9..3e5506558a 100644
--- a/test/server/http2-option.test.js
+++ b/test/server/http2-option.test.js
@@ -5,6 +5,7 @@ const request = require('supertest');
const semver = require('semver');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/contentbase-config/webpack.config');
+const port = require('../ports-map')['http2-option'];
const contentBasePublic = path.resolve(
__dirname,
@@ -37,6 +38,7 @@ describe('http2 option', () => {
contentBase: contentBasePublic,
https: true,
http2: true,
+ port,
},
done
);
@@ -44,7 +46,7 @@ describe('http2 option', () => {
});
it('confirm http2 client can connect', (done) => {
- const client = http2.connect('https://localhost:8080', {
+ const client = http2.connect(`https://localhost:${port}`, {
rejectUnauthorized: false,
});
client.on('error', (err) => console.error(err));
@@ -78,6 +80,7 @@ describe('http2 option', () => {
{
contentBase: contentBasePublic,
http2: true,
+ port,
},
done
);
@@ -99,6 +102,7 @@ describe('http2 option', () => {
contentBase: contentBasePublic,
https: true,
http2: false,
+ port,
},
done
);
diff --git a/test/server/https-option.test.js b/test/server/https-option.test.js
index 189bd48286..719875a000 100644
--- a/test/server/https-option.test.js
+++ b/test/server/https-option.test.js
@@ -5,8 +5,8 @@ const fs = require('fs');
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/contentbase-config/webpack.config');
-const skipTestOnWindows = require('../helpers/conditional-test')
- .skipTestOnWindows;
+const { skipTestOnWindows } = require('../helpers/conditional-test');
+const port = require('../ports-map')['https-option'];
const httpsCertificateDirectory = path.resolve(
__dirname,
@@ -28,6 +28,7 @@ describe('https option', () => {
{
contentBase: contentBasePublic,
https: true,
+ port,
},
done
);
@@ -62,6 +63,7 @@ describe('https option', () => {
),
passphrase: 'webpack-dev-server',
},
+ port,
},
done
);
@@ -86,6 +88,7 @@ describe('https option', () => {
cert: path.join(httpsCertificateDirectory, 'server.crt'),
passphrase: 'webpack-dev-server',
},
+ port,
},
done
);
@@ -114,6 +117,7 @@ describe('https option', () => {
cert: path.join(httpsCertificateDirectory, 'server-symlink.crt'),
passphrase: 'webpack-dev-server',
},
+ port,
},
done
);
@@ -149,6 +153,7 @@ describe('https option', () => {
.toString(),
passphrase: 'webpack-dev-server',
},
+ port,
},
done
);
diff --git a/test/server/inline-option.test.js b/test/server/inline-option.test.js
index c25b953401..78344621e6 100644
--- a/test/server/inline-option.test.js
+++ b/test/server/inline-option.test.js
@@ -4,6 +4,7 @@ const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/client-config/webpack.config');
const multiCompilerConfig = require('../fixtures/multi-compiler-config/webpack.config');
+const port = require('../ports-map')['inline-option'];
describe('inline option', () => {
let server;
@@ -12,7 +13,7 @@ describe('inline option', () => {
describe('simple inline config entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: true,
watchOptions: {
@@ -26,16 +27,16 @@ describe('inline option', () => {
afterAll(testServer.close);
it('should include inline client script in the bundle', (done) => {
- req
- .get('/main.js')
- .expect(200, /client\/index\.js\?http:\/\/0\.0\.0\.0:9000/, done);
+ const url = new RegExp(`client/index.js\\?http://0.0.0.0:${port}`);
+
+ req.get('/main.js').expect(200, url, done);
});
});
describe('multi compiler inline config entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: true,
watchOptions: {
@@ -53,16 +54,16 @@ describe('inline option', () => {
afterAll(testServer.close);
it('should include inline client script in the bundle', (done) => {
- req
- .get('/main.js')
- .expect(200, /client\/index\.js\?http:\/\/0\.0\.0\.0:9000/, done);
+ const url = new RegExp(`client/index.js\\?http://0.0.0.0:${port}`);
+
+ req.get('/main.js').expect(200, url, done);
});
});
describe('inline disabled entries', () => {
beforeAll((done) => {
const options = {
- port: 9000,
+ port,
host: '0.0.0.0',
inline: false,
watchOptions: {
@@ -80,9 +81,7 @@ describe('inline option', () => {
.get('/main.js')
.expect(200)
.then(({ text }) => {
- expect(text).not.toMatch(
- /client\/index\.js\?http:\/\/0\.0\.0\.0:9000/
- );
+ expect(text.includes(`client/index.js?http://0.0.0.0:${port}`));
done();
});
});
diff --git a/test/server/lazy-option.test.js b/test/server/lazy-option.test.js
index 515126f8ed..1d2a660aaf 100644
--- a/test/server/lazy-option.test.js
+++ b/test/server/lazy-option.test.js
@@ -2,6 +2,7 @@
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['lazy-option'];
describe('lazy option', () => {
afterEach(testServer.close);
@@ -10,6 +11,7 @@ describe('lazy option', () => {
expect(() => {
testServer.start(config, {
lazy: true,
+ port,
});
}).toThrow(/'filename' option must be set/);
});
@@ -20,6 +22,7 @@ describe('lazy option', () => {
{
lazy: true,
filename: 'bundle.js',
+ port,
},
done
);
diff --git a/test/server/liveReload-option.test.js b/test/server/liveReload-option.test.js
index 6226f4d771..5cde4c0c7c 100644
--- a/test/server/liveReload-option.test.js
+++ b/test/server/liveReload-option.test.js
@@ -4,6 +4,7 @@ const path = require('path');
const fs = require('fs');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/contentbase-config/webpack.config');
+const port = require('../ports-map')['liveReload-option'];
const contentBasePublic = path.resolve(
__dirname,
@@ -23,6 +24,7 @@ describe('liveReload option', () => {
contentBase: contentBasePublic,
watchContentBase: true,
liveReload: false,
+ port,
},
done
);
@@ -70,6 +72,7 @@ describe('liveReload option', () => {
contentBase: contentBasePublic,
watchContentBase: true,
liveReload: true,
+ port,
},
done
);
diff --git a/test/server/mimeTypes-option.test.js b/test/server/mimeTypes-option.test.js
index 2fcde68a67..662007dadd 100644
--- a/test/server/mimeTypes-option.test.js
+++ b/test/server/mimeTypes-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['mineTypes-option'];
describe('mimeTypes option', () => {
describe('as an object', () => {
@@ -12,6 +13,7 @@ describe('mimeTypes option', () => {
expect(() => {
testServer.start(config, {
mimeTypes: { 'application/octet-stream': ['js'] },
+ port,
});
}).toThrow(/Attempt to change mapping for/);
});
@@ -24,6 +26,7 @@ describe('mimeTypes option', () => {
typeMap: { 'application/octet-stream': ['js'] },
force: true,
},
+ port,
},
done
);
@@ -42,6 +45,7 @@ describe('mimeTypes option', () => {
typeMap: { 'application/octet-stream': ['js'] },
force: true,
},
+ port,
},
done
);
diff --git a/test/server/onListening-option.test.js b/test/server/onListening-option.test.js
index 43db18eec8..d6d66b1565 100644
--- a/test/server/onListening-option.test.js
+++ b/test/server/onListening-option.test.js
@@ -2,6 +2,7 @@
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['onListening-option'];
describe('onListening option', () => {
let onListeningIsRunning = false;
@@ -17,6 +18,7 @@ describe('onListening option', () => {
onListeningIsRunning = true;
},
+ port,
},
done
);
diff --git a/test/server/open-option.test.js b/test/server/open-option.test.js
index c0f1768b99..b33d0a834c 100644
--- a/test/server/open-option.test.js
+++ b/test/server/open-option.test.js
@@ -3,11 +3,12 @@
jest.mock('opn');
const webpack = require('webpack');
-const opn = require('opn');
+const open = require('opn');
const Server = require('../../lib/Server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['open-option'];
-opn.mockImplementation(() => {
+open.mockImplementation(() => {
return {
catch: jest.fn(),
};
@@ -18,15 +19,25 @@ describe('open option', () => {
const compiler = webpack(config);
const server = new Server(compiler, {
open: true,
+ port,
});
compiler.hooks.done.tap('webpack-dev-server', () => {
- expect(opn.mock.calls[0]).toEqual(['http://localhost:8080/', {}]);
- expect(opn.mock.invocationCallOrder[0]).toEqual(1);
- server.close(done);
+ server.close(() => {
+ expect(open.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "http://localhost:8110/",
+ Object {
+ "wait": false,
+ },
+ ]
+ `);
+ expect(open.mock.invocationCallOrder[0]).toEqual(1);
+ done();
+ });
});
compiler.run(() => {});
- server.listen(8080, 'localhost');
+ server.listen(port, 'localhost');
});
});
diff --git a/test/server/port-option.test.js b/test/server/port-option.test.js
index 0cb2046962..ff7488de80 100644
--- a/test/server/port-option.test.js
+++ b/test/server/port-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['port-option'];
describe('port', () => {
let server = null;
@@ -10,7 +11,7 @@ describe('port', () => {
describe('is not be specified', () => {
beforeAll((done) => {
- server = testServer.start(config, {}, done);
+ server = testServer.start(config, { port }, done);
req = request(server.app);
});
diff --git a/test/server/proxy-option.test.js b/test/server/proxy-option.test.js
index e28c8e6126..6f21967248 100644
--- a/test/server/proxy-option.test.js
+++ b/test/server/proxy-option.test.js
@@ -7,21 +7,21 @@ const bodyParser = require('body-parser');
const WebSocket = require('ws');
const testServer = require('../helpers/test-server');
const config = require('../fixtures/proxy-config/webpack.config');
+const [port1, port2, port3, port4] = require('../ports-map')['proxy-option'];
const WebSocketServer = WebSocket.Server;
const contentBase = path.resolve(__dirname, '../fixtures/proxy-config');
const proxyOptionPathsAsProperties = {
'/proxy1': {
- target: 'http://localhost:9000',
+ target: `http://localhost:${port1}`,
},
'/api/proxy2': {
- target: 'http://localhost:9001',
+ target: `http://localhost:${port2}`,
pathRewrite: { '^/api': '' },
},
'/foo': {
bypass(req) {
- console.log(req.path);
if (/\.html$/.test(req.path)) {
return '/index.html';
}
@@ -40,7 +40,7 @@ const proxyOptionPathsAsProperties = {
const proxyOption = {
context: () => true,
- target: 'http://localhost:9000',
+ target: `http://localhost:${port1}`,
};
const proxyOptionOfArray = [
@@ -48,7 +48,7 @@ const proxyOptionOfArray = [
function proxy() {
return {
context: '/api/proxy2',
- target: 'http://localhost:9001',
+ target: `http://localhost:${port2}`,
pathRewrite: { '^/api': '' },
};
},
@@ -69,8 +69,8 @@ function startProxyServers() {
res.send('from proxy2');
});
- listeners.push(proxy1.listen(9000));
- listeners.push(proxy2.listen(9001));
+ listeners.push(proxy1.listen(port1));
+ listeners.push(proxy2.listen(port2));
// return a function to shutdown proxy servers
return function proxy() {
@@ -93,6 +93,7 @@ describe('proxy option', () => {
{
contentBase,
proxy: proxyOptionPathsAsProperties,
+ port: port3,
},
done
);
@@ -149,6 +150,7 @@ describe('proxy option', () => {
{
contentBase,
proxy: proxyOption,
+ port: port3,
},
done
);
@@ -179,6 +181,7 @@ describe('proxy option', () => {
{
contentBase,
proxy: proxyOptionOfArray,
+ port: port3,
},
done
);
@@ -206,7 +209,7 @@ describe('proxy option', () => {
let req;
let listener;
const proxyTarget = {
- target: 'http://localhost:9000',
+ target: `http://localhost:${port1}`,
};
beforeAll((done) => {
@@ -216,7 +219,7 @@ describe('proxy option', () => {
res.send('from proxy');
});
- listener = proxy.listen(9000);
+ listener = proxy.listen(port1);
server = testServer.start(
config,
@@ -226,6 +229,7 @@ describe('proxy option', () => {
'/proxy1': proxyTarget,
'/proxy2': proxyTarget,
},
+ port: port3,
},
done
);
@@ -261,15 +265,16 @@ describe('proxy option', () => {
proxy: [
{
context: '/',
- target: 'http://localhost:9003',
+ target: `http://localhost:${port4}`,
ws: true,
},
],
+ port: port3,
},
done
);
- wsServer = new WebSocketServer({ port: 9003 });
+ wsServer = new WebSocketServer({ port: port4 });
wsServer.on('connection', (server) => {
server.on('message', (message) => {
server.send(message);
@@ -278,7 +283,7 @@ describe('proxy option', () => {
});
beforeEach((done) => {
- ws = new WebSocket('ws://localhost:8080/proxy3/socket');
+ ws = new WebSocket(`ws://localhost:${port3}/proxy3/socket`);
ws.on('message', (message) => {
responseMessage = message;
done();
@@ -303,7 +308,7 @@ describe('proxy option', () => {
let req;
let listener;
const proxyTarget = {
- target: 'http://localhost:9000',
+ target: `http://localhost:${port1}`,
};
beforeAll((done) => {
@@ -339,7 +344,7 @@ describe('proxy option', () => {
res.send('DELETE method from proxy');
});
- listener = proxy.listen(9000);
+ listener = proxy.listen(port1);
server = testServer.start(
config,
diff --git a/test/server/serverMode-option.test.js b/test/server/serverMode-option.test.js
index ebe5aff3a8..b0ef7357fb 100644
--- a/test/server/serverMode-option.test.js
+++ b/test/server/serverMode-option.test.js
@@ -9,6 +9,7 @@ const SockJSServer = require('../../lib/servers/SockJSServer');
const config = require('../fixtures/simple-config/webpack.config');
const testServer = require('../helpers/test-server');
const BaseServer = require('../../lib/servers/BaseServer');
+const port = require('../ports-map')['serverMode-option'];
describe('serverMode option', () => {
let server;
@@ -26,10 +27,11 @@ describe('serverMode option', () => {
config,
{
serverMode: 'sockjs',
+ port,
},
done
);
- req = request('http://localhost:8080');
+ req = request(`http://localhost:${port}`);
});
it('sockjs path responds with a 200', (done) => {
@@ -43,10 +45,11 @@ describe('serverMode option', () => {
config,
{
serverMode: require.resolve('../../lib/servers/SockJSServer'),
+ port,
},
done
);
- req = request('http://localhost:8080');
+ req = request(`http://localhost:${port}`);
});
it('sockjs path responds with a 200', (done) => {
@@ -60,10 +63,11 @@ describe('serverMode option', () => {
config,
{
serverMode: SockJSServer,
+ port,
},
done
);
- req = request('http://localhost:8080');
+ req = request(`http://localhost:${port}`);
});
it('sockjs path responds with a 200', (done) => {
@@ -76,6 +80,7 @@ describe('serverMode option', () => {
server = testServer.start(
config,
{
+ port,
sockPath: '/foo/test/bar/',
serverMode: class MySockJSServer extends BaseServer {
constructor(serv) {
@@ -125,6 +130,7 @@ describe('serverMode option', () => {
config,
{
serverMode: '/bad/path/to/implementation',
+ port,
},
() => {}
);
diff --git a/test/server/servers/SockJSServer.test.js b/test/server/servers/SockJSServer.test.js
index 86335b5c7a..d1024c5910 100644
--- a/test/server/servers/SockJSServer.test.js
+++ b/test/server/servers/SockJSServer.test.js
@@ -4,6 +4,7 @@ const http = require('http');
const express = require('express');
const SockJS = require('sockjs-client/dist/sockjs');
const SockJSServer = require('../../../lib/servers/SockJSServer');
+const port = require('../../ports-map').SockJSServer;
describe('SockJSServer', () => {
let socketServer;
@@ -14,7 +15,7 @@ describe('SockJSServer', () => {
const app = new express();
listeningApp = http.createServer(app);
- listeningApp.listen(8080, 'localhost', () => {
+ listeningApp.listen(port, 'localhost', () => {
const server = {
log: {
error: () => {},
@@ -42,7 +43,7 @@ describe('SockJSServer', () => {
}, 1000);
});
- const client = new SockJS('http://localhost:8080/sockjs-node');
+ const client = new SockJS(`http://localhost:${port}/sockjs-node`);
client.onmessage = (e) => {
data.push(e.data);
diff --git a/test/server/sockPath-option.test.js b/test/server/sockPath-option.test.js
index 5542dc985d..b6840228b5 100644
--- a/test/server/sockPath-option.test.js
+++ b/test/server/sockPath-option.test.js
@@ -3,6 +3,7 @@
const request = require('supertest');
const config = require('../fixtures/simple-config/webpack.config');
const testServer = require('../helpers/test-server');
+const port = require('../ports-map')['sockPath-option'];
describe('sockPath options', () => {
let server;
@@ -16,8 +17,8 @@ describe('sockPath options', () => {
describe('default behavior', () => {
beforeEach((done) => {
- server = testServer.start(config, {}, done);
- req = request('http://localhost:8080');
+ server = testServer.start(config, { port }, done);
+ req = request(`http://localhost:${port}`);
});
it('defaults to a path', () => {
@@ -37,10 +38,11 @@ describe('sockPath options', () => {
config,
{
sockPath: '/foo/test/bar/',
+ port,
},
done
);
- req = request('http://localhost:8080');
+ req = request(`http://localhost:${port}`);
});
it('sets the sock path correctly and strips leading and trailing /s', () => {
diff --git a/test/server/stats-option.test.js b/test/server/stats-option.test.js
index 299ce7aa63..82d58fd233 100644
--- a/test/server/stats-option.test.js
+++ b/test/server/stats-option.test.js
@@ -3,6 +3,7 @@
const webpack = require('webpack');
const Server = require('../../lib/Server');
const config = require('../fixtures/simple-config/webpack.config');
+const port = require('../ports-map')['stats-option'];
describe('stats option', () => {
it(`should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors')`, () => {
@@ -21,7 +22,7 @@ describe('stats option', () => {
return p.then(() => {
return new Promise((resolve) => {
const compiler = webpack(config);
- const server = new Server(compiler, { stats });
+ const server = new Server(compiler, { stats, port });
compiler.hooks.done.tap('webpack-dev-server', (s) => {
expect(Object.keys(server.getStats(s))).toMatchSnapshot();
@@ -30,7 +31,7 @@ describe('stats option', () => {
});
compiler.run(() => {});
- server.listen(8080, 'localhost');
+ server.listen(port, 'localhost');
});
});
}, Promise.resolve());
@@ -40,6 +41,7 @@ describe('stats option', () => {
const compiler = webpack(config);
const server = new Server(compiler, {
stats: { warningsFilter: 'test' },
+ port,
});
compiler.hooks.done.tap('webpack-dev-server', (s) => {
@@ -54,6 +56,6 @@ describe('stats option', () => {
});
compiler.run(() => {});
- server.listen(8080, 'localhost');
+ server.listen(port, 'localhost');
});
});
diff --git a/test/server/utils/createDomain.test.js b/test/server/utils/createDomain.test.js
index 08b839c585..07a755859c 100644
--- a/test/server/utils/createDomain.test.js
+++ b/test/server/utils/createDomain.test.js
@@ -4,6 +4,7 @@ const webpack = require('webpack');
const internalIp = require('internal-ip');
const Server = require('../../../lib/Server');
const createDomain = require('../../../lib/utils/createDomain');
+const [port1, port2] = require('../../ports-map').createDomain;
const config = require('./../../fixtures/simple-config/webpack.config');
describe('check utility functions', () => {
@@ -15,9 +16,7 @@ describe('check utility functions', () => {
});
afterEach((done) => {
- server.close(() => {
- done();
- });
+ server.close(done);
});
const tests = [
@@ -25,32 +24,32 @@ describe('check utility functions', () => {
name: 'default',
options: {
host: 'localhost',
- port: 8080,
+ port: port1,
},
- expected: 'http://localhost:8080',
+ expected: `http://localhost:${port1}`,
},
{
name: 'no host option',
options: {
- port: 8080,
+ port: port1,
},
- expected: 'http://localhost:8080',
+ expected: `http://localhost:${port1}`,
},
{
name: 'https',
options: {
host: 'localhost',
- port: 8080,
+ port: port1,
https: true,
},
- expected: 'https://localhost:8080',
+ expected: `https://localhost:${port1}`,
timeout: 60000,
},
{
name: 'override with public',
options: {
host: 'localhost',
- port: 8080,
+ port: port1,
public: 'myhost.test',
},
expected: 'http://myhost.test',
@@ -59,16 +58,16 @@ describe('check utility functions', () => {
name: 'override with public (port)',
options: {
host: 'localhost',
- port: 8080,
- public: 'myhost.test:9090',
+ port: port1,
+ public: `myhost.test:${port2}`,
},
- expected: 'http://myhost.test:9090',
+ expected: `http://myhost.test:${port2}`,
},
{
name: 'override with public (protocol)',
options: {
host: 'localhost',
- port: 8080,
+ port: port1,
public: 'https://myhost.test',
},
expected: 'https://myhost.test',
@@ -77,18 +76,18 @@ describe('check utility functions', () => {
name: 'override with public (protocol + port)',
options: {
host: 'localhost',
- port: 8080,
- public: 'https://myhost.test:9090',
+ port: port1,
+ public: `https://myhost.test:${port2}`,
},
- expected: 'https://myhost.test:9090',
+ expected: `https://myhost.test:${port2}`,
},
{
name: 'localIp',
options: {
useLocalIp: true,
- port: 8080,
+ port: port1,
},
- expected: `http://${internalIp.v4.sync() || 'localhost'}:8080`,
+ expected: `http://${internalIp.v4.sync() || 'localhost'}:${port1}`,
},
];
diff --git a/test/server/utils/routes.test.js b/test/server/utils/routes.test.js
index 53e1029601..c5f0d7369e 100644
--- a/test/server/utils/routes.test.js
+++ b/test/server/utils/routes.test.js
@@ -3,13 +3,14 @@
const request = require('supertest');
const testServer = require('../../helpers/test-server');
const config = require('../../fixtures/simple-config/webpack.config');
+const port = require('../../ports-map').routes;
describe('routes util', () => {
let server;
let req;
beforeAll((done) => {
- server = testServer.startAwaitingCompilation(config, {}, done);
+ server = testServer.startAwaitingCompilation(config, { port }, done);
req = request(server.app);
});
diff --git a/test/server/utils/runOpen.test.js b/test/server/utils/runOpen.test.js
index 51fce41300..fcb4b42225 100644
--- a/test/server/utils/runOpen.test.js
+++ b/test/server/utils/runOpen.test.js
@@ -17,7 +17,14 @@ describe('runOpen util', () => {
it('on specify URL', () => {
return runOpen('https://example.com', {}, console).then(() => {
- expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com",
+ Object {
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -27,10 +34,14 @@ describe('runOpen util', () => {
{ openPage: '/index.html' },
console
).then(() => {
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com/index.html',
- {},
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com/index.html",
+ Object {
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -40,10 +51,15 @@ describe('runOpen util', () => {
{ open: 'Google Chrome' },
console
).then(() => {
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com',
- { app: 'Google Chrome' },
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com",
+ Object {
+ "app": "Google Chrome",
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -53,10 +69,15 @@ describe('runOpen util', () => {
{ open: 'Google Chrome', openPage: '/index.html' },
console
).then(() => {
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com/index.html',
- { app: 'Google Chrome' },
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com/index.html",
+ Object {
+ "app": "Google Chrome",
+ "wait": false,
+ },
+ ]
+ `);
});
});
});
@@ -77,7 +98,14 @@ describe('runOpen util', () => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
);
- expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com",
+ Object {
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -90,10 +118,14 @@ describe('runOpen util', () => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
);
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com/index.html',
- {},
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com/index.html",
+ Object {
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -106,12 +138,15 @@ describe('runOpen util', () => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
);
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com',
- {
- app: 'Google Chrome',
- },
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com",
+ Object {
+ "app": "Google Chrome",
+ "wait": false,
+ },
+ ]
+ `);
});
});
@@ -124,10 +159,15 @@ describe('runOpen util', () => {
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
);
- expect(opn.mock.calls[0]).toEqual([
- 'https://example.com/index.html',
- { app: 'Google Chrome' },
- ]);
+ expect(opn.mock.calls[0]).toMatchInlineSnapshot(`
+ Array [
+ "https://example.com/index.html",
+ Object {
+ "app": "Google Chrome",
+ "wait": false,
+ },
+ ]
+ `);
});
});
});