Skip to content

Commit 818f1fd

Browse files
committed
test: more
1 parent da69595 commit 818f1fd

File tree

4 files changed

+136
-121
lines changed

4 files changed

+136
-121
lines changed

bin/cli-flags.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ module.exports = {
202202
"When using dev server and you're proxying dev-server, the client script does not always know where to connect to.",
203203
simpleType: 'string',
204204
multiple: false,
205+
processor(opts) {
206+
opts.client = normalizeOption(opts.client);
207+
opts.client.webSocketURL = opts.clientWebSocketUrl;
208+
delete opts.clientWebSocketUrl;
209+
},
205210
},
206211
'client-web-socket-url-host': {
207212
configs: [
@@ -263,7 +268,7 @@ module.exports = {
263268
opts.client = normalizeOption(opts.client);
264269
opts.client.webSocketURL = normalizeOption(opts.client.webSocketURL);
265270
opts.client.webSocketURL.path = opts.clientWebSocketUrlPath;
266-
delete opts.clientWebSocketUrlHost;
271+
delete opts.clientWebSocketUrlPath;
267272
},
268273
},
269274
'web-socket-server': {

test/cli/__snapshots__/cli.test.js.snap.webpack5

Lines changed: 93 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -186,100 +186,101 @@ exports[`CLI should generate correct cli flags 1`] = `
186186
Run the webpack dev server.
187187

188188
Options:
189-
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
190-
--config-name <value...> Name of the configuration to use.
191-
-m, --merge Merge two or more configurations using 'webpack-merge'.
192-
--env <value...> Environment passed to the configuration when it is a function.
193-
--node-env <value> Sets process.env.NODE_ENV to the specified value.
194-
--progress [value] Print compilation progress during build.
195-
-j, --json [value] Prints result as JSON or store it in a file.
196-
-d, --devtool <value> Determine source maps to use.
197-
--no-devtool Do not generate source maps.
198-
--entry <value...> The entry point(s) of your application e.g. ./src/main.js.
199-
--mode <value> Defines the mode to pass to webpack.
200-
--name <value> Name of the configuration. Used when loading multiple configurations.
201-
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
202-
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
203-
--no-stats Disable stats output.
204-
-t, --target <value...> Sets the build target e.g. node.
205-
--no-target Negative 'target' option.
206-
--watch-options-stdin Stop watching when stdin stream has ended.
207-
--no-watch-options-stdin Do not stop watching when stdin stream has ended.
208-
--bonjour Broadcasts the server via ZeroConf networking on start.
209-
--no-bonjour Do not broadcast the server via ZeroConf networking on start.
210-
--client-transport <value> Allows to set custom transport to communicate with server.
211-
--client-host <value> Tells clients connected to devServer to use the provided host.
212-
--client-path <value> Tells clients connected to devServer to use the provided path to connect.
213-
--client-port <value> Tells clients connected to devServer to use the provided port.
214-
--client-logging <value> Specifies client properties.
215-
--client-progress Print compilation progress in percentage in the browser.
216-
--no-client-progress Do not print compilation progress in percentage in the browser.
217-
--client-overlay Show a full-screen overlay in the browser when there are compiler errors or warnings.
218-
--no-client-overlay Do not show a full-screen overlay in the browser when there are compiler errors or warnings.
219-
--client-overlay-errors Show a full-screen overlay in the browser when there are compiler errors.
220-
--no-client-overlay-errors Negative 'client-overlay-errors' option.
221-
--client-overlay-warnings Show a full-screen overlay in the browser when there are compiler warnings.
222-
--no-client-overlay-warnings Negative 'client-overlay-warnings' option.
223-
--client-need-client-entry Tells devServer to inject a client entry.
224-
--no-client-need-client-entry Negative 'client-need-client-entry' option.
225-
--client-hot-entry Tells devServer to inject a Hot Module Replacement entry.
226-
--no-client-hot-entry Do not tell devServer to inject a Hot Module Replacement entry.
227-
--web-socket-server <value> Allows to set web socket server and options.
228-
--web-socket-server-type <value> Allows to set web socket server and options.
229-
--compress Enable gzip compression for everything served.
230-
--no-compress Disable gzip compression.
231-
--firewall [value...] Defines routes which are enabled by default, on by default and allows localhost.
232-
--no-firewall Disable firewall.
233-
--firewall-reset Clear all items provided in firewall configuration.
234-
--history-api-fallback When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses.
235-
--no-history-api-fallback Negative 'history-api-fallback' option.
236-
--host <value> Specify a host to use. If you want your server to be accessible externally.
237-
--hot [value] Enable webpack's Hot Module Replacement feature.
238-
--no-hot Disable webpack's Hot Module Replacement feature.
239-
--http2 Serve over HTTP/2 using spdy.
240-
--no-http2 Do not use HTTP/2.
241-
--https By default, dev-server will be served over HTTP. It can optionally be served over HTTP/2 with HTTPS.
242-
--no-https Do not use HTTPS protocol.
243-
--https-passphrase <value> Passphrase for a pfx file.
244-
--https-request-cert Request for an SSL certificate.
245-
--no-https-request-cert Do not request for an SSL certificate.
246-
--https-cacert <value> Path to an SSL CA certificate.
247-
--https-key <value> Path to an SSL key.
248-
--https-pfx <value> Path to an SSL pfx file.
249-
--https-cert <value> Path to an SSL certificate.
250-
--live-reload By default, the dev-server will reload/refresh the page when file changes are detected.
251-
--no-live-reload Disables live reloading on changing files.
252-
--open [value...] Tells dev-server to open the browser after server had been started. Set it to true to open your default browser.
253-
--no-open Do not open the default browser.
254-
--open-target [value...] Open specified route in browser.
255-
--no-open-target Do not open specified route in browser.
256-
--open-app-name <value...> Open specified browser.
257-
--open-app <value> Open specified browser.
258-
--open-reset Clear all items provided in open configuration.
259-
--open-target-reset Clear all items provided in open.target configuration.
260-
--open-app-name-reset Clear all items provided in open.app.name configuration.
261-
--port <value> Specify a port number to listen for requests on.
262-
--public <value> The public hostname/ip address of the server that client script will try to connect to.
263-
--static [value...] It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options.
264-
--no-static Negative 'static' option.
265-
--static-directory <value> Directory for static contents.
266-
--static-public-path <value...> The bundled files will be available in the browser under this path.
267-
--static-serve-index Tells dev-server to use serveIndex middleware when enabled.
268-
--no-static-serve-index Do not tell dev-server to use serveIndex middleware.
269-
--static-watch Watch for files in static content directory.
270-
--no-static-watch Do not watch for files in static content directory.
271-
--static-reset Clear all items provided in static configuration.
272-
--static-public-path-reset Clear all items provided in static.publicPath configuration.
273-
--watch-files <value...> List of files to watch for file changes and serve.
274-
--watch-files-paths <value...> List of files to watch for file changes and serve.
275-
--watch-files-reset Clear all items provided in watchFiles configuration.
276-
--watch-files-paths-reset Clear all items provided in watchFiles.paths configuration.
189+
-c, --config <value...> Provide path to a webpack configuration file e.g. ./webpack.config.js.
190+
--config-name <value...> Name of the configuration to use.
191+
-m, --merge Merge two or more configurations using 'webpack-merge'.
192+
--env <value...> Environment passed to the configuration when it is a function.
193+
--node-env <value> Sets process.env.NODE_ENV to the specified value.
194+
--progress [value] Print compilation progress during build.
195+
-j, --json [value] Prints result as JSON or store it in a file.
196+
-d, --devtool <value> Determine source maps to use.
197+
--no-devtool Do not generate source maps.
198+
--entry <value...> The entry point(s) of your application e.g. ./src/main.js.
199+
--mode <value> Defines the mode to pass to webpack.
200+
--name <value> Name of the configuration. Used when loading multiple configurations.
201+
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
202+
--stats [value] It instructs webpack on how to treat the stats e.g. verbose.
203+
--no-stats Disable stats output.
204+
-t, --target <value...> Sets the build target e.g. node.
205+
--no-target Negative 'target' option.
206+
--watch-options-stdin Stop watching when stdin stream has ended.
207+
--no-watch-options-stdin Do not stop watching when stdin stream has ended.
208+
--bonjour Broadcasts the server via ZeroConf networking on start.
209+
--no-bonjour Do not broadcast the server via ZeroConf networking on start.
210+
--client-transport <value> Allows to set custom transport to communicate with server.
211+
--client-logging <value> Specifies client properties.
212+
--client-progress Print compilation progress in percentage in the browser.
213+
--no-client-progress Do not print compilation progress in percentage in the browser.
214+
--client-overlay Show a full-screen overlay in the browser when there are compiler errors or warnings.
215+
--no-client-overlay Do not show a full-screen overlay in the browser when there are compiler errors or warnings.
216+
--client-overlay-errors Show a full-screen overlay in the browser when there are compiler errors.
217+
--no-client-overlay-errors Negative 'client-overlay-errors' option.
218+
--client-overlay-warnings Show a full-screen overlay in the browser when there are compiler warnings.
219+
--no-client-overlay-warnings Negative 'client-overlay-warnings' option.
220+
--client-need-client-entry Tells devServer to inject a client entry.
221+
--no-client-need-client-entry Negative 'client-need-client-entry' option.
222+
--client-hot-entry Tells devServer to inject a Hot Module Replacement entry.
223+
--no-client-hot-entry Do not tell devServer to inject a Hot Module Replacement entry.
224+
--client-web-socket-url <value> When using dev server and you're proxying dev-server, the client script does not always know where to connect to.
225+
--client-web-socket-url-host <value> Tells clients connected to devServer to use the provided host.
226+
--client-web-socket-url-port <value> Tells clients connected to devServer to use the provided port.
227+
--client-web-socket-url-path <value> Tells clients connected to devServer to use the provided path to connect.
228+
--web-socket-server <value> Allows to set web socket server and options.
229+
--web-socket-server-type <value> Allows to set web socket server and options.
230+
--compress Enable gzip compression for everything served.
231+
--no-compress Disable gzip compression.
232+
--firewall [value...] Defines routes which are enabled by default, on by default and allows localhost.
233+
--no-firewall Disable firewall.
234+
--firewall-reset Clear all items provided in firewall configuration.
235+
--history-api-fallback When using the HTML5 History API, the index.html page will likely have to be served in place of any 404 responses.
236+
--no-history-api-fallback Negative 'history-api-fallback' option.
237+
--host <value> Specify a host to use. If you want your server to be accessible externally.
238+
--hot [value] Enable webpack's Hot Module Replacement feature.
239+
--no-hot Disable webpack's Hot Module Replacement feature.
240+
--http2 Serve over HTTP/2 using spdy.
241+
--no-http2 Do not use HTTP/2.
242+
--https By default, dev-server will be served over HTTP. It can optionally be served over HTTP/2 with HTTPS.
243+
--no-https Do not use HTTPS protocol.
244+
--https-passphrase <value> Passphrase for a pfx file.
245+
--https-request-cert Request for an SSL certificate.
246+
--no-https-request-cert Do not request for an SSL certificate.
247+
--https-cacert <value> Path to an SSL CA certificate.
248+
--https-key <value> Path to an SSL key.
249+
--https-pfx <value> Path to an SSL pfx file.
250+
--https-cert <value> Path to an SSL certificate.
251+
--live-reload By default, the dev-server will reload/refresh the page when file changes are detected.
252+
--no-live-reload Disables live reloading on changing files.
253+
--open [value...] Tells dev-server to open the browser after server had been started. Set it to true to open your default browser.
254+
--no-open Do not open the default browser.
255+
--open-target [value...] Open specified route in browser.
256+
--no-open-target Do not open specified route in browser.
257+
--open-app-name <value...> Open specified browser.
258+
--open-app <value> Open specified browser.
259+
--open-reset Clear all items provided in open configuration.
260+
--open-target-reset Clear all items provided in open.target configuration.
261+
--open-app-name-reset Clear all items provided in open.app.name configuration.
262+
--port <value> Specify a port number to listen for requests on.
263+
--public <value> The public hostname/ip address of the server that client script will try to connect to.
264+
--static [value...] It is possible to configure advanced options for serving static files from directory. See the Express documentation for the possible options.
265+
--no-static Negative 'static' option.
266+
--static-directory <value> Directory for static contents.
267+
--static-public-path <value...> The bundled files will be available in the browser under this path.
268+
--static-serve-index Tells dev-server to use serveIndex middleware when enabled.
269+
--no-static-serve-index Do not tell dev-server to use serveIndex middleware.
270+
--static-watch Watch for files in static content directory.
271+
--no-static-watch Do not watch for files in static content directory.
272+
--static-reset Clear all items provided in static configuration.
273+
--static-public-path-reset Clear all items provided in static.publicPath configuration.
274+
--watch-files <value...> List of files to watch for file changes and serve.
275+
--watch-files-paths <value...> List of files to watch for file changes and serve.
276+
--watch-files-reset Clear all items provided in watchFiles configuration.
277+
--watch-files-paths-reset Clear all items provided in watchFiles.paths configuration.
277278

278279
Global options:
279-
--color Enable colors on console.
280-
--no-color Disable colors on console.
281-
-v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
282-
-h, --help [verbose] Display help for commands and options.
280+
--color Enable colors on console.
281+
--no-color Disable colors on console.
282+
-v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands.
283+
-h, --help [verbose] Display help for commands and options.
283284

284285
To see list of all supported commands and options run 'webpack --help=verbose'.
285286

test/cli/cli.test.js

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,6 @@ describe('CLI', () => {
105105
.catch(done);
106106
});
107107

108-
it('--client-host', (done) => {
109-
testBin('--client-host 0.0.0.0')
110-
.then((output) => {
111-
expect(output.exitCode).toEqual(0);
112-
done();
113-
})
114-
.catch(done);
115-
});
116-
117-
it('--client-path', (done) => {
118-
testBin('--client-path /ws')
119-
.then((output) => {
120-
expect(output.exitCode).toEqual(0);
121-
done();
122-
})
123-
.catch(done);
124-
});
125-
126-
it('--client-port', (done) => {
127-
testBin('--client-path 8080')
128-
.then((output) => {
129-
expect(output.exitCode).toEqual(0);
130-
done();
131-
})
132-
.catch(done);
133-
});
134-
135108
it('--client-overlay', (done) => {
136109
testBin('--client-overlay')
137110
.then((output) => {
@@ -279,6 +252,42 @@ describe('CLI', () => {
279252
.catch(done);
280253
});
281254

255+
it('--client-web-socket-url', (done) => {
256+
testBin('--client-web-socket-url ws://myhost.com:8080/foo/test')
257+
.then((output) => {
258+
expect(output.exitCode).toEqual(0);
259+
done();
260+
})
261+
.catch(done);
262+
});
263+
264+
it('--client-web-socket-url-host', (done) => {
265+
testBin('--client-web-socket-url-host 0.0.0.0')
266+
.then((output) => {
267+
expect(output.exitCode).toEqual(0);
268+
done();
269+
})
270+
.catch(done);
271+
});
272+
273+
it('--client-web-socket-url-path', (done) => {
274+
testBin('--client-web-socket-url-path /ws')
275+
.then((output) => {
276+
expect(output.exitCode).toEqual(0);
277+
done();
278+
})
279+
.catch(done);
280+
});
281+
282+
it('--client-web-socket-url-port', (done) => {
283+
testBin('--client-web-socket-url-port 8080')
284+
.then((output) => {
285+
expect(output.exitCode).toEqual(0);
286+
done();
287+
})
288+
.catch(done);
289+
});
290+
282291
it('--web-socket-server sockjs', (done) => {
283292
testBin('--web-socket-server sockjs')
284293
.then((output) => {

test/helpers/test-bin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const basicConfigPath = path.resolve(
1717
function testBin(testArgs, configPath) {
1818
const cwd = process.cwd();
1919
const env = {
20-
WEBPACK_CLI_HELP_WIDTH: 1024,
20+
WEBPACK_CLI_HELP_WIDTH: 2048,
2121
NODE_ENV: process.env.NODE_ENV,
2222
};
2323

0 commit comments

Comments
 (0)