From 6e60f443029205d446178f13b3554fa0e1586fb8 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 29 May 2021 09:08:59 +0530 Subject: [PATCH] test: refactor --- bin/cli-flags.js | 40 ----- .../__snapshots__/cli.test.js.snap.webpack4 | 142 +++++++++++++++- .../__snapshots__/cli.test.js.snap.webpack5 | 142 +++++++++++++++- test/cli/cli.test.js | 158 +++++++----------- 4 files changed, 338 insertions(+), 144 deletions(-) diff --git a/bin/cli-flags.js b/bin/cli-flags.js index 66cbfd408e..befcf6ca38 100644 --- a/bin/cli-flags.js +++ b/bin/cli-flags.js @@ -359,46 +359,6 @@ module.exports = { simpleType: 'boolean', multiple: false, }, - firewall: { - configs: [ - { - type: 'boolean', - multiple: false, - description: - 'Defines routes which are enabled by default, on by default and allows localhost.', - path: 'firewall', - }, - { - type: 'string', - multiple: true, - description: - 'Defines routes which are enabled by default, on by default and allows localhost.', - path: 'firewall[]', - }, - ], - description: - 'Defines routes which are enabled by default, on by default and allows localhost.', - negatedDescription: 'Disable firewall.', - simpleType: 'string', - multiple: true, - }, - 'firewall-reset': { - configs: [ - { - type: 'reset', - multiple: false, - description: 'Clear all items provided in firewall configuration.', - path: 'firewall', - }, - ], - description: 'Clear all items provided in firewall configuration.', - simpleType: 'boolean', - multiple: false, - processor(opts) { - opts.firewall = opts.firewall || []; - delete opts.firewallReset; - }, - }, 'history-api-fallback': { configs: [ { diff --git a/test/cli/__snapshots__/cli.test.js.snap.webpack4 b/test/cli/__snapshots__/cli.test.js.snap.webpack4 index 6a21875c7e..9792ff33ee 100644 --- a/test/cli/__snapshots__/cli.test.js.snap.webpack4 +++ b/test/cli/__snapshots__/cli.test.js.snap.webpack4 @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`CLI --bonjour 1`] = ` +exports[`CLI bonjour option --bonjour 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -9,7 +9,7 @@ exports[`CLI --bonjour 1`] = ` [webpack-dev-server] Broadcasting \\"http\\" with subtype of \\"webpack\\" via ZeroConf DNS (Bonjour)" `; -exports[`CLI --bonjour and --https 1`] = ` +exports[`CLI bonjour option --bonjour and --https 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: https://localhost:/ [webpack-dev-server] On Your Network (IPv4): https://:/ @@ -18,7 +18,7 @@ exports[`CLI --bonjour and --https 1`] = ` [webpack-dev-server] Broadcasting \\"https\\" with subtype of \\"webpack\\" via ZeroConf DNS (Bonjour)" `; -exports[`CLI --no-bonjour 1`] = ` +exports[`CLI bonjour option --no-bonjour 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -286,3 +286,139 @@ Webpack documentation: https://webpack.js.org/. CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; + +exports[`CLI static option --no-static-serve-index: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --no-static-watch: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static' directory" +`; + +exports[`CLI static option --static --static-directory: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'static-dir' directory" +`; + +exports[`CLI static option --static: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-directory: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'static-dir' directory" +`; + +exports[`CLI static option --static-public-path: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-public-path-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-reset --static-directory : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static-directory' directory" +`; + +exports[`CLI static option --static-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static-after-reset' directory" +`; + +exports[`CLI static option --static-serve-index: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-watch: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-paths: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-paths-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-reset --watch-files-paths : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; diff --git a/test/cli/__snapshots__/cli.test.js.snap.webpack5 b/test/cli/__snapshots__/cli.test.js.snap.webpack5 index 4c01e192df..df2abbd7a0 100644 --- a/test/cli/__snapshots__/cli.test.js.snap.webpack5 +++ b/test/cli/__snapshots__/cli.test.js.snap.webpack5 @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`CLI --bonjour 1`] = ` +exports[`CLI bonjour option --bonjour 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -9,7 +9,7 @@ exports[`CLI --bonjour 1`] = ` [webpack-dev-server] Broadcasting \\"http\\" with subtype of \\"webpack\\" via ZeroConf DNS (Bonjour)" `; -exports[`CLI --bonjour and --https 1`] = ` +exports[`CLI bonjour option --bonjour and --https 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: https://localhost:/ [webpack-dev-server] On Your Network (IPv4): https://:/ @@ -18,7 +18,7 @@ exports[`CLI --bonjour and --https 1`] = ` [webpack-dev-server] Broadcasting \\"https\\" with subtype of \\"webpack\\" via ZeroConf DNS (Bonjour)" `; -exports[`CLI --no-bonjour 1`] = ` +exports[`CLI bonjour option --no-bonjour 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ [webpack-dev-server] On Your Network (IPv4): http://:/ @@ -286,3 +286,139 @@ Webpack documentation: https://webpack.js.org/. CLI documentation: https://webpack.js.org/api/cli/. Made with ♥ by the webpack team." `; + +exports[`CLI static option --no-static-serve-index: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --no-static-watch: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static' directory" +`; + +exports[`CLI static option --static --static-directory: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'static-dir' directory" +`; + +exports[`CLI static option --static: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-directory: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'static-dir' directory" +`; + +exports[`CLI static option --static-public-path: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-public-path-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-reset --static-directory : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static-directory' directory" +`; + +exports[`CLI static option --static-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from 'new-static-after-reset' directory" +`; + +exports[`CLI static option --static-serve-index: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI static option --static-watch: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-paths: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-paths-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-reset --watch-files-paths : stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; + +exports[`CLI watchFiles option --watch-files-reset: stderr 1`] = ` +" [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/public' directory" +`; diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index a2854bc228..805a180c1c 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -6,6 +6,7 @@ const internalIp = require('internal-ip'); const stripAnsi = require('strip-ansi'); const { testBin, normalizeStderr } = require('../helpers/test-bin'); +const isMacOS = process.platform === 'darwin'; const localIPv4 = internalIp.v4.sync(); const localIPv6 = internalIp.v6.sync(); @@ -93,44 +94,45 @@ describe('CLI', () => { }); }); - describe('bonjour option', () => {}); - it('--bonjour', (done) => { - testBin('--bonjour') - .then((output) => { - expect(output.exitCode).toEqual(0); - expect( - normalizeStderr(output.stderr, { ipv6: true }) - ).toMatchSnapshot(); + describe('bonjour option', () => { + it('--bonjour', (done) => { + testBin('--bonjour') + .then((output) => { + expect(output.exitCode).toEqual(0); + expect( + normalizeStderr(output.stderr, { ipv6: true }) + ).toMatchSnapshot(); - done(); - }) - .catch(done); - }); + done(); + }) + .catch(done); + }); - it('--bonjour and --https', (done) => { - testBin('--bonjour --https') - .then((output) => { - expect(output.exitCode).toEqual(0); - expect( - normalizeStderr(output.stderr, { ipv6: true, https: true }) - ).toMatchSnapshot(); + it('--bonjour and --https', (done) => { + testBin('--bonjour --https') + .then((output) => { + expect(output.exitCode).toEqual(0); + expect( + normalizeStderr(output.stderr, { ipv6: true, https: true }) + ).toMatchSnapshot(); - done(); - }) - .catch(done); - }); + done(); + }) + .catch(done); + }); - it('--no-bonjour', (done) => { - testBin('--no-bonjour') - .then((output) => { - expect(output.exitCode).toEqual(0); - expect( - normalizeStderr(output.stderr, { ipv6: true }) - ).toMatchSnapshot(); + it('--no-bonjour', (done) => { + testBin('--no-bonjour') + .then((output) => { + expect(output.exitCode).toEqual(0); + expect( + normalizeStderr(output.stderr, { ipv6: true }) + ).toMatchSnapshot(); - done(); - }) - .catch(done); + done(); + }) + .catch(done); + }); }); describe('client option', () => { @@ -889,19 +891,11 @@ describe('CLI', () => { }); }); - it('should generate correct cli flags', (done) => { - const isMacOS = process.platform === 'darwin'; - + (isMacOS ? it.skip : it)('should generate correct cli flags', (done) => { testBin('--help') .then((output) => { - // TODO: find a fix, skip for MacOS - if (isMacOS) { - expect(output.exitCode).toBe(0); - done(); - } else { - expect(stripAnsi(output.stdout)).toMatchSnapshot(); - done(); - } + expect(stripAnsi(output.stdout)).toMatchSnapshot(); + done(); }) .catch(done); }); @@ -911,76 +905,57 @@ describe('CLI', () => { testBin('--static') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); it('--static ', (done) => { - testBin( - `--static ${path.resolve( - __dirname, - '../fixtures/static/webpack.config.js' - )}` - ) + testBin('--static new-static') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); it('--static-reset', (done) => { - testBin( - `--static-reset --static ${path.resolve( - __dirname, - '../fixtures/static/webpack.config.js' - )}` - ) + testBin('--static-reset --static new-static-after-reset') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); it('--static-reset --static-directory ', (done) => { - testBin( - `--static-reset --static-directory ${path.resolve( - __dirname, - '../fixtures/static/webpack.config.js' - )}` - ) + testBin('--static-reset --static-directory new-static-directory') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); it('--static-directory', (done) => { - testBin( - `--static-directory ${path.resolve( - __dirname, - '../fixtures/static/webpack.config.js' - )}` - ) + testBin('--static-directory static-dir') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); it('--static --static-directory', (done) => { - testBin( - `--static --static-directory ${path.resolve( - __dirname, - '../fixtures/static/webpack.config.js' - )}` - ) + testBin('--static --static-directory static-dir') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -990,6 +965,7 @@ describe('CLI', () => { testBin('--static-public-path /public') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -999,6 +975,7 @@ describe('CLI', () => { testBin('--static-public-path-reset --static-public-path /new-public') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1008,6 +985,7 @@ describe('CLI', () => { testBin('--static-serve-index') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1017,6 +995,7 @@ describe('CLI', () => { testBin('--no-static-serve-index') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1026,6 +1005,7 @@ describe('CLI', () => { testBin('--static-watch') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1035,34 +1015,11 @@ describe('CLI', () => { testBin('--static-watch') .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); }); - - it('should log static', (done) => { - testBin( - '--no-color', - path.resolve(__dirname, '../fixtures/static/webpack.config.js') - ) - .then((output) => { - expect(output.exitCode).toEqual(0); - done(); - }) - .catch((err) => { - const staticDirectory = path.resolve( - __dirname, - '../fixtures/static/static' - ); - - // for windows - expect(err.stderr).toContain( - `Content not from webpack is served from '${staticDirectory}' directory` - ); - expect(err.stdout).toContain('main.js'); - done(); - }); - }); }); describe('watchFiles option', () => { @@ -1075,6 +1032,7 @@ describe('CLI', () => { testBin(`--watch-files ${watchDirectory}`) .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1089,6 +1047,7 @@ describe('CLI', () => { testBin(`--watch-files-reset --watch-files ${watchDirectory}`) .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1103,6 +1062,7 @@ describe('CLI', () => { testBin(`--watch-files-reset --watch-files-paths ${watchDirectory}`) .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1117,6 +1077,7 @@ describe('CLI', () => { testBin(`--watch-files-paths ${watchDirectory}`) .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done); @@ -1131,6 +1092,7 @@ describe('CLI', () => { testBin(`--watch-files-paths-reset --watch-files-paths ${watchDirectory}`) .then((output) => { expect(output.exitCode).toEqual(0); + expect(normalizeStderr(output.stderr)).toMatchSnapshot('stderr'); done(); }) .catch(done);