diff --git a/README.md b/README.md index 57ac812ef9..ac70cf8ae5 100644 --- a/README.md +++ b/README.md @@ -137,8 +137,7 @@ Options: --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen --no-open Negative 'open' option. - --open-target [value...] Opens specified page in browser. - --no-open-target Negative 'open-target' option. + --open-target Opens specified page in browser. --open-app-name Open specified browser. --open-app Open specified browser. --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 0908c5eaac..326c76c5c5 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -575,12 +575,6 @@ module.exports = { }, 'open-target': { configs: [ - { - type: 'boolean', - multiple: true, - description: 'Opens specified page in browser.', - path: 'open[].target', - }, { type: 'string', multiple: true, diff --git a/lib/Server.js b/lib/Server.js index 80eb1fe858..387c2bd39f 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -643,78 +643,30 @@ class Server { }); } - openBrowser(uri) { + openBrowser(defaultOpenTarget) { const isAbsoluteUrl = require('is-absolute-url'); const open = require('open'); - // https://github.com/webpack/webpack-dev-server/issues/1990 - const defaultOpenOptions = { wait: false }; - const openTasks = []; - - const getOpenTask = (item) => { - if (typeof item === 'boolean') { - return [{ target: uri, options: defaultOpenOptions }]; - } - - if (typeof item === 'string') { - return [{ target: item, options: defaultOpenOptions }]; - } - - let targets; - - if (item.target) { - targets = Array.isArray(item.target) ? item.target : [item.target]; - } else { - targets = [uri]; - } - - return targets.map((target) => { - const openOptions = defaultOpenOptions; - - if (item.app) { - if (typeof item.app === 'string') { - openOptions.app = { name: item.app }; - } else { - openOptions.app = item.app; - } - } - - return { target, options: openOptions }; - }); - }; - - if (Array.isArray(this.options.open)) { - this.options.open.forEach((item) => { - openTasks.push(...getOpenTask(item)); - }); - } else { - openTasks.push(...getOpenTask(this.options.open)); - } - Promise.all( - openTasks.map((openTask) => { + this.options.open.map((item) => { let openTarget; - if (openTask.target) { - if (typeof openTask.target === 'boolean') { - openTarget = uri; - } else { - openTarget = isAbsoluteUrl(openTask.target) - ? openTask.target - : new URL(openTask.target, uri).toString(); - } + if (item.target === '') { + openTarget = defaultOpenTarget; } else { - openTarget = uri; + openTarget = isAbsoluteUrl(item.target) + ? item.target + : new URL(item.target, defaultOpenTarget).toString(); } - return open(openTarget, openTask.options).catch(() => { + return open(openTarget, item.options).catch(() => { this.logger.warn( `Unable to open "${openTarget}" page${ // eslint-disable-next-line no-nested-ternary - openTask.options.app - ? ` in "${openTask.options.app.name}" app${ - openTask.options.app.arguments - ? ` with "${openTask.options.app.arguments.join( + item.options.app + ? ` in "${item.options.app.name}" app${ + item.options.app.arguments + ? ` with "${item.options.app.arguments.join( ' ' )}" arguments` : '' @@ -766,7 +718,7 @@ class Server { } else { const protocol = this.options.https ? 'https' : 'http'; const { address, port } = this.server.address(); - const prettyPrintUrl = (newHostname) => + const prettyPrintURL = (newHostname) => url.format({ protocol, hostname: newHostname, port, pathname: '/' }); let server; @@ -778,7 +730,7 @@ class Server { if (this.options.host) { if (this.options.host === 'localhost') { - localhost = prettyPrintUrl('localhost'); + localhost = prettyPrintURL('localhost'); } else { let isIP; @@ -789,7 +741,7 @@ class Server { } if (!isIP) { - server = prettyPrintUrl(this.options.host); + server = prettyPrintURL(this.options.host); } } } @@ -797,33 +749,33 @@ class Server { const parsedIP = ipaddr.parse(address); if (parsedIP.range() === 'unspecified') { - localhost = prettyPrintUrl('localhost'); + localhost = prettyPrintURL('localhost'); const networkIPv4 = internalIp.v4.sync(); if (networkIPv4) { - networkUrlIPv4 = prettyPrintUrl(networkIPv4); + networkUrlIPv4 = prettyPrintURL(networkIPv4); } const networkIPv6 = internalIp.v6.sync(); if (networkIPv6) { - networkUrlIPv6 = prettyPrintUrl(networkIPv6); + networkUrlIPv6 = prettyPrintURL(networkIPv6); } } else if (parsedIP.range() === 'loopback') { if (parsedIP.kind() === 'ipv4') { - loopbackIPv4 = prettyPrintUrl(parsedIP.toString()); + loopbackIPv4 = prettyPrintURL(parsedIP.toString()); } else if (parsedIP.kind() === 'ipv6') { - loopbackIPv6 = prettyPrintUrl(parsedIP.toString()); + loopbackIPv6 = prettyPrintURL(parsedIP.toString()); } } else { networkUrlIPv4 = parsedIP.kind() === 'ipv6' && parsedIP.isIPv4MappedAddress() - ? prettyPrintUrl(parsedIP.toIPv4Address().toString()) - : prettyPrintUrl(address); + ? prettyPrintURL(parsedIP.toIPv4Address().toString()) + : prettyPrintURL(address); if (parsedIP.kind() === 'ipv6') { - networkUrlIPv6 = prettyPrintUrl(address); + networkUrlIPv6 = prettyPrintURL(address); } } @@ -854,8 +806,8 @@ class Server { ); } - if (this.options.open) { - const openTarget = prettyPrintUrl(this.options.host || 'localhost'); + if (this.options.open.length > 0) { + const openTarget = prettyPrintURL(this.options.host || 'localhost'); this.openBrowser(openTarget); } diff --git a/lib/options.json b/lib/options.json index d72e6ac051..258da5aa34 100644 --- a/lib/options.json +++ b/lib/options.json @@ -379,9 +379,6 @@ "type": "string" } }, - { - "type": "boolean" - }, { "type": "string" } diff --git a/lib/utils/normalizeOptions.js b/lib/utils/normalizeOptions.js index 2234967a2d..9902046e23 100644 --- a/lib/utils/normalizeOptions.js +++ b/lib/utils/normalizeOptions.js @@ -230,6 +230,54 @@ function normalizeOptions(compiler, options, logger, cacheDir) { options.liveReload = typeof options.liveReload !== 'undefined' ? options.liveReload : true; + // https://github.com/webpack/webpack-dev-server/issues/1990 + const defaultOpenOptions = { wait: false }; + const getOpenItemsFromObject = ({ target, ...rest }) => { + const normalizedOptions = { ...defaultOpenOptions, ...rest }; + + if (typeof normalizedOptions.app === 'string') { + normalizedOptions.app = { + name: normalizedOptions.app, + }; + } + + const normalizedTarget = typeof target === 'undefined' ? '' : target; + + if (Array.isArray(normalizedTarget)) { + return normalizedTarget.map((singleTarget) => { + return { target: singleTarget, options: normalizedOptions }; + }); + } + + return [{ target: normalizedTarget, options: normalizedOptions }]; + }; + + if (typeof options.open === 'undefined') { + options.open = []; + } else if (typeof options.open === 'boolean') { + options.open = options.open + ? [{ target: '', options: defaultOpenOptions }] + : []; + } else if (typeof options.open === 'string') { + options.open = [{ target: options.open, options: defaultOpenOptions }]; + } else if (Array.isArray(options.open)) { + const result = []; + + options.open.forEach((item) => { + if (typeof item === 'string') { + result.push({ target: item, options: defaultOpenOptions }); + + return; + } + + result.push(...getOpenItemsFromObject(item)); + }); + + options.open = result; + } else { + options.open = [...getOpenItemsFromObject(options.open)]; + } + if (typeof options.port === 'string' && options.port !== 'auto') { options.port = Number(options.port); } diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index eb47b2c65d..34f109e9d2 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -450,12 +450,11 @@ exports[`options validate should throw an error on the "open" option with '{"tar -> Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen Details: * options.open.target should be one of these: - [string, ...] | boolean | string + [string, ...] | string -> Opens specified page in browser. Details: * options.open.target should be an array: [string, ...] - * options.open.target should be a boolean. * options.open.target should be a string." `; diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index eb47b2c65d..34f109e9d2 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -450,12 +450,11 @@ exports[`options validate should throw an error on the "open" option with '{"tar -> Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen Details: * options.open.target should be one of these: - [string, ...] | boolean | string + [string, ...] | string -> Opens specified page in browser. Details: * options.open.target should be an array: [string, ...] - * options.open.target should be a boolean. * options.open.target should be a string." `; diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack4 b/test/cli/__snapshots__/basic.test.js.snap.webpack4 index 62769e4f10..30fce5d175 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack4 @@ -87,8 +87,7 @@ Options: --no-live-reload Disables reload/refresh the page(s) when file changes are detected (enabled by default) --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen --no-open Does not open the default browser. - --open-target [value...] Opens specified page in browser. - --no-open-target Does not open specified page in browser. + --open-target Opens specified page in browser. --open-app-name Open specified browser. --open-app Open specified browser. --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen diff --git a/test/cli/__snapshots__/basic.test.js.snap.webpack5 b/test/cli/__snapshots__/basic.test.js.snap.webpack5 index 7a9fbbcb53..929b06d546 100644 --- a/test/cli/__snapshots__/basic.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/basic.test.js.snap.webpack5 @@ -87,8 +87,7 @@ Options: --no-live-reload Negative 'live-reload' option. --open [value...] Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen --no-open Negative 'open' option. - --open-target [value...] Opens specified page in browser. - --no-open-target Negative 'open-target' option. + --open-target Opens specified page in browser. --open-app-name Open specified browser. --open-app Open specified browser. --open-reset Clear all items provided in 'open' configuration. Allows to configure dev server to open the browser(s) and page(s) after server had been started (set it to true to open your default browser). https://webpack.js.org/configuration/dev-server/#devserveropen diff --git a/test/cli/__snapshots__/host-option.test.js.snap.webpack4 b/test/cli/__snapshots__/host-option.test.js.snap.webpack4 index 5f52f39a6f..6989e36475 100644 --- a/test/cli/__snapshots__/host-option.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/host-option.test.js.snap.webpack4 @@ -14,6 +14,12 @@ exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 1`] = ` [webpack-dev-server] Content not from webpack is served from '/public' directory" `; +exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 2`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://[::1]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + exports[`"host" CLI option should work using "--host ": stderr 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -28,13 +34,6 @@ exports[`"host" CLI option should work using "--host 0.0.0.0" (IPv4): stderr 1`] [webpack-dev-server] Content not from webpack is served from '/public' directory" `; -exports[`"host" CLI option should work using "--host 0:0:0:0:0:FFFF:7F00:0001" (IPv6): stderr 1`] = ` -" [webpack-dev-server] Project is running at: - [webpack-dev-server] On Your Network (IPv4): http://127.0.0.1:/ - [webpack-dev-server] On Your Network (IPv6): http://[::ffff:127.0.0.1]:/ - [webpack-dev-server] Content not from webpack is served from '/public' directory" -`; - exports[`"host" CLI option should work using "--host 127.0.0.1" (IPv4): stderr 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://127.0.0.1:/ diff --git a/test/cli/__snapshots__/host-option.test.js.snap.webpack5 b/test/cli/__snapshots__/host-option.test.js.snap.webpack5 index 5f52f39a6f..6989e36475 100644 --- a/test/cli/__snapshots__/host-option.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/host-option.test.js.snap.webpack5 @@ -14,6 +14,12 @@ exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 1`] = ` [webpack-dev-server] Content not from webpack is served from '/public' directory" `; +exports[`"host" CLI option should work using "--host ::1" (IPv6): stderr 2`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://[::1]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + exports[`"host" CLI option should work using "--host ": stderr 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -28,13 +34,6 @@ exports[`"host" CLI option should work using "--host 0.0.0.0" (IPv4): stderr 1`] [webpack-dev-server] Content not from webpack is served from '/public' directory" `; -exports[`"host" CLI option should work using "--host 0:0:0:0:0:FFFF:7F00:0001" (IPv6): stderr 1`] = ` -" [webpack-dev-server] Project is running at: - [webpack-dev-server] On Your Network (IPv4): http://127.0.0.1:/ - [webpack-dev-server] On Your Network (IPv6): http://[::ffff:127.0.0.1]:/ - [webpack-dev-server] Content not from webpack is served from '/public' directory" -`; - exports[`"host" CLI option should work using "--host 127.0.0.1" (IPv4): stderr 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://127.0.0.1:/ diff --git a/test/cli/allowedHosts-option.test.js b/test/cli/allowedHosts-option.test.js index 8004312b37..b7222235c4 100644 --- a/test/cli/allowedHosts-option.test.js +++ b/test/cli/allowedHosts-option.test.js @@ -6,10 +6,10 @@ const port = require('../ports-map')['cli-allowed-hosts']; describe('"allowedHosts" CLI option', () => { it('should work using "--allowed-hosts auto"', async () => { const { exitCode } = await testBin([ - '--allowed-hosts', - 'auto', '--port', port, + '--allowed-hosts', + 'auto', ]); expect(exitCode).toEqual(0); @@ -17,10 +17,10 @@ describe('"allowedHosts" CLI option', () => { it('should work using "--allowed-hosts all"', async () => { const { exitCode } = await testBin([ - '--allowed-hosts', - 'all', '--port', port, + '--allowed-hosts', + 'all', ]); expect(exitCode).toEqual(0); @@ -28,10 +28,10 @@ describe('"allowedHosts" CLI option', () => { it('should work using "--allowed-hosts testhouse.com"', async () => { const { exitCode } = await testBin([ - '--allowed-hosts', - 'testhouse.com', '--port', port, + '--allowed-hosts', + 'testhouse.com', ]); expect(exitCode).toEqual(0); @@ -39,12 +39,12 @@ describe('"allowedHosts" CLI option', () => { it('should work using "--allowed-hosts testhost.com --allowed-hosts testhost1.com"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--allowed-hosts', 'testhost.com', '--allowed-hosts', 'testhost1.com', - '--port', - port, ]); expect(exitCode).toEqual(0); diff --git a/test/cli/basic.test.js b/test/cli/basic.test.js index 61411dfd5c..83c662afdf 100644 --- a/test/cli/basic.test.js +++ b/test/cli/basic.test.js @@ -43,7 +43,11 @@ describe('basic', () => { describe('basic', () => { it('should work', async () => { - const { exitCode, stderr } = await testBin(''); + const { exitCode, stderr } = await testBin([ + // Ideally it should be empty to test without arguments, unfortunately it takes 8080 port and other test can failed + '--port', + port, + ]); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot('stderr'); @@ -51,10 +55,10 @@ describe('basic', () => { it('should work using "--host localhost --port "', async () => { const { exitCode, stderr } = await testBin([ - '--host', - 'localhost', '--port', port, + '--host', + 'localhost', ]); expect(exitCode).toEqual(0); @@ -63,15 +67,15 @@ describe('basic', () => { it('should accept the promise function of webpack.config.js', async () => { try { - const { exitCode } = await testBin( - false, + const { exitCode } = await testBin([ + '--config', path.resolve( __dirname, '../fixtures/promise-config/webpack.config.js' ), '--port', - port - ); + port, + ]); expect(exitCode).toEqual(0); } catch (err) { // for windows @@ -88,7 +92,7 @@ describe('basic', () => { __dirname, '../../examples/cli/web-socket-url' ); - const cp = execa('node', [cliPath, '--port', port], { cwd: examplePath }); + const cp = execa('node', ['--port', port, cliPath], { cwd: examplePath }); cp.stdout.on('data', (data) => { const bits = data.toString(); @@ -111,7 +115,7 @@ describe('basic', () => { '../../bin/webpack-dev-server.js' ); const cwd = path.resolve(__dirname, '../fixtures/cli'); - const cp = execa('node', [cliPath, '--port', port], { cwd }); + const cp = execa('node', ['--port', port, cliPath], { cwd }); let killed = false; @@ -141,7 +145,7 @@ describe('basic', () => { ); const cp = execa( 'node', - [cliPath, '--watch-options-stdin', '--port', port], + [cliPath, '--port', port, '--watch-options-stdin'], { cwd: examplePath, } @@ -171,7 +175,7 @@ describe('basic', () => { const cwd = path.resolve(__dirname, '../fixtures/cli'); const cp = execa( 'node', - [cliPath, '--watch-options-stdin', '--port', port], + [cliPath, '--port', port, '--watch-options-stdin'], { cwd } ); @@ -194,12 +198,12 @@ describe('basic', () => { }); it('should add dev server entry points to a single entry point', async () => { - const { exitCode, stdout } = await testBin( - null, - './test/fixtures/dev-server/default-config.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--config', + './test/fixtures/dev-server/default-config.js', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('client/index.js?'); @@ -208,12 +212,14 @@ describe('basic', () => { webpack5Test( 'should add dev server entry points to a multi entry point object', async () => { - const { exitCode, stdout } = await testBin( - '--stats=verbose', - './test/fixtures/dev-server/multi-entry.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--config', + './test/fixtures/dev-server/multi-entry.js', + '--stats', + 'verbose', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('client/index.js?'); @@ -224,12 +230,12 @@ describe('basic', () => { webpack5Test( 'should add dev server entry points to an empty entry object', async () => { - const { exitCode, stdout } = await testBin( - null, - './test/fixtures/dev-server/empty-entry.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--config', + './test/fixtures/dev-server/empty-entry.js', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('client/index.js?'); @@ -237,24 +243,26 @@ describe('basic', () => { ); webpack5Test('should supports entry as descriptor', async () => { - const { exitCode, stdout } = await testBin( - '--stats=detailed', - './test/fixtures/entry-as-descriptor/webpack.config', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--config', + './test/fixtures/entry-as-descriptor/webpack.config', + '--stats', + 'detailed', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('foo.js'); }); it('should only prepends dev server entry points to "web" target', async () => { - const { exitCode, stdout } = await testBin( - '--target web', - './test/fixtures/dev-server/default-config.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--target', + 'web', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('client/index.js?'); @@ -262,12 +270,12 @@ describe('basic', () => { }); it('should not prepend dev server entry points to "node" target', async () => { - const { exitCode, stdout } = await testBin( - '--target node', - './test/fixtures/dev-server/default-config.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--target', + 'node', + ]); expect(exitCode).toEqual(0); expect(stdout).not.toContain('client/index.js?'); @@ -275,12 +283,13 @@ describe('basic', () => { }); it('should prepends the hot runtime to "node" target as well', async () => { - const { exitCode, stdout } = await testBin( - '--target node --hot', - './test/fixtures/dev-server/default-config.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--target', + 'node', + '--hot', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('webpack/hot/dev-server'); @@ -289,12 +298,12 @@ describe('basic', () => { webpack5Test( 'should prepend dev server entry points depending on targetProperties', async () => { - const { exitCode, stdout } = await testBin( - null, - './test/fixtures/dev-server/target-config.js', + const { exitCode, stdout } = await testBin([ '--port', - port - ); + port, + '--config', + './test/fixtures/dev-server/target-config.js', + ]); expect(exitCode).toEqual(0); expect(stdout).toContain('client/index.js'); diff --git a/test/cli/bonjour-option.test.js b/test/cli/bonjour-option.test.js index 2d8d0a0bdd..7cc424c6b8 100644 --- a/test/cli/bonjour-option.test.js +++ b/test/cli/bonjour-option.test.js @@ -5,7 +5,7 @@ const port = require('../ports-map')['cli-bonjour']; describe('"bonjour" CLI option', () => { it('should work using "--bonjour"', async () => { - const { exitCode, stderr } = await testBin(['--bonjour', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--bonjour']); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot(); @@ -13,10 +13,10 @@ describe('"bonjour" CLI option', () => { it('should work using "--bonjour and --https"', async () => { const { exitCode, stderr } = await testBin([ - '--bonjour', - '--https', '--port', port, + '--bonjour', + '--https', ]); expect(exitCode).toEqual(0); @@ -27,9 +27,9 @@ describe('"bonjour" CLI option', () => { it('should work using "--no-bonjour"', async () => { const { exitCode, stderr } = await testBin([ - '--no-bonjour', '--port', port, + '--no-bonjour', ]); expect(exitCode).toEqual(0); diff --git a/test/cli/client-option.test.js b/test/cli/client-option.test.js index 87e079e618..cc67251fd1 100644 --- a/test/cli/client-option.test.js +++ b/test/cli/client-option.test.js @@ -6,10 +6,10 @@ const port = require('../ports-map')['cli-client']; describe('"client" CLI option', () => { it('should work using "--client-transport sockjs"', async () => { const { exitCode } = await testBin([ - '--client-transport', - 'sockjs', '--port', port, + '--client-transport', + 'sockjs', ]); expect(exitCode).toEqual(0); @@ -17,32 +17,32 @@ describe('"client" CLI option', () => { it('should work using "--client-transport ws"', async () => { const { exitCode } = await testBin([ - '--client-transport', - 'ws', '--port', port, + '--client-transport', + 'ws', ]); expect(exitCode).toEqual(0); }); it('should work using "--client-overlay"', async () => { - const { exitCode } = await testBin(['--client-overlay', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--client-overlay']); expect(exitCode).toEqual(0); }); it('should work using "--no-client-overlay"', async () => { - const { exitCode } = await testBin(['--no-client-overlay', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--no-client-overlay']); expect(exitCode).toEqual(0); }); it('should work using "--client-overlay-errors"', async () => { const { exitCode } = await testBin([ - '--client-overlay-errors', '--port', port, + '--client-overlay-errors', ]); expect(exitCode).toEqual(0); @@ -50,9 +50,9 @@ describe('"client" CLI option', () => { it('should work using "--no-client-overlay-errors"', async () => { const { exitCode } = await testBin([ - '--no-client-overlay-errors', '--port', port, + '--no-client-overlay-errors', ]); expect(exitCode).toEqual(0); @@ -60,9 +60,9 @@ describe('"client" CLI option', () => { it('should work using "--client-overlay-warnings"', async () => { const { exitCode } = await testBin([ - '--client-overlay-warnings', '--port', port, + '--client-overlay-warnings', ]); expect(exitCode).toEqual(0); @@ -70,9 +70,9 @@ describe('"client" CLI option', () => { it('should work using "--no-client-overlay-warnings"', async () => { const { exitCode } = await testBin([ - '--no-client-overlay-warnings', '--port', port, + '--no-client-overlay-warnings', ]); expect(exitCode).toEqual(0); @@ -80,10 +80,10 @@ describe('"client" CLI option', () => { it('should work using "--client-need-client-entry"', async () => { const { exitCode, stdout } = await testBin([ - '--client-need-client-entry', - '--stats=detailed', '--port', port, + '--client-need-client-entry', + '--stats=detailed', ]); expect(exitCode).toEqual(0); @@ -92,10 +92,10 @@ describe('"client" CLI option', () => { it('should work using "--no-client-need-client-entry"', async () => { const { exitCode, stdout } = await testBin([ - '--no-client-need-client-entry', - '--stats=detailed', '--port', port, + '--no-client-need-client-entry', + '--stats=detailed', ]); expect(exitCode).toEqual(0); @@ -104,26 +104,26 @@ describe('"client" CLI option', () => { it('should work using "--client-logging"', async () => { const { exitCode } = await testBin([ - '--client-logging', - 'verbose', '--port', port, + '--client-logging', + 'verbose', ]); expect(exitCode).toEqual(0); }); it('should work using "--client-progress"', async () => { - const { exitCode } = await testBin(['--client-progress', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--client-progress']); expect(exitCode).toEqual(0); }); it('should work using "--no-client-progress"', async () => { const { exitCode } = await testBin([ - '--no-client-progress', '--port', port, + '--no-client-progress', ]); expect(exitCode).toEqual(0); @@ -131,10 +131,11 @@ describe('"client" CLI option', () => { it('should work using "--client-hot-entry"', async () => { const { exitCode, stdout } = await testBin([ - '--client-hot-entry', - '--stats=detailed', '--port', port, + '--client-hot-entry', + '--stats', + 'detailed', ]); expect(exitCode).toEqual(0); @@ -143,10 +144,11 @@ describe('"client" CLI option', () => { it('should work using "--no-client-hot-entry"', async () => { const { exitCode, stdout } = await testBin([ - '--no-client-hot-entry', - '--stats=detailed', '--port', port, + '--no-client-hot-entry', + '--stats', + 'detailed', ]); expect(exitCode).toEqual(0); @@ -155,11 +157,12 @@ describe('"client" CLI option', () => { it('should not inject HMR entry using "--client-hot-entry --no-hot"', async () => { const { exitCode, stdout } = await testBin([ - '--client-hot-entry', - '--no-hot', - '--stats=detailed', '--port', port, + '--client-hot-entry', + '--no-hot', + '--stats', + 'detailed', ]); expect(exitCode).toEqual(0); @@ -168,11 +171,12 @@ describe('"client" CLI option', () => { it('should not inject HMR entry using "--no-client-hot-entry --hot"', async () => { const { exitCode, stdout } = await testBin([ - '--no-client-hot-entry', - '--hot', - '--stats=detailed', '--port', port, + '--no-client-hot-entry', + '--hot', + '--stats', + 'detailed', ]); expect(exitCode).toEqual(0); @@ -181,10 +185,10 @@ describe('"client" CLI option', () => { it('should work using "--client-web-socket-url"', async () => { const { exitCode } = await testBin([ - '--client-web-socket-url', - 'ws://myhost.com:8080/foo/test', '--port', port, + '--client-web-socket-url', + 'ws://myhost.com:8080/foo/test', ]); expect(exitCode).toEqual(0); @@ -192,10 +196,10 @@ describe('"client" CLI option', () => { it('should work using "--client-web-socket-url-protocol"', async () => { const { exitCode } = await testBin([ - '--client-web-socket-url-protocol', - 'ws:', '--port', port, + '--client-web-socket-url-protocol', + 'ws:', ]); expect(exitCode).toEqual(0); @@ -203,10 +207,10 @@ describe('"client" CLI option', () => { it('should work using "--client-web-socket-url-hostname"', async () => { const { exitCode } = await testBin([ - '--client-web-socket-url-hostname', - '0.0.0.0', '--port', port, + '--client-web-socket-url-hostname', + '0.0.0.0', ]); expect(exitCode).toEqual(0); @@ -214,10 +218,10 @@ describe('"client" CLI option', () => { it('should work using "--client-web-socket-url-pathname"', async () => { const { exitCode } = await testBin([ - '--client-web-socket-url-pathname', - '/ws', '--port', port, + '--client-web-socket-url-pathname', + '/ws', ]); expect(exitCode).toEqual(0); @@ -225,10 +229,10 @@ describe('"client" CLI option', () => { it('should work using "--client-web-socket-url-port"', async () => { const { exitCode } = await testBin([ - '--client-web-socket-url-port', - 8080, '--port', port, + '--client-web-socket-url-port', + 8080, ]); expect(exitCode).toEqual(0); diff --git a/test/cli/colors.test.js b/test/cli/colors.test.js index 2467f65e1f..c4f308b67d 100644 --- a/test/cli/colors.test.js +++ b/test/cli/colors.test.js @@ -15,12 +15,12 @@ const colorsEnabled = require.resolve( describe('colors', () => { it('should work use colors by default', async () => { - const { exitCode, stderr, stdout } = await testBin( + const { exitCode, stderr, stdout } = await testBin([ + '--port', + port, '--color', colorsDefaultStats, - '--port', - port - ); + ]); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot('stderr'); @@ -29,9 +29,9 @@ describe('colors', () => { it('should work use colors using "--color"', async () => { const { exitCode, stderr, stdout } = await testBin([ - '--color', '--port', port, + '--color', ]); expect(exitCode).toEqual(0); @@ -41,9 +41,9 @@ describe('colors', () => { it('should work do not use colors using "--no-color"', async () => { const { exitCode, stderr, stdout } = await testBin([ - '--no-color', '--port', port, + '--no-color', ]); expect(exitCode).toEqual(0); @@ -52,10 +52,12 @@ describe('colors', () => { }); it('should work use colors using configuration with enabled colors', async () => { - const { exitCode, stderr, stdout } = await testBin( - ['--port', port], - colorsEnabled - ); + const { exitCode, stderr, stdout } = await testBin([ + '--port', + port, + '--config', + colorsEnabled, + ]); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot('stderr'); @@ -63,10 +65,12 @@ describe('colors', () => { }); it('should work and do not use colors using configuration with disabled colors', async () => { - const { exitCode, stderr, stdout } = await testBin( - ['--port', port], - colorsDisabled - ); + const { exitCode, stderr, stdout } = await testBin([ + '--port', + port, + '--config', + colorsDisabled, + ]); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot('stderr'); diff --git a/test/cli/compress-option.test.js b/test/cli/compress-option.test.js index 616bdd9141..70042dad3f 100644 --- a/test/cli/compress-option.test.js +++ b/test/cli/compress-option.test.js @@ -5,13 +5,13 @@ const port = require('../ports-map')['cli-compress']; describe('"compress" CLI option', () => { it('should work using "--compress"', async () => { - const { exitCode } = await testBin(['--compress', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--compress']); expect(exitCode).toEqual(0); }); it('should work using "--no-compress"', async () => { - const { exitCode } = await testBin(['--no-compress', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--no-compress']); expect(exitCode).toEqual(0); }); diff --git a/test/cli/historyApiFallback-option.test.js b/test/cli/historyApiFallback-option.test.js index 210e062fba..afd857fee1 100644 --- a/test/cli/historyApiFallback-option.test.js +++ b/test/cli/historyApiFallback-option.test.js @@ -6,9 +6,9 @@ const port = require('../ports-map')['cli-history-api-fallback']; describe('"historyApiFallback" CLI option', () => { it('should work using "--history-api-fallback"', async () => { const { exitCode, stderr } = await testBin([ - '--history-api-fallback', '--port', port, + '--history-api-fallback', ]); expect(exitCode).toEqual(0); @@ -17,9 +17,9 @@ describe('"historyApiFallback" CLI option', () => { it('should work using "--no-history-api-fallback"', async () => { const { exitCode, stderr } = await testBin([ - '--no-history-api-fallback', '--port', port, + '--no-history-api-fallback', ]); expect(exitCode).toEqual(0); diff --git a/test/cli/host-option.test.js b/test/cli/host-option.test.js index 234121820c..5ea2f75fd8 100644 --- a/test/cli/host-option.test.js +++ b/test/cli/host-option.test.js @@ -10,10 +10,10 @@ const localIPv6 = internalIp.v6.sync(); describe('"host" CLI option', () => { it('should work using "--host 0.0.0.0" (IPv4)', async () => { const { exitCode, stderr } = await testBin([ - '--host', - '0.0.0.0', '--port', port, + '--host', + '0.0.0.0', ]); expect(exitCode).toEqual(0); @@ -22,10 +22,10 @@ describe('"host" CLI option', () => { it('should work using "--host ::" (IPv6)', async () => { const { exitCode, stderr } = await testBin([ - '--host', - '::', '--port', port, + '--host', + '::', ]); expect(exitCode).toEqual(0); @@ -34,10 +34,10 @@ describe('"host" CLI option', () => { it('should work using "--host ::1" (IPv6)', async () => { const { exitCode, stderr } = await testBin([ - '--host', - '::1', '--port', port, + '--host', + '::1', ]); expect(exitCode).toEqual(0); @@ -46,10 +46,10 @@ describe('"host" CLI option', () => { it('should work using "--host localhost"', async () => { const { exitCode, stderr } = await testBin([ - '--host', - 'localhost', '--port', port, + '--host', + 'localhost', ]); expect(exitCode).toEqual(0); @@ -58,22 +58,22 @@ describe('"host" CLI option', () => { it('should work using "--host 127.0.0.1" (IPv4)', async () => { const { exitCode, stderr } = await testBin([ - '--host', - '127.0.0.1', '--port', port, + '--host', + '127.0.0.1', ]); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); }); - it('should work using "--host 0:0:0:0:0:FFFF:7F00:0001" (IPv6)', async () => { + it('should work using "--host ::1" (IPv6)', async () => { const { exitCode, stderr } = await testBin([ - '--host', - '0:0:0:0:0:FFFF:7F00:0001', '--port', port, + '--host', + '::1', ]); expect(exitCode).toEqual(0); @@ -82,10 +82,10 @@ describe('"host" CLI option', () => { it(`should work using "--host "`, async () => { const { exitCode, stderr } = await testBin([ - '--host', - localIPv4, '--port', port, + '--host', + localIPv4, ]); expect(exitCode).toEqual(0); @@ -94,10 +94,10 @@ describe('"host" CLI option', () => { it.skip(`should work using "--host "`, async () => { const { exitCode, stderr } = await testBin([ - '--host', - localIPv6, '--port', port, + '--host', + localIPv6, ]); expect(exitCode).toEqual(0); @@ -106,10 +106,10 @@ describe('"host" CLI option', () => { it('should work using "--host local-ip"', async () => { const { exitCode, stderr } = await testBin([ - '--host', - 'local-ip', '--port', port, + '--host', + 'local-ip', ]); expect(exitCode).toEqual(0); @@ -118,10 +118,10 @@ describe('"host" CLI option', () => { it('should work using "--host local-ipv4"', async () => { const { exitCode, stderr } = await testBin([ - '--host', - 'local-ipv4', '--port', port, + '--host', + 'local-ipv4', ]); expect(exitCode).toEqual(0); diff --git a/test/cli/hot-option.test.js b/test/cli/hot-option.test.js index f26efef1c9..70ad756426 100644 --- a/test/cli/hot-option.test.js +++ b/test/cli/hot-option.test.js @@ -6,10 +6,10 @@ const port = require('../ports-map')['cli-hot']; describe('"hot" CLI option', () => { it('should work using "--hot"', async () => { const { exitCode, stdout } = await testBin([ - '--hot', - '--stats=detailed', '--port', port, + '--hot', + '--stats=detailed', ]); expect(exitCode).toEqual(0); @@ -18,10 +18,10 @@ describe('"hot" CLI option', () => { it('should work using "--no-hot"', async () => { const { exitCode, stdout } = await testBin([ - '--no-hot', - '--stats=detailed', '--port', port, + '--no-hot', + '--stats=detailed', ]); expect(exitCode).toEqual(0); @@ -30,10 +30,10 @@ describe('"hot" CLI option', () => { it('should work using "--hot only"', async () => { const { exitCode, stdout } = await testBin([ - '--hot', - 'only', '--port', port, + '--hot', + 'only', ]); expect(exitCode).toEqual(0); diff --git a/test/cli/http2-option.test.js b/test/cli/http2-option.test.js index a9caab6f89..9a12d70fbb 100644 --- a/test/cli/http2-option.test.js +++ b/test/cli/http2-option.test.js @@ -5,7 +5,7 @@ const port = require('../ports-map')['cli-http2']; describe('"http2" CLI option', () => { it('should work using "--http2"', async () => { - const { exitCode, stderr } = await testBin(['--http2', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--http2']); expect(exitCode).toEqual(0); expect( @@ -14,7 +14,7 @@ describe('"http2" CLI option', () => { }); it('should work using "--no-http2"', async () => { - const { exitCode, stderr } = await testBin(['--no-http2', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--no-http2']); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot(); diff --git a/test/cli/https-option.test.js b/test/cli/https-option.test.js index 9c50e48f69..4b2b8c8d4d 100644 --- a/test/cli/https-option.test.js +++ b/test/cli/https-option.test.js @@ -11,7 +11,7 @@ const httpsCertificateDirectory = path.resolve( describe('"https" CLI option', () => { it('should work using "--https"', async () => { - const { exitCode, stderr } = await testBin(['--https', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--https']); expect(exitCode).toEqual(0); expect( @@ -26,9 +26,20 @@ describe('"https" CLI option', () => { const cacert = path.join(httpsCertificateDirectory, 'ca.pem'); const passphrase = 'webpack-dev-server'; - const { exitCode, stderr } = await testBin( - `--https-key ${key} --https-pfx ${pfxFile} --https-passphrase ${passphrase} --https-cert ${cert} --https-cacert ${cacert}` - ); + const { exitCode, stderr } = await testBin([ + '--port', + port, + '--https-key', + key, + '--https-pfx', + pfxFile, + '--https-passphrase', + passphrase, + '--https-cert', + cert, + '--https-cacert', + cacert, + ]); expect(exitCode).toEqual(0); expect( @@ -44,6 +55,8 @@ describe('"https" CLI option', () => { const passphrase = 'webpack-dev-server'; const { exitCode, stderr } = await testBin([ + '--port', + port, '--https-key', key, '--https-pfx', @@ -52,8 +65,6 @@ describe('"https" CLI option', () => { passphrase, '--https-cert', cert, - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -64,9 +75,9 @@ describe('"https" CLI option', () => { it('should work using "--https-request-cert"', async () => { const { exitCode, stderr } = await testBin([ - '--https-request-cert', '--port', port, + '--https-request-cert', ]); expect(exitCode).toEqual(0); @@ -77,9 +88,9 @@ describe('"https" CLI option', () => { it('should work using "--no-https-request-cert"', async () => { const { exitCode, stderr } = await testBin([ - '--no-https-request-cert', '--port', port, + '--no-https-request-cert', ]); expect(exitCode).toEqual(0); @@ -89,7 +100,7 @@ describe('"https" CLI option', () => { }); it('should work using "--no-https"', async () => { - const { exitCode, stderr } = await testBin(['--no-https', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--no-https']); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot(); diff --git a/test/cli/liveReload-option.test.js b/test/cli/liveReload-option.test.js index ca59cb29b3..5177540200 100644 --- a/test/cli/liveReload-option.test.js +++ b/test/cli/liveReload-option.test.js @@ -5,13 +5,13 @@ const port = require('../ports-map')['cli-live-reload']; describe('"liveReload" CLI option', () => { it('should work using "--live-reload"', async () => { - const { exitCode } = await testBin(['--live-reload', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--live-reload']); expect(exitCode).toEqual(0); }); it('should work using "--no-live-reload"', async () => { - const { exitCode } = await testBin(['--no-live-reload', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--no-live-reload']); expect(exitCode).toEqual(0); }); diff --git a/test/cli/open-option.test.js b/test/cli/open-option.test.js index 395bbaf0c7..552e82e68c 100644 --- a/test/cli/open-option.test.js +++ b/test/cli/open-option.test.js @@ -5,17 +5,17 @@ const port = require('../ports-map')['cli-open']; describe('"open" CLI option', () => { it('should work using "--open"', async () => { - const { exitCode } = await testBin(['--open', '--port', port]); + const { exitCode } = await testBin(['--port', port, '--open']); expect(exitCode).toEqual(0); }); it('should work using "--open /index.html"', async () => { const { exitCode } = await testBin([ - '--open', - '/index.html', '--port', port, + '--open', + '/index.html', ]); expect(exitCode).toEqual(0); @@ -23,11 +23,11 @@ describe('"open" CLI option', () => { it('should work using "--open /first.html second.html"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open', '/first.html', 'second.html', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -39,24 +39,25 @@ describe('"open" CLI option', () => { expect(exitCode).toEqual(0); }); - it('should work using "--open-reset"', async () => { + it('should work using "--open-reset --open /third.html"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-reset', '--open', '/third.html', - '--port', - port, ]); expect(exitCode).toEqual(0); }); - it('should work using "--open-reset --open-target"', async () => { + it('should work using "--open-reset --open-target "', async () => { const { exitCode } = await testBin([ - '--open-reset', - '--open-target', '--port', port, + '--open-reset', + '--open-target', + '', ]); expect(exitCode).toEqual(0); @@ -64,11 +65,11 @@ describe('"open" CLI option', () => { it('should work using "--open-reset --open-target /third.html"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-reset', '--open-target', '/third.html', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -76,10 +77,10 @@ describe('"open" CLI option', () => { it('should work using "--open-app google-chrome"', async () => { const { exitCode } = await testBin([ - '--open-app', - 'google-chrome', '--port', port, + '--open-app', + 'google-chrome', ]); expect(exitCode).toEqual(0); @@ -87,10 +88,10 @@ describe('"open" CLI option', () => { it('should work using "--open-app-name google-chrome"', async () => { const { exitCode } = await testBin([ - '--open-app-name', - 'google-chrome', '--port', port, + '--open-app-name', + 'google-chrome', ]); expect(exitCode).toEqual(0); @@ -98,46 +99,34 @@ describe('"open" CLI option', () => { it('should work using "--open-app-name-reset --open-app-name firefox"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-app-name-reset', '--open-app-name', 'firefox', - '--port', - port, ]); expect(exitCode).toEqual(0); }); - it('should work using "--open-target"', async () => { - const { exitCode } = await testBin(['-open-target', '--port', port]); - - expect(exitCode).toEqual(0); - }); - - it('should work using "--no-open-target"', async () => { - const { exitCode } = await testBin(['--no-open-target', '--port', port]); - - expect(exitCode).toEqual(0); - }); - it('should work using "--open-target index.html"', async () => { const { exitCode } = await testBin([ - '--open-target', - 'index.html', '--port', port, + '--open-target', + 'index.html', ]); expect(exitCode).toEqual(0); }); - it('should work using "--open-target-reset"', async () => { + it('should work using "--open-target-reset --open-target first.html"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-target-reset', '--open-target', 'first.html', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -145,11 +134,11 @@ describe('"open" CLI option', () => { it('should work using "--open-target /first.html second.html"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-target', '/first.html', 'second.html', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -157,12 +146,12 @@ describe('"open" CLI option', () => { it('should work using "--open-target /index.html --open-app google-chrome"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-target', '/index.html', '--open-app', 'google-chrome', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -170,12 +159,12 @@ describe('"open" CLI option', () => { it('should work using "--open-target /index.html --open-app-name google-chrome"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-target', '/index.html', '--open-app-name', 'google-chrome', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -183,14 +172,14 @@ describe('"open" CLI option', () => { it('should work using "--open-target /index.html --open-app google-chrome --open-app-name google-chrome"', async () => { const { exitCode } = await testBin([ + '--port', + port, '--open-target', '/index.html', '--open-app', 'google-chrome', '--open-app-name', 'google-chrome', - '--port', - port, ]); expect(exitCode).toEqual(0); diff --git a/test/cli/static-option.test.js b/test/cli/static-option.test.js index 5d84591931..d350df9214 100644 --- a/test/cli/static-option.test.js +++ b/test/cli/static-option.test.js @@ -5,7 +5,7 @@ const port = require('../ports-map')['cli-static']; describe('"static" CLI option', () => { it('should work using "--static"', async () => { - const { exitCode, stderr } = await testBin(['--static', '--port', port]); + const { exitCode, stderr } = await testBin(['--port', port, '--static']); expect(exitCode).toEqual(0); expect(normalizeStderr(stderr, { ipv6: true })).toMatchSnapshot('stderr'); @@ -13,10 +13,10 @@ describe('"static" CLI option', () => { it('should work using "--static new-static"', async () => { const { exitCode, stderr } = await testBin([ - '--static', - 'new-static', '--port', port, + '--static', + 'new-static', ]); expect(exitCode).toEqual(0); @@ -25,12 +25,12 @@ describe('"static" CLI option', () => { it('should work using "--static new-static --static other-static"', async () => { const { exitCode, stderr } = await testBin([ + '--port', + port, '--static', 'new-static', '--static', 'other-static', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -39,11 +39,11 @@ describe('"static" CLI option', () => { it('should work using "--static-reset"', async () => { const { exitCode, stderr } = await testBin([ + '--port', + port, '--static-reset', '--static', 'new-static-after-reset', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -52,11 +52,11 @@ describe('"static" CLI option', () => { it('should work using "--static-reset --static-directory new-static-directory"', async () => { const { exitCode, stderr } = await testBin([ + '--port', + port, '--static-reset', '--static-directory', 'new-static-directory', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -65,10 +65,10 @@ describe('"static" CLI option', () => { it('should work using "--static-directory static-dir"', async () => { const { exitCode, stderr } = await testBin([ - '--static-directory', - 'static-dir', '--port', port, + '--static-directory', + 'static-dir', ]); expect(exitCode).toEqual(0); @@ -77,10 +77,10 @@ describe('"static" CLI option', () => { it('should work using "--static-public-path /public"', async () => { const { exitCode, stderr } = await testBin([ - '--static-public-path', - '/public', '--port', port, + '--static-public-path', + '/public', ]); expect(exitCode).toEqual(0); @@ -89,11 +89,11 @@ describe('"static" CLI option', () => { it('should work using "--static-public-path-reset"', async () => { const { exitCode, stderr } = await testBin([ + '--port', + port, '--static-public-path-reset', '--static-public-path', '/new-public', - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -102,9 +102,9 @@ describe('"static" CLI option', () => { it('should work using "--static-serve-index"', async () => { const { exitCode, stderr } = await testBin([ - '--static-serve-index', '--port', port, + '--static-serve-index', ]); expect(exitCode).toEqual(0); @@ -113,9 +113,9 @@ describe('"static" CLI option', () => { it('should work using "--no-static-serve-index"', async () => { const { exitCode, stderr } = await testBin([ - '--no-static-serve-index', '--port', port, + '--no-static-serve-index', ]); expect(exitCode).toEqual(0); @@ -124,9 +124,9 @@ describe('"static" CLI option', () => { it('should work using "--static-watch"', async () => { const { exitCode, stderr } = await testBin([ - '--static-watch', '--port', port, + '--static-watch', ]); expect(exitCode).toEqual(0); @@ -135,9 +135,9 @@ describe('"static" CLI option', () => { it('should work using "--no-static-watch"', async () => { const { exitCode, stderr } = await testBin([ - '--no-static-watch', '--port', port, + '--no-static-watch', ]); expect(exitCode).toEqual(0); diff --git a/test/cli/watchFiles-option.test.js b/test/cli/watchFiles-option.test.js index efc9826060..444f62c60e 100644 --- a/test/cli/watchFiles-option.test.js +++ b/test/cli/watchFiles-option.test.js @@ -9,10 +9,10 @@ describe('"watchFiles" CLI option', () => { const watchDirectory = path.resolve(__dirname, '../fixtures/static/static'); const { exitCode, stderr } = await testBin([ - '--watch-files', - watchDirectory, '--port', port, + '--watch-files', + watchDirectory, ]); expect(exitCode).toEqual(0); @@ -27,12 +27,12 @@ describe('"watchFiles" CLI option', () => { ); const { exitCode, stderr } = await testBin([ + '--port', + port, '--watch-files', watchDirectory, '--watch-files', watchOtherDirectory, - '--port', - port, ]); expect(exitCode).toEqual(0); @@ -43,11 +43,11 @@ describe('"watchFiles" CLI option', () => { const watchDirectory = path.resolve(__dirname, '../fixtures/static/static'); const { exitCode, stderr } = await testBin([ + '--port', + port, '--watch-files-reset', '--watch-files', watchDirectory, - '--port', - port, ]); expect(exitCode).toEqual(0); diff --git a/test/cli/webSocketServer-option.test.js b/test/cli/webSocketServer-option.test.js index 2cc3ad21fd..0240e5d9c6 100644 --- a/test/cli/webSocketServer-option.test.js +++ b/test/cli/webSocketServer-option.test.js @@ -6,10 +6,10 @@ const port = require('../ports-map')['cli-web-socket-server']; describe('"webSocketServer" CLI option', () => { it('should work using "--web-socket-server sockjs"', async () => { const { exitCode } = await testBin([ - '--web-socket-server', - 'sockjs', '--port', port, + '--web-socket-server', + 'sockjs', ]); expect(exitCode).toEqual(0); @@ -17,10 +17,10 @@ describe('"webSocketServer" CLI option', () => { it('should work using "--web-socket-server ws"', async () => { const { exitCode } = await testBin([ - '--web-socket-server', - 'ws', '--port', port, + '--web-socket-server', + 'ws', ]); expect(exitCode).toEqual(0); diff --git a/test/helpers/test-bin.js b/test/helpers/test-bin.js index 73c32e7d7c..c40808d3a5 100644 --- a/test/helpers/test-bin.js +++ b/test/helpers/test-bin.js @@ -15,28 +15,27 @@ const basicConfigPath = path.resolve( '../fixtures/cli/webpack.config.js' ); -const testBin = (testArgs, configPath) => { +const testBin = (testArgs = []) => { const cwd = process.cwd(); const env = { WEBPACK_CLI_HELP_WIDTH: 2048, NODE_ENV: process.env.NODE_ENV, }; - if (!configPath) { - configPath = basicConfigPath; - } - - if (!testArgs) { - testArgs = []; - } else if (typeof testArgs === 'string') { + if (typeof testArgs === 'string') { testArgs = testArgs.split(' '); } let args; + if (testArgs.includes('--help')) { - args = [webpackDevServerPath].concat(testArgs); + args = [webpackDevServerPath, ...testArgs]; } else { - args = [webpackDevServerPath, '--config', configPath].concat(testArgs); + const configOptions = testArgs.includes('--config') + ? [] + : ['--config', basicConfigPath]; + + args = [webpackDevServerPath, ...configOptions, ...testArgs]; } return execa('node', args, { cwd, env, timeout: 10000 }); diff --git a/test/server/Server.test.js b/test/server/Server.test.js index fc64d1ff2e..2b479b3252 100644 --- a/test/server/Server.test.js +++ b/test/server/Server.test.js @@ -575,15 +575,14 @@ describe('Server', () => { expect(freePort).toEqual(60000 + retryCount); }); - // TODO: fix me, Flaky on CI it('should retry finding the port when serial ports are busy', async () => { const busyPorts = [60000, 60001, 60002, 60003, 60004, 60005]; - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 6; + process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 1000; await createDummyServers(busyPorts); const freePort = await Server.getFreePort(); - expect(freePort).toEqual(60000 + busyPorts.length); + expect(freePort).toBeGreaterThan(60005); }); it("should throws the error when the port isn't found", async () => { diff --git a/test/server/open-option.test.js b/test/server/open-option.test.js index 35d60bb205..b6e0dd4cd1 100644 --- a/test/server/open-option.test.js +++ b/test/server/open-option.test.js @@ -293,6 +293,30 @@ describe('"open" option', () => { server.listen(port, host); }); + it('should work with "" pattern', (done) => { + const host = 'localhost'; + server = new Server( + { + host, + port, + open: '', + }, + compiler + ); + + compiler.hooks.done.tap('webpack-dev-server', () => { + server.close(() => { + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + wait: false, + }); + + done(); + }); + }); + + server.listen(port, host); + }); + it('should work with relative string starting with "/"', (done) => { const host = 'localhost'; server = new Server( @@ -414,22 +438,29 @@ describe('"open" option', () => { server.listen(port, host); }); - it('should work with empty object', (done) => { + it('should work with "" pattern in multiple strings', (done) => { const host = 'localhost'; server = new Server( { - host, + host: 'localhost', port, - open: {}, + open: ['', 'second.html'], }, compiler ); compiler.hooks.done.tap('webpack-dev-server', () => { server.close(() => { - expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + expect(open).toHaveBeenNthCalledWith(1, `http://${host}:${port}/`, { wait: false, }); + expect(open).toHaveBeenNthCalledWith( + 2, + `http://${host}:${port}/second.html`, + { + wait: false, + } + ); done(); }); @@ -438,15 +469,13 @@ describe('"open" option', () => { server.listen(port, host); }); - it("should work with object and with the boolean value of 'target' option", (done) => { + it('should work with empty object', (done) => { const host = 'localhost'; server = new Server( { host, port, - open: { - target: true, - }, + open: {}, }, compiler ); @@ -609,6 +638,34 @@ describe('"open" option', () => { server.listen(port, host); }); + it('should work with pattern in "target" and "app" options', (done) => { + const host = 'localhost'; + server = new Server( + { + host, + port, + open: { + target: '', + app: 'google-chrome', + }, + }, + compiler + ); + + compiler.hooks.done.tap('webpack-dev-server', () => { + server.close(() => { + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + app: { name: 'google-chrome' }, + wait: false, + }); + + done(); + }); + }); + + server.listen(port, host); + }); + it("should work with object, with multiple value of the 'target' option and with the 'app' and 'arguments' options", (done) => { const host = 'localhost'; server = new Server( @@ -689,6 +746,82 @@ describe('"open" option', () => { server.listen(port, host); }); + it('should work with pattern in multiple open options', (done) => { + const host = 'localhost'; + server = new Server( + { + host, + port, + open: [ + { + target: '', + app: 'google-chrome', + }, + { + target: '', + app: 'firefox', + }, + ], + }, + compiler + ); + + compiler.hooks.done.tap('webpack-dev-server', () => { + server.close(() => { + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + app: { name: 'google-chrome' }, + wait: false, + }); + + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + app: { name: 'firefox' }, + wait: false, + }); + + done(); + }); + }); + + server.listen(port, host); + }); + + it('should work with multiple open options without target', (done) => { + const host = 'localhost'; + server = new Server( + { + host, + port, + open: [ + { + app: 'google-chrome', + }, + { + app: 'firefox', + }, + ], + }, + compiler + ); + + compiler.hooks.done.tap('webpack-dev-server', () => { + server.close(() => { + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + app: { name: 'google-chrome' }, + wait: false, + }); + + expect(open).toHaveBeenCalledWith(`http://${host}:${port}/`, { + app: { name: 'firefox' }, + wait: false, + }); + + done(); + }); + }); + + server.listen(port, host); + }); + it("should log warning when can't open", (done) => { open.mockImplementation(() => Promise.reject()); diff --git a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack4 b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack4 index 87c7a25a32..0fd712f9ee 100644 --- a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack4 +++ b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack4 @@ -12,6 +12,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -48,6 +49,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -86,6 +88,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -124,6 +127,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -161,6 +165,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -198,6 +203,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -234,6 +240,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -270,6 +277,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -308,6 +316,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -346,6 +355,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -382,6 +392,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -419,6 +430,7 @@ Object { }, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -454,6 +466,7 @@ Object { "devMiddleware": Object {}, "hot": false, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -489,6 +502,7 @@ Object { "devMiddleware": Object {}, "hot": "only", "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -524,6 +538,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -559,6 +574,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": false, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -594,6 +610,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -629,6 +646,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -666,6 +684,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -701,6 +720,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "port": 9000, "setupExitSignals": true, "static": Array [ @@ -737,6 +757,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -774,6 +795,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -811,6 +833,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -848,6 +871,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -883,6 +907,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -929,6 +954,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -975,6 +1001,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1021,6 +1048,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1056,6 +1084,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": false, "webSocketServer": Object { @@ -1079,6 +1108,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1114,6 +1144,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1149,6 +1180,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1184,6 +1216,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1220,6 +1253,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1255,6 +1289,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1288,6 +1323,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1323,6 +1359,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1360,6 +1397,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1395,6 +1433,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1433,6 +1472,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1468,6 +1508,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1503,6 +1544,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { diff --git a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack5 b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack5 index 87c7a25a32..0fd712f9ee 100644 --- a/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack5 +++ b/test/server/utils/__snapshots__/normalizeOptions.test.js.snap.webpack5 @@ -12,6 +12,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -48,6 +49,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -86,6 +88,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -124,6 +127,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -161,6 +165,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -198,6 +203,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -234,6 +240,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -270,6 +277,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -308,6 +316,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -346,6 +355,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -382,6 +392,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -419,6 +430,7 @@ Object { }, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -454,6 +466,7 @@ Object { "devMiddleware": Object {}, "hot": false, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -489,6 +502,7 @@ Object { "devMiddleware": Object {}, "hot": "only", "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -524,6 +538,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -559,6 +574,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": false, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -594,6 +610,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -629,6 +646,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -666,6 +684,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -701,6 +720,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "port": 9000, "setupExitSignals": true, "static": Array [ @@ -737,6 +757,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -774,6 +795,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -811,6 +833,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -848,6 +871,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -883,6 +907,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -929,6 +954,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -975,6 +1001,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1021,6 +1048,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1056,6 +1084,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": false, "webSocketServer": Object { @@ -1079,6 +1108,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1114,6 +1144,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1149,6 +1180,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1184,6 +1216,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1220,6 +1253,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1255,6 +1289,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1288,6 +1323,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1323,6 +1359,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1360,6 +1397,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1395,6 +1433,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1433,6 +1472,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1468,6 +1508,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { @@ -1503,6 +1544,7 @@ Object { "devMiddleware": Object {}, "hot": true, "liveReload": true, + "open": Array [], "setupExitSignals": true, "static": Array [ Object { diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 7b50e0248e..d2e3159127 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -259,7 +259,10 @@ const tests = { 'foo', [], ['foo', 'bar'], - { target: true }, + [{ app: 'google-chrome' }], + [{ app: 'google-chrome' }, { app: 'firefox' }], + [{ target: 'foo', app: 'google-chrome' }, { app: 'firefox' }], + [{ target: ['foo', 'bar'], app: 'google-chrome' }, { app: 'firefox' }], { target: 'foo' }, { target: ['foo', 'bar'] }, { app: 'google-chrome' },