From af0c647a818c6d9a19836387fd0d7c73f3b03443 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Fri, 30 Apr 2021 02:34:18 +0530 Subject: [PATCH] test: watch option snapshot --- test/utils/test-utils.js | 13 +++ .../analyze-flag.test.js.snap.webpack4 | 9 ++ .../analyze-flag.test.js.snap.webpack5 | 9 ++ test/watch/analyze/analyze-flag.test.js | 6 +- .../__snapshots__/bail.test.js.snap.webpack4 | 89 +++++++++++++++++++ .../__snapshots__/bail.test.js.snap.webpack5 | 55 ++++++++++++ test/watch/bail/bail.test.js | 26 +++--- .../__snapshots__/basic.test.js.snap.webpack4 | 39 ++++++++ .../__snapshots__/basic.test.js.snap.webpack5 | 36 ++++++++ test/watch/basic/basic.test.js | 21 ++--- .../stats-and-watch.test.js.snap.webpack4 | 13 +++ .../stats-and-watch.test.js.snap.webpack5 | 17 ++++ test/watch/stats/stats-and-watch.test.js | 14 +-- 13 files changed, 311 insertions(+), 36 deletions(-) create mode 100644 test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack4 create mode 100644 test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack5 create mode 100644 test/watch/bail/__snapshots__/bail.test.js.snap.webpack4 create mode 100644 test/watch/bail/__snapshots__/bail.test.js.snap.webpack5 create mode 100644 test/watch/basic/__snapshots__/basic.test.js.snap.webpack4 create mode 100644 test/watch/basic/__snapshots__/basic.test.js.snap.webpack5 create mode 100644 test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack4 create mode 100644 test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack5 diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 65a9fce20b7..02a1c940478 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -247,6 +247,17 @@ const normalizeError = (output) => { return output.replace(/SyntaxError: .+/, 'SyntaxError: ').replace(/\s+at .+(}|\)|\d)/gs, '\n at stack'); }; +const normalizeCompileTime = (output) => { + return output.replace(/in \d+ ms/gm, 'in ms').replace(); +}; + +const normalizeV4Output = (output) => { + return output + .replace(/Hash: .*/gm, 'Hash: ') + .replace(/Time: .*/gm, 'Time: ') + .replace(/Built at: .*/gm, 'Built at: '); +}; + const normalizeStdout = (stdout) => { if (typeof stdout !== 'string') { return stdout; @@ -260,6 +271,8 @@ const normalizeStdout = (stdout) => { normalizedStdout = normalizeCwd(normalizedStdout); normalizedStdout = normalizeVersions(normalizedStdout); normalizedStdout = normalizeError(normalizedStdout); + normalizedStdout = normalizeCompileTime(normalizedStdout); + normalizedStdout = normalizeV4Output(normalizedStdout); return normalizedStdout; }; diff --git a/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack4 b/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack4 new file mode 100644 index 00000000000..58e6c254071 --- /dev/null +++ b/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack4 @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stderr 1`] = `""`; + +exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stdout 1`] = ` +"Webpack Bundle Analyzer is started + at stack +Use Ctrl+C to close it" +`; diff --git a/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack5 b/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack5 new file mode 100644 index 00000000000..58e6c254071 --- /dev/null +++ b/test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack5 @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stderr 1`] = `""`; + +exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stdout 1`] = ` +"Webpack Bundle Analyzer is started + at stack +Use Ctrl+C to close it" +`; diff --git a/test/watch/analyze/analyze-flag.test.js b/test/watch/analyze/analyze-flag.test.js index 25ef9e24825..f41d5c4d8f0 100644 --- a/test/watch/analyze/analyze-flag.test.js +++ b/test/watch/analyze/analyze-flag.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { runWatch } = require('../../utils/test-utils'); +const { runWatch, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); describe('"analyze" option', () => { it('should load webpack-bundle-analyzer plugin with --analyze flag', async () => { @@ -8,7 +8,7 @@ describe('"analyze" option', () => { killString: /Webpack Bundle Analyzer is started at/, }); - expect(stderr).toBeFalsy(); - expect(stdout).toContain('Webpack Bundle Analyzer is started at'); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); }); diff --git a/test/watch/bail/__snapshots__/bail.test.js.snap.webpack4 b/test/watch/bail/__snapshots__/bail.test.js.snap.webpack4 new file mode 100644 index 00000000000..5bc295f5527 --- /dev/null +++ b/test/watch/bail/__snapshots__/bail.test.js.snap.webpack4 @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"bail" option should log warning in case of multiple compilers: stderr 1`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in case of multiple compilers: stdout 1`] = ` +"Hash: +Version: webpack x.x.x +Child first: + Hash: + Time: + Built at: + Asset Size Chunks Chunk Names + ./dist-first.js 3.77 KiB main [emitted] main + Entrypoint main = ./dist-first.js + [./src/first.js] 50 bytes {main} [built] +Child second: + Hash: + Time: + Built at: + Asset Size Chunks Chunk Names + ./dist-second.js 3.77 KiB main [emitted] main + Entrypoint main = ./dist-second.js + [./src/second.js] 51 bytes {main} [built]" +`; + +exports[`"bail" option should log warning in watch mode: stderr 1`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in watch mode: stderr 2`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in watch mode: stdout 1`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 3.77 KiB main [emitted] main +Entrypoint main = main.js +[./src/first.js] 50 bytes {main} [built]" +`; + +exports[`"bail" option should log warning in watch mode: stdout 2`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 3.77 KiB main [emitted] main +Entrypoint main = main.js +[./src/first.js] 50 bytes {main} [built]" +`; + +exports[`"bail" option should not log warning in not watch mode without the "watch" option: stderr 1`] = `""`; + +exports[`"bail" option should not log warning in not watch mode without the "watch" option: stdout 1`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 3.77 KiB main [emitted] main +Entrypoint main = main.js +[./src/first.js] 50 bytes {main} [built]" +`; + +exports[`"bail" option should not log warning without the "bail" option: stderr 1`] = `""`; + +exports[`"bail" option should not log warning without the "bail" option: stderr 2`] = `""`; + +exports[`"bail" option should not log warning without the "bail" option: stdout 1`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 3.77 KiB main [emitted] main +Entrypoint main = main.js +[./src/first.js] 50 bytes {main} [built]" +`; + +exports[`"bail" option should not log warning without the "bail" option: stdout 2`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 3.77 KiB main [emitted] main +Entrypoint main = main.js +[./src/first.js] 50 bytes {main} [built]" +`; diff --git a/test/watch/bail/__snapshots__/bail.test.js.snap.webpack5 b/test/watch/bail/__snapshots__/bail.test.js.snap.webpack5 new file mode 100644 index 00000000000..1fd26a728da --- /dev/null +++ b/test/watch/bail/__snapshots__/bail.test.js.snap.webpack5 @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"bail" option should log warning in case of multiple compilers: stderr 1`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in case of multiple compilers: stdout 1`] = ` +"first: + asset ./dist-first.js 217 bytes [emitted] (name: main) + ./src/first.js 50 bytes [built] [code generated] + first (webpack x.x.x) compiled successfully in ms + +second: + asset ./dist-second.js 221 bytes [emitted] (name: main) + ./src/second.js 51 bytes [built] [code generated] + second (webpack x.x.x) compiled successfully in ms" +`; + +exports[`"bail" option should log warning in watch mode: stderr 1`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in watch mode: stderr 2`] = `" [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; + +exports[`"bail" option should log warning in watch mode: stdout 1`] = ` +"asset main.js 217 bytes [compared for emit] (name: main) +./src/first.js 50 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; + +exports[`"bail" option should log warning in watch mode: stdout 2`] = ` +"asset main.js 217 bytes [compared for emit] (name: main) +./src/first.js 50 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; + +exports[`"bail" option should not log warning in not watch mode without the "watch" option: stderr 1`] = `""`; + +exports[`"bail" option should not log warning in not watch mode without the "watch" option: stdout 1`] = ` +"asset main.js 217 bytes [emitted] (name: main) +./src/first.js 50 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; + +exports[`"bail" option should not log warning without the "bail" option: stderr 1`] = `""`; + +exports[`"bail" option should not log warning without the "bail" option: stderr 2`] = `""`; + +exports[`"bail" option should not log warning without the "bail" option: stdout 1`] = ` +"asset main.js 217 bytes [compared for emit] (name: main) +./src/first.js 50 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; + +exports[`"bail" option should not log warning without the "bail" option: stdout 2`] = ` +"asset main.js 217 bytes [compared for emit] (name: main) +./src/first.js 50 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; diff --git a/test/watch/bail/bail.test.js b/test/watch/bail/bail.test.js index 2d6bd82c1fb..dd2b915c620 100644 --- a/test/watch/bail/bail.test.js +++ b/test/watch/bail/bail.test.js @@ -1,47 +1,47 @@ 'use strict'; -const { runWatch } = require('../../utils/test-utils'); +const { runWatch, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); describe('"bail" option', () => { it('should not log warning in not watch mode without the "watch" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'watch-webpack.config.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should not log warning without the "bail" option', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']); - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']); - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should log warning in case of multiple compilers', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js']); - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); }); diff --git a/test/watch/basic/__snapshots__/basic.test.js.snap.webpack4 b/test/watch/basic/__snapshots__/basic.test.js.snap.webpack4 new file mode 100644 index 00000000000..65592723415 --- /dev/null +++ b/test/watch/basic/__snapshots__/basic.test.js.snap.webpack4 @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`basic should log supplied config with watch: stderr 1`] = ` +" [webpack-cli] Compiler starting... + [webpack-cli] Compiler is using config: '/test/watch/basic/log.config.js' + [webpack-cli] Compiler finished +" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stderr 1`] = ` +"[webpack-cli] Error: Unknown option '--no-watch' +[webpack-cli] Run 'webpack --help' to see available commands and options" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stdout 1`] = `""`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stderr 1`] = ` +"[webpack-cli] Error: Unknown option '--watch' +[webpack-cli] Run 'webpack --help' to see available commands and options" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stdout 1`] = `""`; + +exports[`basic should work with negative value: stderr 1`] = `""`; + +exports[`basic should work with negative value: stdout 1`] = ` +"Hash: +Version: webpack x.x.x +Time: +Built at: + Asset Size Chunks Chunk Names +main.js 960 bytes 0 [emitted] main +Entrypoint main = main.js +[0] ./src/index.js 32 bytes {0} [built] + +WARNING in configuration +The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. +You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/" +`; diff --git a/test/watch/basic/__snapshots__/basic.test.js.snap.webpack5 b/test/watch/basic/__snapshots__/basic.test.js.snap.webpack5 new file mode 100644 index 00000000000..7a48dc3ee9a --- /dev/null +++ b/test/watch/basic/__snapshots__/basic.test.js.snap.webpack5 @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`basic should log supplied config with watch: stderr 1`] = ` +" [webpack-cli] Compiler starting... + [webpack-cli] Compiler is using config: '/test/watch/basic/log.config.js' + [webpack-cli] Compiler finished +" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stderr 1`] = ` +"[webpack-cli] Error: Unknown option '--no-watch' +[webpack-cli] Run 'webpack --help' to see available commands and options" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stdout 1`] = `""`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stderr 1`] = ` +"[webpack-cli] Error: Unknown option '--watch' +[webpack-cli] Run 'webpack --help' to see available commands and options" +`; + +exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stdout 1`] = `""`; + +exports[`basic should work with negative value: stderr 1`] = `""`; + +exports[`basic should work with negative value: stdout 1`] = ` +"asset main.js 31 bytes [emitted] [minimized] (name: main) +./src/index.js 32 bytes [built] [code generated] + +WARNING in configuration +The 'mode' option has not been set, webpack will fallback to 'production' for this value. +Set 'mode' option to 'development' or 'production' to enable defaults for each environment. +You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/ + +webpack x.x.x compiled with 1 warning in ms" +`; diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index ed0fd817749..5a2e9bcc3e1 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { run, runAndGetProcess, isWebpack5, processKill } = require('../../utils/test-utils'); +const { run, runAndGetProcess, isWebpack5, processKill, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); const { writeFileSync } = require('fs'); const { resolve } = require('path'); @@ -12,8 +12,8 @@ describe('basic', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should recompile upon file change using the `--watch` option', (done) => { @@ -160,7 +160,6 @@ describe('basic', () => { it('should log supplied config with watch', (done) => { const proc = runAndGetProcess(__dirname, ['watch', '--config', 'log.config.js']); - const configPath = resolve(__dirname, './log.config.js'); let stderr = ''; @@ -170,9 +169,7 @@ describe('basic', () => { stderr += data; if (/Compiler finished/.test(data)) { - expect(stderr).toContain('Compiler starting...'); - expect(stderr).toContain(`Compiler is using config: '${configPath}'`); - expect(stderr).toContain('Compiler finished'); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); processKill(proc); done(); @@ -184,17 +181,15 @@ describe('basic', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['watch', '--watch', '--mode', 'development']); expect(exitCode).toBe(2); - expect(stderr).toContain("Error: Unknown option '--watch'"); - expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should recompile upon file change using the `command` option and the `--no-watch` option and log warning', async () => { const { exitCode, stderr, stdout } = await run(__dirname, ['watch', '--no-watch', '--mode', 'development']); expect(exitCode).toBe(2); - expect(stderr).toContain("Error: Unknown option '--no-watch'"); - expect(stderr).toContain("Run 'webpack --help' to see available commands and options"); - expect(stdout).toBeFalsy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); }); diff --git a/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack4 b/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack4 new file mode 100644 index 00000000000..a0dac6fb561 --- /dev/null +++ b/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack4 @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`stats and watch should log stats with the "normal" value in arguments: stderr 1`] = `""`; + +exports[`stats and watch should log stats with the "normal" value in arguments: stdout 1`] = `"webpack x.x.x"`; + +exports[`stats and watch should not log stats with the "none" value from the configuration and multi compiler mode: stderr 1`] = `""`; + +exports[`stats and watch should not log stats with the "none" value from the configuration and multi compiler mode: stdout 1`] = `"webpack x.x.x"`; + +exports[`stats and watch should not log stats with the "none" value from the configuration: stderr 1`] = `""`; + +exports[`stats and watch should not log stats with the "none" value from the configuration: stdout 1`] = `"webpack x.x.x"`; diff --git a/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack5 b/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack5 new file mode 100644 index 00000000000..46ba1626ed8 --- /dev/null +++ b/test/watch/stats/__snapshots__/stats-and-watch.test.js.snap.webpack5 @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`stats and watch should log stats with the "normal" value in arguments: stderr 1`] = `""`; + +exports[`stats and watch should log stats with the "normal" value in arguments: stdout 1`] = ` +"asset main.js 1.19 KiB [compared for emit] (name: main) +./src/index.js 20 bytes [built] [code generated] +webpack x.x.x compiled successfully in ms" +`; + +exports[`stats and watch should not log stats with the "none" value from the configuration and multi compiler mode: stderr 1`] = `""`; + +exports[`stats and watch should not log stats with the "none" value from the configuration and multi compiler mode: stdout 1`] = `"webpack x.x.x"`; + +exports[`stats and watch should not log stats with the "none" value from the configuration: stderr 1`] = `""`; + +exports[`stats and watch should not log stats with the "none" value from the configuration: stdout 1`] = `"webpack x.x.x"`; diff --git a/test/watch/stats/stats-and-watch.test.js b/test/watch/stats/stats-and-watch.test.js index 6b34d69ef6f..99065a816f9 100644 --- a/test/watch/stats/stats-and-watch.test.js +++ b/test/watch/stats/stats-and-watch.test.js @@ -1,26 +1,26 @@ 'use strict'; -const { runWatch } = require('../../utils/test-utils'); +const { runWatch, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); it('should log stats with the "normal" value in arguments', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal']); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); }); });