From 9b3cc283d7b74aa3bb26fe36c6110436b016e0d9 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 8 Dec 2020 16:41:41 +0300 Subject: [PATCH] fix: reduce spammy logs (#2206) --- .../webpack-cli/__tests__/serve/serve.test.js | 6 +- packages/webpack-cli/lib/plugins/CLIPlugin.js | 16 ++--- test/analyze/analyze-flag.test.js | 3 +- test/bail/bail.test.js | 39 ++--------- test/build-errors/errors.test.js | 9 +-- test/build-warnings/warnings.test.js | 9 +-- test/cache/cache.test.js | 44 ++++-------- test/colors/colors.test.js | 70 +++++++------------ test/config-format/coffee/coffee.test.js | 6 +- test/config-format/commonjs/commonjs.test.js | 3 +- test/config-format/mjs/mjs.test.js | 3 +- .../custom-name/custom-name.test.js | 3 +- .../dotfolder-array/dotfolder-array.test.js | 5 +- .../dotfolder-single/dotfolder-single.test.js | 3 +- .../relative/basic-config.test.js | 6 +- test/config-name/config-name.test.js | 32 ++------- test/config/absent/config-absent.test.js | 2 - test/config/basic/basic-config.test.js | 3 +- .../basic-config/default-js-config.test.js | 3 +- .../cjs-config/default-cjs-config.test.js | 3 +- .../multiple-location-config.test.js | 3 +- .../dev-none-config.test.js | 3 +- .../mjs-config/default-mjs-config.test.js | 3 +- .../with-mode/multiple-config.test.js | 3 +- test/config/empty-array/empty-array.test.js | 3 +- .../empty-function/empty-function.test.js | 3 +- .../empty-promise/empty-promise.test.js | 3 +- test/config/empty/empty.test.js | 3 +- .../config/function/functional-config.test.js | 8 +-- .../multiple-with-one-compilation.test.js | 3 +- test/config/multiple/multiple-config.test.js | 7 +- .../no-config-object/no-config-object.test.js | 3 +- .../function-with-argv.test.js | 6 +- .../array-function-with-env.test.js | 6 +- .../array-functions/array-functions.test.js | 5 +- .../array-promises/array-promises.test.js | 6 +- test/config/type/array/array.test.js | 10 +-- .../function-array/function-array.test.js | 6 +- .../function-async/function-async.test.js | 3 +- .../function-promise/function-promise.test.js | 3 +- .../function-with-argv.test.js | 3 +- .../function-with-env.test.js | 24 +++---- test/config/type/function/function.test.js | 3 +- .../type/promise-array/promise-array.test.js | 3 +- .../promise-function/promise-function.test.js | 3 +- test/config/type/promise/promise.test.js | 3 +- test/core-flags/amd-flag.test.js | 3 +- test/core-flags/bail-flag.test.js | 6 +- test/core-flags/cache-flags.test.js | 57 +++++---------- test/core-flags/context-flag.test.js | 6 +- test/core-flags/dependencies-flag.test.js | 6 +- test/core-flags/devtool-flag.test.js | 8 +-- test/core-flags/entry-reset-flag.test.js | 5 +- test/core-flags/experiments-flag.test.js | 6 +- test/core-flags/externals-flags.test.js | 18 ++--- .../core-flags/infrastructure-logging.test.js | 6 +- test/core-flags/module-flags.test.js | 21 ++---- test/core-flags/node-flags.test.js | 9 +-- test/core-flags/optimization-flags.test.js | 33 +++------ test/core-flags/output-flags.test.js | 60 ++++++---------- test/core-flags/parallelism-flag.test.js | 5 +- test/core-flags/performance-flags.test.js | 9 +-- test/core-flags/profile-flag.test.js | 6 +- test/core-flags/records-flag.test.js | 9 +-- test/core-flags/resolve-flags.test.js | 12 ++-- test/core-flags/snapshot-flags.test.js | 6 +- test/core-flags/stats-flags.test.js | 24 +++---- test/core-flags/watch-flags.test.js | 15 ++-- test/defaults/output-defaults.test.js | 6 +- test/devtool/array/source-map-array.test.js | 10 +-- test/devtool/object/source-map-object.test.js | 9 +-- .../entry-with-command.test.js | 3 +- .../entry-with-config.test.js | 3 +- .../entry-with-config.test.js | 3 +- .../defaults-empty/entry-single-arg.test.js | 3 +- .../defaults-index/entry-multi-args.test.js | 6 +- test/entry/flag-entry/entry-with-flag.test.js | 15 ++-- .../multiple-entries/multi-entries.test.js | 6 +- test/env/array/array-env.test.js | 3 +- test/env/object/object-env.test.js | 3 +- test/error/error.test.js | 2 - test/hot/hot-flag.test.js | 5 +- test/invalid-schema/invalid-schema.test.js | 4 -- test/merge/config/merge-config.test.js | 8 +-- .../mode-single-arg/mode-single-arg.test.js | 15 ++-- .../mode-with-config/mode-with-config.test.js | 27 +++---- test/name/name.test.js | 3 +- test/no-hot/no-hot.test.js | 7 +- .../with-config/no-stats-with-config.test.js | 6 +- test/no-stats/with-flags/no-stats.test.js | 7 +- test/node/node.test.js | 9 +-- test/optimization/optimization.test.js | 5 +- .../output-named-bundles.test.js | 12 ++-- test/prefetch/prefetch.test.js | 8 +-- test/progress/progress-flag.test.js | 8 --- test/serve/basic/serve-basic.test.js | 17 ++--- test/serve/serve-variable/serve-basic.test.js | 3 +- .../serve-custom-config.test.js | 12 ++-- test/stats/cli-flags/stats.test.js | 6 +- test/stats/config/stats.test.js | 6 +- test/stats/watch/multi-webpack.config.js | 22 ++++++ test/stats/watch/stats-and-watch.test.js | 26 +++---- test/stats/watch/webpack.config.js | 13 +++- test/target/flag-test/target-flag.test.js | 12 ++-- test/target/node/node-test.test.js | 3 +- test/utils/cli-plugin-test/plugin.test.js | 3 +- test/utils/test-utils.js | 9 +-- test/utils/test-utils.test.js | 12 ++-- .../version/version-external-packages.test.js | 20 +++--- test/version/version-multi-args.test.js | 16 ++--- test/version/version-single-arg.test.js | 6 +- test/watch/watch-flag.test.js | 9 +-- .../entry-absent/zero-config.test.js | 3 +- .../entry-present/zero-config.test.js | 3 +- 114 files changed, 375 insertions(+), 749 deletions(-) diff --git a/packages/webpack-cli/__tests__/serve/serve.test.js b/packages/webpack-cli/__tests__/serve/serve.test.js index 77df7668eb2..de1111b9820 100644 --- a/packages/webpack-cli/__tests__/serve/serve.test.js +++ b/packages/webpack-cli/__tests__/serve/serve.test.js @@ -14,8 +14,7 @@ describe('Serve', () => { it('should run with cli', async () => { const { stderr, stdout } = await runServe([], __dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -23,8 +22,7 @@ describe('Serve', () => { it('should work with flags', async () => { const { stderr, stdout } = await runServe(['--hot'], __dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); diff --git a/packages/webpack-cli/lib/plugins/CLIPlugin.js b/packages/webpack-cli/lib/plugins/CLIPlugin.js index a57a1d17846..643088643e5 100644 --- a/packages/webpack-cli/lib/plugins/CLIPlugin.js +++ b/packages/webpack-cli/lib/plugins/CLIPlugin.js @@ -42,10 +42,10 @@ class CLIPlugin { setupHelpfulOutput(compiler) { const pluginName = 'webpack-cli'; - const getCompilationName = (compilation) => (compilation.name ? ` '${compilation.name}'` : ''); + const getCompilationName = () => (compiler.name ? ` '${compiler.name}'` : ''); - compiler.hooks.run.tap(pluginName, (compiler) => { - this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); + compiler.hooks.run.tap(pluginName, () => { + this.logger.log(`Compilation${getCompilationName()} starting...`); }); compiler.hooks.watchRun.tap(pluginName, (compiler) => { @@ -55,22 +55,22 @@ class CLIPlugin { this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); } - this.logger.info(`Compilation${getCompilationName(compiler)} starting...`); + this.logger.log(`Compilation${getCompilationName()} starting...`); }); compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { const date = new Date(changeTime * 1000); - this.logger.info(`File '${filename}' was modified`); + this.logger.log(`File '${filename}' was modified`); this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`); }); - (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, (stats) => { - this.logger.info(`Compilation${getCompilationName(stats.compilation)} finished`); + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => { + this.logger.log(`Compilation${getCompilationName()} finished`); process.nextTick(() => { if (compiler.watchMode) { - this.logger.info(`Compiler${getCompilationName(stats.compilation)} is watching files for updates...`); + this.logger.log(`Compiler${getCompilationName()} is watching files for updates...`); } }); }); diff --git a/test/analyze/analyze-flag.test.js b/test/analyze/analyze-flag.test.js index 15274c16c6e..972a00223eb 100644 --- a/test/analyze/analyze-flag.test.js +++ b/test/analyze/analyze-flag.test.js @@ -22,8 +22,7 @@ describe('--analyze flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './analyze.config.js', '--analyze']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('Webpack Bundle Analyzer saved report to'); expect(stdout.match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(1); }); diff --git a/test/bail/bail.test.js b/test/bail/bail.test.js index bddea2f0136..51f0121fc40 100644 --- a/test/bail/bail.test.js +++ b/test/bail/bail.test.js @@ -7,9 +7,7 @@ describe('bail and watch warning', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'bail-webpack.config.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -17,44 +15,34 @@ describe('bail and watch warning', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); 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).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); 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).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); 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).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); @@ -62,26 +50,13 @@ describe('bail and watch warning', () => { it('should log warning in watch mode', async () => { const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); it('should log warning in case of multiple compilers', async () => { - const { stderr, stdout } = await runWatch( - __dirname, - ['-c', 'multi-webpack.config.js'], - true, - "Compiler 'second' is watching files for updates...", - ); - - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compiler 'first' is watching files for updates..."); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); - expect(stderr).toContain("Compiler 'second' is watching files for updates..."); + const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js'], true); + expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); expect(stdout).toBeTruthy(); }); diff --git a/test/build-errors/errors.test.js b/test/build-errors/errors.test.js index 8da5bc0b2cf..50a397ebffa 100644 --- a/test/build-errors/errors.test.js +++ b/test/build-errors/errors.test.js @@ -8,8 +8,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toMatch(/ERROR/); expect(stdout).toMatch(/Error: Can't resolve/); }); @@ -18,8 +17,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json']); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(() => JSON.parse(stdout)).not.toThrow(); const json = JSON.parse(stdout); @@ -34,8 +32,7 @@ describe('errors', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('stats are successfully stored as json to stats.json'); readFile(resolve(__dirname, 'stats.json'), 'utf-8', (error, data) => { diff --git a/test/build-warnings/warnings.test.js b/test/build-warnings/warnings.test.js index dd054091313..27422faf42e 100644 --- a/test/build-warnings/warnings.test.js +++ b/test/build-warnings/warnings.test.js @@ -8,8 +8,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toMatch(/WARNING/); expect(stdout).toMatch(/Error: Can't resolve/); }); @@ -18,8 +17,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json']); expect(exitCode).toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(() => JSON.parse(stdout)).not.toThrow(); @@ -35,8 +33,7 @@ describe('warnings', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--json', 'stats.json']); expect(exitCode).toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('stats are successfully stored as json to stats.json'); expect(existsSync(resolve(__dirname, './stats.json'))).toBeTruthy(); diff --git a/test/cache/cache.test.js b/test/cache/cache.test.js index dae6085dc3a..f0898708ce1 100644 --- a/test/cache/cache.test.js +++ b/test/cache/cache.test.js @@ -13,10 +13,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-default' starting..."); - expect(stderr).toContain("Compilation 'cache-test-default' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -25,29 +24,27 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-default' starting..."); - expect(stderr).toContain("Compilation 'cache-test-default' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); it('should work in multi compiler mode', () => { - rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-{first,second}-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-first-development')); + rimraf.sync(path.join(__dirname, '../../node_modules/.cache/webpack/cache-test-second-development')); let { exitCode, stderr, stdout } = run(__dirname, ['-c', './multi.config.js'], false); expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-first' starting..."); - expect(stderr).toContain("Compilation 'cache-test-first' finished"); - expect(stderr).toContain("Compilation 'cache-test-second' starting..."); - expect(stderr).toContain("Compilation 'cache-test-second' finished"); + console.log(stderr); expect(stderr.match(/No pack exists at/g)).toHaveLength(2); expect(stderr.match(/Stored pack/g)).toHaveLength(2); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -56,13 +53,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-first' starting..."); - expect(stderr).toContain("Compilation 'cache-test-first' finished"); - expect(stderr).toContain("Compilation 'cache-test-second' starting..."); - expect(stderr).toContain("Compilation 'cache-test-second' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(2); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(2); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(2); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -79,10 +73,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-third' starting..."); - expect(stderr).toContain("Compilation 'cache-test-third' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -95,11 +88,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-third' starting..."); - expect(stderr).toContain("Compilation 'cache-test-third' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -116,10 +108,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -132,11 +123,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fourth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fourth' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -165,10 +155,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -193,11 +182,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-fifth' starting..."); - expect(stderr).toContain("Compilation 'cache-test-fifth' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); @@ -210,10 +198,9 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); - expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); expect(stderr.match(/No pack exists at/g)).toHaveLength(1); expect(stderr.match(/Stored pack/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } @@ -222,11 +209,10 @@ describe('cache', () => { expect(exitCode).toEqual(0); if (isWebpack5) { - expect(stderr).toContain("Compilation 'cache-test-autoloading' starting..."); - expect(stderr).toContain("Compilation 'cache-test-autoloading' finished"); expect(stderr.match(/restore cache container:/g)).toHaveLength(1); expect(stderr.match(/restore cache content metadata:/g)).toHaveLength(1); expect(stderr.match(/restore cache content \d+ \(.+\):/g)).toHaveLength(1); + expect(stderr).toBeTruthy(); expect(stdout).toBeTruthy(); } }); diff --git a/test/colors/colors.test.js b/test/colors/colors.test.js index 2add37e2178..31f3d7e88c9 100644 --- a/test/colors/colors.test.js +++ b/test/colors/colors.test.js @@ -7,21 +7,19 @@ describe('colors related tests', () => { it('should output by default', () => { const { exitCode, stderr, stdout } = run(__dirname, [], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration', () => { @@ -33,11 +31,10 @@ describe('colors related tests', () => { { FORCE_COLOR: true }, ); - expect(stderr).toContain("Compilation 'test' starting..."); - expect(stderr).toContain("Compilation 'test' finished"); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from flags and from configuration #2', () => { @@ -45,114 +42,101 @@ describe('colors related tests', () => { FORCE_COLOR: true, }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should disable colored output with --no-color', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--no-color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option and --color flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats=verbose', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-string.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #1', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=stats-boolean.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #2', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=no-stats.webpack.config.js'], true, [], { FORCE_COLOR: true }); - expect(stderr).toContain("Compilation 'test' starting..."); - expect(stderr).toContain("Compilation 'test' finished"); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #3', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(coloretteOptions.enabled ? `\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m` : output); - expect(exitCode).toBe(0); }); it('should work with the "stats" option from the configuration #4', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should prioritize --color over colors in config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-false.webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); - expect(exitCode).toBe(0); }); it('should prioratize --no-color over colors in config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=colors-true.webpack.config.js', '--no-color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); const output = isWebpack5 ? 'successfully' : 'main.js'; expect(stdout).not.toContain(`\u001b[1m\u001b[32m${output}\u001b[39m\u001b[22m`); expect(stdout).toContain(output); - expect(exitCode).toBe(0); }); it('should work in multicompiler mode', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config=multiple-configs.js', '--color']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first-config' starting..."); - expect(stderr).toContain("Compilation 'first-config' finished"); - expect(stderr).toContain("Compilation 'second-config' starting..."); - expect(stderr).toContain("Compilation 'second-config' finished"); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`\u001b[1mfirst-config`); diff --git a/test/config-format/coffee/coffee.test.js b/test/config-format/coffee/coffee.test.js index e0ab6310dfc..ac853526f7d 100644 --- a/test/config-format/coffee/coffee.test.js +++ b/test/config-format/coffee/coffee.test.js @@ -6,8 +6,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.coffee'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -15,8 +14,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/commonjs/commonjs.test.js b/test/config-format/commonjs/commonjs.test.js index 73a9232f94a..b31d62a3655 100644 --- a/test/config-format/commonjs/commonjs.test.js +++ b/test/config-format/commonjs/commonjs.test.js @@ -5,8 +5,7 @@ describe('webpack cli', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.cjs'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-format/mjs/mjs.test.js b/test/config-format/mjs/mjs.test.js index 20b6c4764f0..5da18d95c16 100644 --- a/test/config-format/mjs/mjs.test.js +++ b/test/config-format/mjs/mjs.test.js @@ -6,8 +6,7 @@ describe('webpack cli', () => { if (exitCode === 0) { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); } else { expect(exitCode).toBe(2); diff --git a/test/config-lookup/custom-name/custom-name.test.js b/test/config-lookup/custom-name/custom-name.test.js index 06e57a4bdf7..aa9bcd1c439 100644 --- a/test/config-lookup/custom-name/custom-name.test.js +++ b/test/config-lookup/custom-name/custom-name.test.js @@ -8,8 +8,7 @@ describe('custom config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'config.webpack.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-lookup/dotfolder-array/dotfolder-array.test.js b/test/config-lookup/dotfolder-array/dotfolder-array.test.js index 3e139c59eee..db296a2a46d 100644 --- a/test/config-lookup/dotfolder-array/dotfolder-array.test.js +++ b/test/config-lookup/dotfolder-array/dotfolder-array.test.js @@ -8,10 +8,7 @@ describe('dotfolder array config lookup', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); diff --git a/test/config-lookup/dotfolder-single/dotfolder-single.test.js b/test/config-lookup/dotfolder-single/dotfolder-single.test.js index 49287f1a2c4..4ab02015988 100644 --- a/test/config-lookup/dotfolder-single/dotfolder-single.test.js +++ b/test/config-lookup/dotfolder-single/dotfolder-single.test.js @@ -10,8 +10,7 @@ describe('dotfolder single config lookup', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('Module not found'); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); diff --git a/test/config-lookup/relative/basic-config.test.js b/test/config-lookup/relative/basic-config.test.js index 723a904373f..1d4655bc236 100644 --- a/test/config-lookup/relative/basic-config.test.js +++ b/test/config-lookup/relative/basic-config.test.js @@ -7,8 +7,7 @@ describe('relative path to config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config.js', '--output-path', './binary/a'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -16,8 +15,7 @@ describe('relative path to config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js', '--output-path', './binary/b'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config-name/config-name.test.js b/test/config-name/config-name.test.js index 26d7a2324e0..607eb97fa08 100644 --- a/test/config-name/config-name.test.js +++ b/test/config-name/config-name.test.js @@ -7,8 +7,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -18,10 +17,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'third' starting..."); - expect(stderr).toContain("Compilation 'third' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); @@ -35,10 +31,7 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'four' starting..."); - expect(stderr).toContain("Compilation 'four' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -49,8 +42,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -59,8 +50,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config-name', 'test', '-c', 'single-config.js'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); @@ -73,8 +62,6 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); @@ -88,9 +75,6 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); - expect(stderr).not.toContain('Configuration with the name "first" was not found.'); expect(stderr).toContain('Configuration with the name "bar" was not found.'); expect(stdout).toBeFalsy(); }); @@ -99,8 +83,7 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'first'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).not.toContain('third'); @@ -114,10 +97,7 @@ describe('--config-name flag', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'third' starting..."); - expect(stderr).toContain("Compilation 'third' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).not.toContain('second'); expect(stdout).toContain('third'); @@ -127,8 +107,6 @@ describe('--config-name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', 'function-config.js', '--config-name', 'test'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Configuration with the name "test" was not found.'); expect(stdout).toBeFalsy(); }); diff --git a/test/config/absent/config-absent.test.js b/test/config/absent/config-absent.test.js index 7cfbe24a490..2a10305273c 100644 --- a/test/config/absent/config-absent.test.js +++ b/test/config/absent/config-absent.test.js @@ -10,8 +10,6 @@ describe('Config:', () => { // should throw with correct exit code expect(exitCode).toBe(2); // Should contain the correct error message - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`The specified config file doesn't exist in '${resolve(__dirname, 'webpack.config.js')}'`); expect(stdout).toBeFalsy(); }); diff --git a/test/config/basic/basic-config.test.js b/test/config/basic/basic-config.test.js index fa061bbdbb3..2661f445e02 100644 --- a/test/config/basic/basic-config.test.js +++ b/test/config/basic/basic-config.test.js @@ -11,8 +11,7 @@ describe('basic config file', () => { false, ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/defaults/basic-config/default-js-config.test.js b/test/config/defaults/basic-config/default-js-config.test.js index 95e875c044b..ca1d5ab4fc0 100644 --- a/test/config/defaults/basic-config/default-js-config.test.js +++ b/test/config/defaults/basic-config/default-js-config.test.js @@ -7,8 +7,7 @@ describe('Zero Config', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); diff --git a/test/config/defaults/cjs-config/default-cjs-config.test.js b/test/config/defaults/cjs-config/default-cjs-config.test.js index 6e52b89d3ab..cacc8166a21 100644 --- a/test/config/defaults/cjs-config/default-cjs-config.test.js +++ b/test/config/defaults/cjs-config/default-cjs-config.test.js @@ -7,8 +7,7 @@ describe('Default Config:', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config diff --git a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js index c1e586dac7d..b851b223453 100644 --- a/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js +++ b/test/config/defaults/dot-webpack-directory-webpackfile/multiple-location-config.test.js @@ -7,8 +7,7 @@ describe('multiple dev config files with webpack.config.js', () => { it('Uses webpack.config.development.js', () => { const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.folder.js'))).toBeTruthy(); }); diff --git a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js index 34ff1498b2c..a085b31e6ea 100644 --- a/test/config/defaults/dot-webpack-directory/dev-none-config.test.js +++ b/test/config/defaults/dot-webpack-directory/dev-none-config.test.js @@ -7,8 +7,7 @@ describe('multiple config files', () => { it('Uses dev config when both dev and none are present', () => { const { stdout, stderr, exitCode } = run(__dirname, [], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); diff --git a/test/config/defaults/mjs-config/default-mjs-config.test.js b/test/config/defaults/mjs-config/default-mjs-config.test.js index 2c920c0e492..434de374fd8 100644 --- a/test/config/defaults/mjs-config/default-mjs-config.test.js +++ b/test/config/defaults/mjs-config/default-mjs-config.test.js @@ -8,8 +8,7 @@ describe('Default Config:', () => { if (exitCode === 0) { expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // default entry should be used expect(stdout).toContain('./src/index.js'); // should pick up the output path from config diff --git a/test/config/defaults/with-mode/multiple-config.test.js b/test/config/defaults/with-mode/multiple-config.test.js index 1515eb64dcc..163779cf95b 100644 --- a/test/config/defaults/with-mode/multiple-config.test.js +++ b/test/config/defaults/with-mode/multiple-config.test.js @@ -7,8 +7,7 @@ describe('multiple config files', () => { it('Uses dev config when development mode is supplied', () => { const { stdout, stderr, exitCode } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toBe(undefined); expect(existsSync(resolve(__dirname, './binary/dev.bundle.js'))).toBeTruthy(); }); diff --git a/test/config/empty-array/empty-array.test.js b/test/config/empty-array/empty-array.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-array/empty-array.test.js +++ b/test/config/empty-array/empty-array.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-function/empty-function.test.js b/test/config/empty-function/empty-function.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-function/empty-function.test.js +++ b/test/config/empty-function/empty-function.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty-promise/empty-promise.test.js b/test/config/empty-promise/empty-promise.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty-promise/empty-promise.test.js +++ b/test/config/empty-promise/empty-promise.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/empty/empty.test.js b/test/config/empty/empty.test.js index a466a1c108b..ec2f20716c2 100644 --- a/test/config/empty/empty.test.js +++ b/test/config/empty/empty.test.js @@ -7,8 +7,7 @@ describe('config flag with empty config file', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/function/functional-config.test.js b/test/config/function/functional-config.test.js index c135ef86845..3f8f2eabc11 100644 --- a/test/config/function/functional-config.test.js +++ b/test/config/function/functional-config.test.js @@ -9,8 +9,7 @@ describe('functional config', () => { const { stderr, stdout, exitCode } = run(__dirname, ['--config', resolve(__dirname, 'single-webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'single' starting..."); - expect(stderr).toContain("Compilation 'single' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./src/index.js'); expect(existsSync(resolve(__dirname, './bin/dist-single.js'))).toBeTruthy(); }); @@ -19,10 +18,7 @@ describe('functional config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', resolve(__dirname, 'multi-webpack.config.js')]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('first'); expect(stdout).toContain('second'); expect(existsSync(resolve(__dirname, './bin/dist-first.js'))).toBeTruthy(); diff --git a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js index fa061bbdbb3..2661f445e02 100644 --- a/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js +++ b/test/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js @@ -11,8 +11,7 @@ describe('basic config file', () => { false, ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/multiple/multiple-config.test.js b/test/config/multiple/multiple-config.test.js index 097a99d9b48..3daf66584a9 100644 --- a/test/config/multiple/multiple-config.test.js +++ b/test/config/multiple/multiple-config.test.js @@ -6,12 +6,7 @@ describe('Multiple config flag: ', () => { // Should contain the correct exit code expect(exitCode).toEqual(0); - - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - + expect(stderr).toBeFalsy(); // Should spawn multiple compilers expect(stdout).toContain('amd:'); expect(stdout).toContain('commonjs:'); diff --git a/test/config/no-config-object/no-config-object.test.js b/test/config/no-config-object/no-config-object.test.js index ba6cdfd4ab3..6e27769c970 100644 --- a/test/config/no-config-object/no-config-object.test.js +++ b/test/config/no-config-object/no-config-object.test.js @@ -12,8 +12,7 @@ describe('empty config', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/config/type/array-function-with-argv/function-with-argv.test.js b/test/config/type/array-function-with-argv/function-with-argv.test.js index 9a65b47e4cb..8599e533bce 100644 --- a/test/config/type/array-function-with-argv/function-with-argv.test.js +++ b/test/config/type/array-function-with-argv/function-with-argv.test.js @@ -8,12 +8,8 @@ describe('array of function with args', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); diff --git a/test/config/type/array-function-with-env/array-function-with-env.test.js b/test/config/type/array-function-with-env/array-function-with-env.test.js index a90d258a55f..33dcd38aee2 100644 --- a/test/config/type/array-function-with-env/array-function-with-env.test.js +++ b/test/config/type/array-function-with-env/array-function-with-env.test.js @@ -8,12 +8,8 @@ describe('array of functions with env', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './dist/a-dev.js'))); expect(existsSync(resolve(__dirname, './dist/b-dev.js'))); }); diff --git a/test/config/type/array-functions/array-functions.test.js b/test/config/type/array-functions/array-functions.test.js index 9223d92fff1..6f9bf1f5d7a 100644 --- a/test/config/type/array-functions/array-functions.test.js +++ b/test/config/type/array-functions/array-functions.test.js @@ -8,10 +8,7 @@ describe('array of functions', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); diff --git a/test/config/type/array-promises/array-promises.test.js b/test/config/type/array-promises/array-promises.test.js index e618726d3e9..7fbd9bdf0e6 100644 --- a/test/config/type/array-promises/array-promises.test.js +++ b/test/config/type/array-promises/array-promises.test.js @@ -8,12 +8,8 @@ describe('array of promises', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-promise.js'))).toBeTruthy(); }); diff --git a/test/config/type/array/array.test.js b/test/config/type/array/array.test.js index 5cb2267e933..0634759ff9a 100644 --- a/test/config/type/array/array.test.js +++ b/test/config/type/array/array.test.js @@ -8,10 +8,7 @@ describe('array config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/dist-amd.js'))).toBeTruthy(); @@ -21,10 +18,7 @@ describe('array config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'none'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); + expect(stderr).toBeFalsy(); // should not print anything because of stats: none expect(stdout).toBeFalsy(); expect(existsSync(resolve(__dirname, './dist/dist-commonjs.js'))).toBeTruthy(); diff --git a/test/config/type/function-array/function-array.test.js b/test/config/type/function-array/function-array.test.js index a081360b620..66a1fa260eb 100644 --- a/test/config/type/function-array/function-array.test.js +++ b/test/config/type/function-array/function-array.test.js @@ -8,12 +8,8 @@ describe('function array', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'first' starting..."); - expect(stderr).toContain("Compilation 'first' finished"); - expect(stderr).toContain("Compilation 'second' starting..."); - expect(stderr).toContain("Compilation 'second' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './binary/a-functor.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/b-functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-async/function-async.test.js b/test/config/type/function-async/function-async.test.js index 86a1766a3df..1bd458b19e8 100644 --- a/test/config/type/function-async/function-async.test.js +++ b/test/config/type/function-async/function-async.test.js @@ -8,8 +8,7 @@ describe('function async', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-promise/function-promise.test.js b/test/config/type/function-promise/function-promise.test.js index 074f276933c..243589bf329 100644 --- a/test/config/type/function-promise/function-promise.test.js +++ b/test/config/type/function-promise/function-promise.test.js @@ -8,8 +8,7 @@ describe('function promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/function-with-argv/function-with-argv.test.js b/test/config/type/function-with-argv/function-with-argv.test.js index c75e62c1a78..0c5d24e749a 100644 --- a/test/config/type/function-with-argv/function-with-argv.test.js +++ b/test/config/type/function-with-argv/function-with-argv.test.js @@ -8,8 +8,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).toContain("argv: { mode: 'development' }"); expect(existsSync(resolve(__dirname, './dist/dev.js'))); diff --git a/test/config/type/function-with-env/function-with-env.test.js b/test/config/type/function-with-env/function-with-env.test.js index 1fb719b1b05..359df2f24a1 100644 --- a/test/config/type/function-with-env/function-with-env.test.js +++ b/test/config/type/function-with-env/function-with-env.test.js @@ -17,8 +17,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isProd']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/prod.js'))).toBeTruthy(); @@ -28,8 +27,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/dev.js'))).toBeTruthy(); @@ -46,8 +44,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Luffy.js'))).toBeTruthy(); @@ -64,8 +61,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Atsumu.js'))).toBeTruthy(); @@ -82,8 +78,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/name=is=Eren.js'))).toBeTruthy(); @@ -100,8 +95,7 @@ describe('function configuration', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/Hisoka.js'))).toBeTruthy(); @@ -111,8 +105,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'name.', '--env', 'environment=dot', '-c', 'webpack.env.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files expect(existsSync(resolve(__dirname, './bin/true.js'))).toBeTruthy(); @@ -122,8 +115,7 @@ describe('function configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--env', 'isDev', '--env', 'verboseStats', '--env', 'envMessage']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // check that the verbose env is respected expect(stdout).toContain('LOG from webpack'); diff --git a/test/config/type/function/function.test.js b/test/config/type/function/function.test.js index 6f90a6cd065..a850fd16eab 100644 --- a/test/config/type/function/function.test.js +++ b/test/config/type/function/function.test.js @@ -8,8 +8,7 @@ describe('function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/functor.js'))).toBeTruthy(); }); diff --git a/test/config/type/promise-array/promise-array.test.js b/test/config/type/promise-array/promise-array.test.js index 0d38f7b6682..89c1b4a905e 100644 --- a/test/config/type/promise-array/promise-array.test.js +++ b/test/config/type/promise-array/promise-array.test.js @@ -9,8 +9,7 @@ describe('promise array', () => { expect(exitCode).toBe(0); expect(stdout).toBeTruthy(); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/a-promise.js'))).toBeTruthy(); }); diff --git a/test/config/type/promise-function/promise-function.test.js b/test/config/type/promise-function/promise-function.test.js index 9f662f2d6f8..bd93e6d3162 100644 --- a/test/config/type/promise-function/promise-function.test.js +++ b/test/config/type/promise-function/promise-function.test.js @@ -8,8 +8,7 @@ describe('promise function', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); diff --git a/test/config/type/promise/promise.test.js b/test/config/type/promise/promise.test.js index 34e93c57f26..0284dc243bc 100644 --- a/test/config/type/promise/promise.test.js +++ b/test/config/type/promise/promise.test.js @@ -8,8 +8,7 @@ describe('promise', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/promise.js'))).toBeTruthy(); }); diff --git a/test/core-flags/amd-flag.test.js b/test/core-flags/amd-flag.test.js index 2cac616a060..48acfe5aad4 100644 --- a/test/core-flags/amd-flag.test.js +++ b/test/core-flags/amd-flag.test.js @@ -7,8 +7,7 @@ describe('--no-amd flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-amd']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('amd: false'); }); }); diff --git a/test/core-flags/bail-flag.test.js b/test/core-flags/bail-flag.test.js index 27a38f18a3d..dd3a5920ded 100644 --- a/test/core-flags/bail-flag.test.js +++ b/test/core-flags/bail-flag.test.js @@ -7,8 +7,7 @@ describe('--bail flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--bail']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: true'); }); @@ -16,8 +15,7 @@ describe('--bail flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-bail']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('bail: false'); }); }); diff --git a/test/core-flags/cache-flags.test.js b/test/core-flags/cache-flags.test.js index d2eb845fbee..a7e6c54d64f 100644 --- a/test/core-flags/cache-flags.test.js +++ b/test/core-flags/cache-flags.test.js @@ -11,8 +11,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'memory'`); }); @@ -20,8 +19,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-cache']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('cache: false'); }); @@ -33,8 +31,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`type: 'filesystem'`); }); @@ -53,8 +50,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('test-cache-path'); }); @@ -67,8 +63,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('cache-core-flag-test-cache-location'); expect(existsSync(cacheLocation)).toBeTruthy(); @@ -89,8 +84,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`hashAlgorithm: 'sha256'`); }); @@ -110,8 +104,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`name: 'cli-test'`); }); @@ -131,8 +124,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`store: 'pack'`); }); @@ -152,8 +144,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain(`version: '1.1.3'`); }); @@ -173,8 +164,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); @@ -191,8 +181,7 @@ describe('cache related flags from core', () => { ])); expect(exitCode).toEqual(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); }); @@ -207,8 +196,7 @@ describe('cache related flags from core', () => { let { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler-cache' starting..."); - expect(stderr).toContain("Compilation 'compiler-cache' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); @@ -217,8 +205,7 @@ describe('cache related flags from core', () => { ({ exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '--cache-cache-location', cacheLocation])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler-cache' starting..."); - expect(stderr).toContain("Compilation 'compiler-cache' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); }); @@ -228,8 +215,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.cache.config.js', '-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${resolve(__dirname, 'webpack.cache.config.js')}'`); @@ -242,8 +228,7 @@ describe('cache related flags from core', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '--name', 'cache-core-flag-test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'cache-core-flag-test' starting..."); - expect(stderr).toContain("Compilation 'cache-core-flag-test' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.config.js')}'`); expect(stdout).toContain("type: 'filesystem'"); @@ -265,8 +250,7 @@ describe('cache related flags from core', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("type: 'filesystem'"); expect(stdout).toContain('buildDependencies'); // expect(stdout).toContain(`'${path.join(__dirname, './webpack.cache.config.js')}'`); @@ -283,16 +267,14 @@ describe('cache related flags from core', () => { let { exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('[cached]'); // Running again should use the cache ({ exitCode, stderr, stdout } = run(__dirname, ['--cache-type', 'filesystem', '-c', './webpack.test.config.js'])); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('[cached]'); // Change config to invalidate cache @@ -303,8 +285,7 @@ describe('cache related flags from core', () => { unlinkSync(resolve(__dirname, './webpack.test.config.js')); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain('[cached]'); }); }); diff --git a/test/core-flags/context-flag.test.js b/test/core-flags/context-flag.test.js index 804bc6cd3d7..bac4667b0f9 100644 --- a/test/core-flags/context-flag.test.js +++ b/test/core-flags/context-flag.test.js @@ -8,8 +8,7 @@ describe('--context flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--context', './']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (isWindows) { const windowsPath = resolve(__dirname, './').replace(/\\/g, '\\\\'); @@ -23,8 +22,7 @@ describe('--context flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--context', '/invalid-context-path']); expect(exitCode).toBe(1); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`Module not found: Error: Can't resolve './src/main.js'`); }); }); diff --git a/test/core-flags/dependencies-flag.test.js b/test/core-flags/dependencies-flag.test.js index 1cc0ff6536b..035e460f45e 100644 --- a/test/core-flags/dependencies-flag.test.js +++ b/test/core-flags/dependencies-flag.test.js @@ -7,8 +7,7 @@ describe('--dependencies and related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies', 'lodash']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`dependencies: [ 'lodash' ]`); }); @@ -16,8 +15,7 @@ describe('--dependencies and related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--dependencies-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('dependencies: []'); }); }); diff --git a/test/core-flags/devtool-flag.test.js b/test/core-flags/devtool-flag.test.js index 269396b21a2..fa37bc37b43 100644 --- a/test/core-flags/devtool-flag.test.js +++ b/test/core-flags/devtool-flag.test.js @@ -7,8 +7,7 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`devtool: 'source-map'`); }); @@ -16,8 +15,7 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-devtool']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`devtool: false`); }); @@ -25,8 +23,6 @@ describe('--devtool flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'invalid']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/entry-reset-flag.test.js b/test/core-flags/entry-reset-flag.test.js index 660c40bf39e..91e7bfec4cc 100644 --- a/test/core-flags/entry-reset-flag.test.js +++ b/test/core-flags/entry-reset-flag.test.js @@ -7,8 +7,7 @@ describe('--entry-reset flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset', '--entry', './src/entry.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('src/entry.js'); expect(stdout).not.toContain('src/main.js'); }); @@ -17,8 +16,6 @@ describe('--entry-reset flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry-reset']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/experiments-flag.test.js b/test/core-flags/experiments-flag.test.js index 741463cfedb..07704d3c825 100644 --- a/test/core-flags/experiments-flag.test.js +++ b/test/core-flags/experiments-flag.test.js @@ -15,8 +15,7 @@ describe('experiments option related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); }); @@ -24,8 +23,7 @@ describe('experiments option related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/externals-flags.test.js b/test/core-flags/externals-flags.test.js index dd0afaaf86a..f402a194691 100644 --- a/test/core-flags/externals-flags.test.js +++ b/test/core-flags/externals-flags.test.js @@ -10,8 +10,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals', './main.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externals: [ './main.js' ]`); }); @@ -19,8 +18,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals', 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externalsType: 'var'`); }); @@ -28,8 +26,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals-type', 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externalsType: 'var'`); }); @@ -37,8 +34,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--externals-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`externals: []`); }); @@ -51,8 +47,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); }); @@ -60,8 +55,7 @@ describe('externals related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); }); diff --git a/test/core-flags/infrastructure-logging.test.js b/test/core-flags/infrastructure-logging.test.js index f04966f215b..9e408f2d46b 100644 --- a/test/core-flags/infrastructure-logging.test.js +++ b/test/core-flags/infrastructure-logging.test.js @@ -7,8 +7,7 @@ describe('infrastructure logging related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`debug: [ 'myPlugin' ]`); }); @@ -16,8 +15,7 @@ describe('infrastructure logging related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`debug: []`); }); diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index b02f3aade81..22510b4849b 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -22,22 +22,19 @@ describe('module config related flag', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); const option = propName.split('Reset')[0]; - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${option}: []`); } else if (flag.name.includes('rules-')) { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("sideEffects: 'flag'"); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -47,8 +44,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('rules-')) { expect(stdout).toContain('sideEffects: false'); @@ -65,15 +61,13 @@ describe('module config related flag', () => { if (flag.name === 'module-no-parse') { expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('value'); } else if (flag.name.includes('reg-exp')) { ({ stdout, stderr, exitCode } = run(__dirname, [`--${flag.name}`, '/ab?c*/'])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: /ab?c*/`); } else if (flag.name.includes('module-rules-')) { ({ stdout } = run(__dirname, [`--${flag.name}`, 'javascript/auto'])); @@ -92,9 +86,8 @@ describe('module config related flag', () => { } } else { expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'value'`); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); } }); } diff --git a/test/core-flags/node-flags.test.js b/test/core-flags/node-flags.test.js index 437f0c1d778..b3d24a4198f 100644 --- a/test/core-flags/node-flags.test.js +++ b/test/core-flags/node-flags.test.js @@ -7,8 +7,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('node: false'); }); @@ -16,8 +15,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--node-filename', 'mock']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`__filename: 'mock'`); }); @@ -25,8 +23,7 @@ describe('node option related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--node-dirname', 'mock']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`__dirname: 'mock'`); }); }); diff --git a/test/core-flags/optimization-flags.test.js b/test/core-flags/optimization-flags.test.js index 6e579f40129..72cd235c357 100644 --- a/test/core-flags/optimization-flags.test.js +++ b/test/core-flags/optimization-flags.test.js @@ -26,22 +26,19 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`splitChunks: false`); } else if (flag.name.includes('reset')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: []`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -51,8 +48,7 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain('splitChunks: false'); @@ -71,43 +67,37 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'initial']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`chunks: 'initial'`); } else if (flag.name === 'optimization-mangle-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-mangle-exports', 'size']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mangleExports: 'size'`); } else if (flag.name === 'optimization-used-exports') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-used-exports', 'global']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`usedExports: 'global'`); } else if (flag.name === 'optimization-split-chunks-default-size-types') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-split-chunks-default-size-types', 'global']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`defaultSizeTypes: [Array]`); } else if (flag.name === 'optimization-side-effects') { const { exitCode, stderr, stdout } = run(__dirname, ['--optimization-side-effects', 'flag']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'flag'`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'named']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'named'`); } }); @@ -118,8 +108,7 @@ describe('optimization config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name === 'optimization-split-chunks') { expect(stdout).toContain(`chunks: 'async'`); diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index ab6e9067667..fb08268a5a1 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -25,20 +25,17 @@ describe('output config related flag', () => { ({ exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '--experiments-output-module'])); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('module: true'); } else if (flag.name.includes('-reset')) { const option = propName.split('Reset')[0]; expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${option}: []`); } else { expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: true`); } }); @@ -48,8 +45,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); }); } @@ -60,8 +56,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 10`); }); } @@ -72,92 +67,79 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'anonymous']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'anonymous'`); } else if (flag.name === 'output-chunk-format') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'commonjs']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'commonjs'`); } else if (flag.name === 'output-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'jsonp']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'jsonp'`); } else if (flag.name === 'output-enabled-chunk-loading-types' || flag.name === 'output-enabled-wasm-loading-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'async-node' ]`); } else if (flag.name === 'output-enabled-library-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'amd']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'amd'`); } else if (flag.name === 'output-hash-function') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'sha256']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`hashFunction: 'sha256'`); } else if (flag.name === 'output-script-type') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'module']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'module'`); } else if (flag.name === 'output-enabled-library-types') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'var']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: [ 'var' ]`); } else if (flag.name === 'output-path') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('test'); } else if (flag.name === 'output-pathinfo') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'verbose']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`pathinfo: 'verbose'`); } else if (flag.name === 'output-worker-chunk-loading') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else if (flag.name.includes('wasm')) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'async-node'`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'test'`); } }); @@ -178,8 +160,7 @@ describe('output config related flag', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('myLibrary'); expect(stdout).toContain(`type: 'var'`); expect(stdout).toContain('export: [Array]'); @@ -191,8 +172,7 @@ describe('output config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-library-reset']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('name: []'); }); } diff --git a/test/core-flags/parallelism-flag.test.js b/test/core-flags/parallelism-flag.test.js index 1bf2f1462db..95902729986 100644 --- a/test/core-flags/parallelism-flag.test.js +++ b/test/core-flags/parallelism-flag.test.js @@ -7,8 +7,7 @@ describe('--parallelism flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '50']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('parallelism: 50'); }); @@ -16,8 +15,6 @@ describe('--parallelism flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--parallelism', '0']); expect(exitCode).toBe(2); - expect(stderr).not.toContain("Compilation 'compiler' starting..."); - expect(stderr).not.toContain("Compilation 'compiler' finished"); expect(stderr).toContain('configuration.parallelism should be >= 1'); expect(stdout).toBeFalsy(); }); diff --git a/test/core-flags/performance-flags.test.js b/test/core-flags/performance-flags.test.js index bfaf42b2c4d..f13d1ca0221 100644 --- a/test/core-flags/performance-flags.test.js +++ b/test/core-flags/performance-flags.test.js @@ -10,8 +10,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-performance`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('performance: false'); }); @@ -25,8 +24,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 10`); }); } @@ -36,8 +34,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'warning']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: 'warning'`); }); } diff --git a/test/core-flags/profile-flag.test.js b/test/core-flags/profile-flag.test.js index 5c702ae77d9..a4806015904 100644 --- a/test/core-flags/profile-flag.test.js +++ b/test/core-flags/profile-flag.test.js @@ -7,8 +7,7 @@ describe('--profile flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--profile']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('profile: true'); }); @@ -16,8 +15,7 @@ describe('--profile flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-profile']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('profile: false'); }); }); diff --git a/test/core-flags/records-flag.test.js b/test/core-flags/records-flag.test.js index 831c0d97142..1b3ba08787a 100644 --- a/test/core-flags/records-flag.test.js +++ b/test/core-flags/records-flag.test.js @@ -7,8 +7,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); @@ -16,8 +15,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-input-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); @@ -25,8 +23,7 @@ describe('module config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--records-output-path', './bin/records.json']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('records.json'); }); }); diff --git a/test/core-flags/resolve-flags.test.js b/test/core-flags/resolve-flags.test.js index 719a94e9dbe..e2c069ff02c 100644 --- a/test/core-flags/resolve-flags.test.js +++ b/test/core-flags/resolve-flags.test.js @@ -21,8 +21,7 @@ describe('resolve config related flags', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`]); // expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -38,8 +37,7 @@ describe('resolve config related flags', () => { const { stderr, stdout } = run(__dirname, [`--${flag.name}`, 'browser']); // expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (propName === 'restrictions') { expect(stdout).toContain('browser'); @@ -75,8 +73,7 @@ describe('resolve config related flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`alias: [ { alias: 'alias', name: 'name' } ]`); expect(stdout).toContain(`aliasFields: [ 'aliasField' ]`); expect(stdout).toContain(`alias: [ { alias: 'loaderAlias', name: 'loaderName' } ]`); @@ -99,8 +96,7 @@ describe('resolve config related flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`alias: []`); expect(stdout).toContain(`aliasFields: []`); expect(stdout).toContain(`fallback: []`); diff --git a/test/core-flags/snapshot-flags.test.js b/test/core-flags/snapshot-flags.test.js index 15005dd57b8..5860127cb3b 100644 --- a/test/core-flags/snapshot-flags.test.js +++ b/test/core-flags/snapshot-flags.test.js @@ -16,8 +16,7 @@ describe('snapshot config related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -35,8 +34,7 @@ describe('snapshot config related flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'test-snap-path']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('test-snap-path'); }); } diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index 39f57c7faf8..904e5f774da 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -16,8 +16,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { const option = propName.split('Reset')[0]; @@ -32,8 +31,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: false }`); }); } @@ -44,8 +42,7 @@ describe('stats config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 10 }`); }); } @@ -59,36 +56,31 @@ describe('stats config related flag', () => { const option = flag.name.split('stats-colors-')[1]; expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { colors: { ${option}: 'u001b[32m' } }`); } else if (acceptsSingleValue.includes(propName)) { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 'log' }`); } else if (flag.name === 'stats-context') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain('log'); } else if (flag.name === 'stats-entrypoints') { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'auto']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: 'auto' }`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'log']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: [ 'log' ] }`); } }); diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index e1263020b8c..b0f9e8f2892 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -16,8 +16,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); if (flag.name.includes('reset')) { expect(stdout).toContain(`watchOptions: { ignored: [] }`); @@ -31,8 +30,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: false }`); }); } @@ -43,8 +41,7 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '10']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: 10 }`); }); } @@ -55,15 +52,13 @@ describe('watch config related flag', () => { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, '200']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: 200 }`); } else { const { exitCode, stderr, stdout } = run(__dirname, [`--${flag.name}`, 'ignore.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'compiler' starting..."); - expect(stderr).toContain("Compilation 'compiler' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: [ 'ignore.js' ] }`); } }); diff --git a/test/defaults/output-defaults.test.js b/test/defaults/output-defaults.test.js index c727226adf5..555ca1204b4 100644 --- a/test/defaults/output-defaults.test.js +++ b/test/defaults/output-defaults.test.js @@ -8,8 +8,7 @@ describe('output flag defaults', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js', '--output-path', './binary'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should print warning about config fallback expect(stdout).toContain('option has not been set, webpack will fallback to'); @@ -20,8 +19,7 @@ describe('output flag defaults', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './a.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './binary/main.js'))).toBeTruthy(); }); diff --git a/test/devtool/array/source-map-array.test.js b/test/devtool/array/source-map-array.test.js index ae9bbabfe41..d6e1624ec47 100644 --- a/test/devtool/array/source-map-array.test.js +++ b/test/devtool/array/source-map-array.test.js @@ -8,10 +8,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'dist'), (err, files) => { @@ -24,10 +21,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--devtool', 'source-map', '--output-path', './binary'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'commonjs' starting..."); - expect(stderr).toContain("Compilation 'commonjs' finished"); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'binary'), (err, files) => { diff --git a/test/devtool/object/source-map-object.test.js b/test/devtool/object/source-map-object.test.js index 8a13e79aa61..4237b08d520 100644 --- a/test/devtool/object/source-map-object.test.js +++ b/test/devtool/object/source-map-object.test.js @@ -8,8 +8,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.eval.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); readdir(resolve(__dirname, 'bin'), (err, files) => { @@ -23,8 +22,7 @@ describe('source-map object', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.source.config.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, 'dist/dist-amd.js.map'))).toBeTruthy(); }); @@ -37,8 +35,7 @@ describe('source-map object', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'amd' starting..."); - expect(stderr).toContain("Compilation 'amd' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, 'binary/dist-amd.js.map'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-command/entry-with-command.test.js b/test/entry/config-entry/entry-with-command/entry-with-command.test.js index ac8bc9505ef..2cd0595f3f9 100644 --- a/test/entry/config-entry/entry-with-command/entry-with-command.test.js +++ b/test/entry/config-entry/entry-with-command/entry-with-command.test.js @@ -8,8 +8,7 @@ describe('config entry and command entry all exist', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js', './index.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./index.js'); expect(existsSync(resolve(__dirname, './binary/main.bundle.js'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-config/entry-with-config.test.js b/test/entry/config-entry/entry-with-config/entry-with-config.test.js index 69dba9616fa..5906cf5919f 100644 --- a/test/entry/config-entry/entry-with-config/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-config/entry-with-config.test.js @@ -8,8 +8,7 @@ describe('default entry and config entry all exist', () => { const { stdout, stderr, exitCode } = run(__dirname, ['-c', '../1.js'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('./a.js'); expect(existsSync(resolve(__dirname, './binary/index.bundle.js'))).toBeTruthy(); }); diff --git a/test/entry/config-entry/entry-with-index/entry-with-config.test.js b/test/entry/config-entry/entry-with-index/entry-with-config.test.js index 18fe3c879fb..5c998e1a621 100644 --- a/test/entry/config-entry/entry-with-index/entry-with-config.test.js +++ b/test/entry/config-entry/entry-with-index/entry-with-config.test.js @@ -7,8 +7,7 @@ describe('default entry and config entry all exist', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should contain the relevant entry expect(stdout).toContain('./src/app.js'); expect(stdout).toContain('./src/print.js'); diff --git a/test/entry/defaults-empty/entry-single-arg.test.js b/test/entry/defaults-empty/entry-single-arg.test.js index 6218698926d..d6274bf2e8f 100644 --- a/test/entry/defaults-empty/entry-single-arg.test.js +++ b/test/entry/defaults-empty/entry-single-arg.test.js @@ -7,8 +7,7 @@ describe('single entry flag empty project', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`not found: Error: Can't resolve`); }); }); diff --git a/test/entry/defaults-index/entry-multi-args.test.js b/test/entry/defaults-index/entry-multi-args.test.js index a91113d40ba..dbacb46d325 100644 --- a/test/entry/defaults-index/entry-multi-args.test.js +++ b/test/entry/defaults-index/entry-multi-args.test.js @@ -10,8 +10,7 @@ describe('single entry flag index present', () => { const { stderr, stdout, exitCode } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stderr).not.toContain('Module not found'); expect(stdout).toBeTruthy(); }); @@ -20,8 +19,7 @@ describe('single entry flag index present', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--output-path', 'bin']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); }); diff --git a/test/entry/flag-entry/entry-with-flag.test.js b/test/entry/flag-entry/entry-with-flag.test.js index fc2072a901f..22d0ff09f95 100644 --- a/test/entry/flag-entry/entry-with-flag.test.js +++ b/test/entry/flag-entry/entry-with-flag.test.js @@ -9,8 +9,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/index.cjs', '-o', './dist/'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -18,8 +17,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -28,14 +26,12 @@ describe('entry flag', () => { if (!isWebpack5) { expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`Module not found: Error: Can't resolve`); done(); } else { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './dist/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { @@ -50,8 +46,7 @@ describe('entry flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/test.js']); expect(exitCode).toEqual(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain("Module not found: Error: Can't resolve"); }); }); diff --git a/test/entry/multiple-entries/multi-entries.test.js b/test/entry/multiple-entries/multi-entries.test.js index d9b5598cbd4..339a21786bc 100644 --- a/test/entry/multiple-entries/multi-entries.test.js +++ b/test/entry/multiple-entries/multi-entries.test.js @@ -9,8 +9,7 @@ describe(' multiple entries', () => { const { exitCode, stderr, stdout } = run(__dirname, ['./src/a.js', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { @@ -25,8 +24,7 @@ describe(' multiple entries', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--entry', './src/a.js', '--entry', './src/b.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); diff --git a/test/env/array/array-env.test.js b/test/env/array/array-env.test.js index caf8f7054b9..83e75c74fb6 100644 --- a/test/env/array/array-env.test.js +++ b/test/env/array/array-env.test.js @@ -14,8 +14,7 @@ describe('env array', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/env/object/object-env.test.js b/test/env/object/object-env.test.js index 91b889f461e..d886da0eaf8 100644 --- a/test/env/object/object-env.test.js +++ b/test/env/object/object-env.test.js @@ -11,8 +11,7 @@ describe('env object', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); if (isWebpack5) { diff --git a/test/error/error.test.js b/test/error/error.test.js index de227ce0ec6..5096f198b1a 100644 --- a/test/error/error.test.js +++ b/test/error/error.test.js @@ -7,8 +7,6 @@ describe('error', () => { const { exitCode, stderr, stdout } = await run(__dirname); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: test'); expect(stderr).toMatch(/at .+ (.+)/); expect(stdout).toBeFalsy(); diff --git a/test/hot/hot-flag.test.js b/test/hot/hot-flag.test.js index 9ee1764d6fb..361c1dfe9ab 100644 --- a/test/hot/hot-flag.test.js +++ b/test/hot/hot-flag.test.js @@ -8,8 +8,7 @@ describe('--hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(readFileSync(resolve(__dirname, './bin/main.js')).toString()).toContain('webpackHotUpdate'); }); @@ -18,8 +17,6 @@ describe('--hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot', '--hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); diff --git a/test/invalid-schema/invalid-schema.test.js b/test/invalid-schema/invalid-schema.test.js index e5e42f06b77..52cd44bebde 100644 --- a/test/invalid-schema/invalid-schema.test.js +++ b/test/invalid-schema/invalid-schema.test.js @@ -6,8 +6,6 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']); expect(exitCode).toEqual(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Invalid configuration object'); expect(stdout).toBeFalsy(); }); @@ -16,8 +14,6 @@ describe('invalid schema', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']); expect(exitCode).toEqual(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); if (isWebpack5) { expect(stderr).toContain("Found the 'invalid-value' problem with the '--mode' argument by path 'mode'"); diff --git a/test/merge/config/merge-config.test.js b/test/merge/config/merge-config.test.js index ffbdb19a795..916eb44c750 100644 --- a/test/merge/config/merge-config.test.js +++ b/test/merge/config/merge-config.test.js @@ -7,8 +7,7 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '--merge'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('option has not been set, webpack will fallback to'); }); @@ -16,8 +15,7 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '--config', './2.js', '-m'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('merged.js'); }); @@ -25,8 +23,6 @@ describe('merge flag configuration', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--config', './1.js', '-m'], false); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('At least two configurations are required for merge.'); expect(stdout).toBeFalsy(); }); diff --git a/test/mode/mode-single-arg/mode-single-arg.test.js b/test/mode/mode-single-arg/mode-single-arg.test.js index 90e4abb7e02..74a768bdd11 100644 --- a/test/mode/mode-single-arg/mode-single-arg.test.js +++ b/test/mode/mode-single-arg/mode-single-arg.test.js @@ -7,8 +7,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(`mode: 'production'`); expect(stdout).toContain(`The 'mode' option has not been set, webpack will fallback to 'production' for this value.`); }); @@ -17,8 +16,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); @@ -26,8 +24,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); @@ -35,8 +32,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); }); @@ -44,8 +40,7 @@ describe('mode flags', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false, [], { NODE_ENV: 'development' }); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); diff --git a/test/mode/mode-with-config/mode-with-config.test.js b/test/mode/mode-with-config/mode-with-config.test.js index f3cb00f3ed9..c158d1b4d61 100644 --- a/test/mode/mode-with-config/mode-with-config.test.js +++ b/test/mode/mode-with-config/mode-with-config.test.js @@ -9,8 +9,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -29,8 +28,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'development', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -50,8 +48,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '--config', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); // Should generate the appropriate files @@ -72,8 +69,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'production', '-c', 'webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); }); @@ -83,8 +79,7 @@ describe('mode flags with config', () => { }); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); }); @@ -92,8 +87,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); }); @@ -101,8 +95,7 @@ describe('mode flags with config', () => { const { exitCode, stdout, stderr } = run(__dirname, ['-c', 'webpack.config3.js', '-c', 'webpack.config2.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'development'", 'g')).length).toEqual(1); }); @@ -111,8 +104,7 @@ describe('mode flags with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'none', '-c', './webpack.config3.js', '-c', './webpack.config2.js']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'none'`); expect(stdout.match(new RegExp("mode: 'none'", 'g')).length).toEqual(2); }); @@ -123,8 +115,7 @@ describe('mode flags with config', () => { }); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`mode: 'production'`); expect(stdout).toContain(`mode: 'development'`); expect(stdout.match(new RegExp("mode: 'production'", 'g')).length).toEqual(1); diff --git a/test/name/name.test.js b/test/name/name.test.js index f05dab56270..a40682f66c8 100644 --- a/test/name/name.test.js +++ b/test/name/name.test.js @@ -6,8 +6,7 @@ describe('name flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--name', 'config-name'], false); expect(exitCode).toBe(0); - expect(stderr).toContain("Compilation 'config-name' starting..."); - expect(stderr).toContain("Compilation 'config-name' finished"); + expect(stderr).toBeFalsy(); expect(stdout).toContain("name: 'config-name'"); }); }); diff --git a/test/no-hot/no-hot.test.js b/test/no-hot/no-hot.test.js index a381d52e9bd..91b268603be 100644 --- a/test/no-hot/no-hot.test.js +++ b/test/no-hot/no-hot.test.js @@ -9,11 +9,11 @@ describe('no-hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); expect(stdout).not.toContain('webpack/runtime/hot module replacement'); expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); + readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { expect(err).toBe(null); // check for absence of special functions invoked by HMR plugin only @@ -26,13 +26,10 @@ describe('no-hot flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--hot', '--no-hot']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain( 'You provided both --hot and --no-hot. We will use only the last of these flags that you provided in your CLI arguments', ); expect(stdout).toBeTruthy(); - expect(existsSync(resolve(__dirname, './bin/main.js'))).toBeTruthy(); readFile(resolve(__dirname, './bin/main.js'), 'utf-8', (err, data) => { diff --git a/test/no-stats/with-config/no-stats-with-config.test.js b/test/no-stats/with-config/no-stats-with-config.test.js index 46a49569c46..1c4ab3da1a0 100644 --- a/test/no-stats/with-config/no-stats-with-config.test.js +++ b/test/no-stats/with-config/no-stats-with-config.test.js @@ -8,8 +8,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'detailed' }`); @@ -22,8 +21,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); diff --git a/test/no-stats/with-flags/no-stats.test.js b/test/no-stats/with-flags/no-stats.test.js index 679461326af..20e9ffcb820 100644 --- a/test/no-stats/with-flags/no-stats.test.js +++ b/test/no-stats/with-flags/no-stats.test.js @@ -8,8 +8,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'none' }`); @@ -22,8 +21,6 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); if (version.startsWith('5')) { @@ -37,8 +34,6 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`); if (version.startsWith('5')) { diff --git a/test/node/node.test.js b/test/node/node.test.js index d98ae225b3f..79c143d1e2e 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -13,8 +13,7 @@ describe('node flags', () => { ]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('---from bootstrap.js---'); expect(stdout).toContain('---from bootstrap2.js---'); }); @@ -23,8 +22,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--unknown']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('bad option'); expect(stdout).toBeFalsy(); }); @@ -33,8 +30,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], false, ['--max-old-space-size']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('value for flag --max-old-space-size'); expect(stdout).toBeFalsy(); }); @@ -43,8 +38,6 @@ describe('node flags', () => { const { exitCode, stderr, stdout } = await run(__dirname, [], true, ['--max_old_space_size=1024a']); expect(exitCode).not.toBe(0); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain('Error: illegal value for flag --max_old_space_size=1024a of type size_t'); expect(stdout).toBeFalsy(); }); diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js index f30060e850e..ea28769da3a 100644 --- a/test/optimization/optimization.test.js +++ b/test/optimization/optimization.test.js @@ -7,13 +7,10 @@ describe('optimization option in config', () => { // Should throw when webpack is less than 5 if (isWebpack5) { expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('mangleExports: false'); } else { expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); expect(stdout).toBeFalsy(); } diff --git a/test/output/named-bundles/output-named-bundles.test.js b/test/output/named-bundles/output-named-bundles.test.js index ecb694c74a3..a6a5aed9e93 100644 --- a/test/output/named-bundles/output-named-bundles.test.js +++ b/test/output/named-bundles/output-named-bundles.test.js @@ -12,8 +12,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -25,8 +24,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -38,8 +36,7 @@ describe('output flag named bundles', () => { ); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -47,8 +44,7 @@ describe('output flag named bundles', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', resolve(__dirname, 'webpack.multiple.config.js')], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); diff --git a/test/prefetch/prefetch.test.js b/test/prefetch/prefetch.test.js index 30def73ad77..95ece6bd8e8 100644 --- a/test/prefetch/prefetch.test.js +++ b/test/prefetch/prefetch.test.js @@ -12,8 +12,7 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/p.js', '--mode', 'development'], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); const content = fs.readFileSync(join(__dirname, '/dist/main.js'), 'utf-8'); @@ -25,8 +24,7 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch', './src/somefile.js'], false); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should contain the error message expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); }); @@ -35,8 +33,6 @@ describe('prefetch', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--prefetch'], false); expect(exitCode).toBe(1); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`error: option '--prefetch ' argument missing`); expect(stdout).toBeFalsy(); }); diff --git a/test/progress/progress-flag.test.js b/test/progress/progress-flag.test.js index 6a5a8d1dd39..d3dd1a7c9cd 100644 --- a/test/progress/progress-flag.test.js +++ b/test/progress/progress-flag.test.js @@ -7,8 +7,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); @@ -18,8 +16,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress=profile']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); if (isWebpack5) { expect(stderr).toMatch(/\[webpack\.Progress] \d+ ms setup/); @@ -33,8 +29,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--progress=unknown']); expect(exitCode).toBe(2); - expect(stderr).not.toContain('Compilation starting...'); - expect(stderr).not.toContain('Compilation finished'); expect(stderr).toContain(`'unknown' is an invalid value for the --progress option. Only 'profile' is allowed.`); expect(stdout).toBeFalsy(); }); @@ -43,8 +37,6 @@ describe('progress flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', 'webpack.progress.config.js', '--progress']); expect(exitCode).toEqual(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); expect(stderr).not.toMatch(/\[webpack\.Progress] \d+ ms setup/); expect(stderr).toContain('[webpack.Progress] 100%'); expect(stdout).toContain('main.js'); diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 64c112648f4..64f8f2f07c8 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -37,8 +37,7 @@ describe('basic serve usage', () => { it('should not invoke info subcommand', async () => { const { stdout, stderr } = await runServe(['--client-log-level', 'info'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -46,8 +45,7 @@ describe('basic serve usage', () => { it('compiles without flags', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -55,8 +53,7 @@ describe('basic serve usage', () => { it('uses hot flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); @@ -64,8 +61,7 @@ describe('basic serve usage', () => { it('uses hot-only flag to alter bundle', async () => { const { stdout, stderr } = await runServe(['--port', port, isDevServer4 ? '--hot only' : '--hot-only'], testPath); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); @@ -73,9 +69,8 @@ describe('basic serve usage', () => { it('uses no-hot flag', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); }); @@ -83,8 +78,6 @@ describe('basic serve usage', () => { const { stdout, stderr } = await runServe(['--port', port, '--hot', '--progress'], testPath); expect(stderr).toContain('webpack.Progress'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compilation starting...'); expect(stdout).toContain('main.js'); expect(stdout).toContain('HotModuleReplacementPlugin'); }); diff --git a/test/serve/serve-variable/serve-basic.test.js b/test/serve/serve-variable/serve-basic.test.js index 7bab5984b4d..ee4b3b93c62 100644 --- a/test/serve/serve-variable/serve-basic.test.js +++ b/test/serve/serve-variable/serve-basic.test.js @@ -26,8 +26,7 @@ describe('serve variable', () => { it('compiles without flags and export variable', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); expect(stdout).toContain('PASS'); diff --git a/test/serve/with-custom-port/serve-custom-config.test.js b/test/serve/with-custom-port/serve-custom-config.test.js index bac94e4accf..4903e7ea7eb 100644 --- a/test/serve/with-custom-port/serve-custom-config.test.js +++ b/test/serve/with-custom-port/serve-custom-config.test.js @@ -26,8 +26,7 @@ describe('serve with devServer in config', () => { it('Should pick up the host and port from config', async () => { const { stdout, stderr } = await runServe([], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); @@ -38,8 +37,7 @@ describe('serve with devServer in config', () => { it('Port flag should override the config port', async () => { const { stdout, stderr } = await runServe(['--port', port], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); expect(stdout).not.toContain('HotModuleReplacementPlugin'); @@ -50,8 +48,7 @@ describe('serve with devServer in config', () => { it('Passing hot flag works alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--hot'], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is being used @@ -63,8 +60,7 @@ describe('serve with devServer in config', () => { it('works fine when no-hot flag is passed alongside other server config', async () => { const { stdout, stderr } = await runServe(['--port', port, '--no-hot'], testPath); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should output the correct bundle file expect(stdout).toContain('main.js'); // HMR is not being used diff --git a/test/stats/cli-flags/stats.test.js b/test/stats/cli-flags/stats.test.js index 21e5a4566ff..71c1fcb495a 100644 --- a/test/stats/cli-flags/stats.test.js +++ b/test/stats/cli-flags/stats.test.js @@ -15,8 +15,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); @@ -30,8 +29,7 @@ describe('stats flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: 'normal' }`); diff --git a/test/stats/config/stats.test.js b/test/stats/config/stats.test.js index 2eeb66671c7..6d4510b5224 100644 --- a/test/stats/config/stats.test.js +++ b/test/stats/config/stats.test.js @@ -16,8 +16,7 @@ describe('stats flag with config', () => { const { exitCode, stderr, stdout } = run(__dirname, []); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (version.startsWith('5')) { expect(stdout).toContain(`stats: { preset: 'normal' }`); @@ -31,8 +30,7 @@ describe('stats flag with config', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--stats', `${preset}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`stats: { preset: '${preset}' }`); diff --git a/test/stats/watch/multi-webpack.config.js b/test/stats/watch/multi-webpack.config.js index 7d116eda8b8..f2c12cc6680 100644 --- a/test/stats/watch/multi-webpack.config.js +++ b/test/stats/watch/multi-webpack.config.js @@ -1,10 +1,32 @@ +const webpack = require('webpack'); + module.exports = [ { + name: 'first', watch: true, stats: 'none', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }, { + name: 'two', watch: true, stats: 'none', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }, ]; diff --git a/test/stats/watch/stats-and-watch.test.js b/test/stats/watch/stats-and-watch.test.js index 86ef24df20e..e180b31741e 100644 --- a/test/stats/watch/stats-and-watch.test.js +++ b/test/stats/watch/stats-and-watch.test.js @@ -2,33 +2,25 @@ const { runWatch } = require('../../utils/test-utils'); -// const output = isWebpack5 ? 'successfully' : 'main.js'; - describe('stats and watch', () => { it('should not log stats with the "none" value from the configuration', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); it('should not log stats with the "none" value from the configuration and multi compiler mode', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './multi-webpack.config.js', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); it('should log stats with the "normal" value in arguments', async () => { - const { stderr } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); + const { stderr, stdout } = await runWatch(__dirname, ['-c', './webpack.config.js', '--stats', 'normal', '--color']); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); - expect(stderr).toContain('Compiler is watching files for updates...'); - // expect(stdout).toContain(output); + expect(stderr).toBeFalsy(); + expect(stdout).toBeTruthy(); }); }); diff --git a/test/stats/watch/webpack.config.js b/test/stats/watch/webpack.config.js index 65a1ecbbe75..d98762eafc4 100644 --- a/test/stats/watch/webpack.config.js +++ b/test/stats/watch/webpack.config.js @@ -1,5 +1,16 @@ +const webpack = require('webpack'); + module.exports = { watch: true, stats: 'none', - mode: 'production', + mode: 'development', + plugins: [ + { + apply(compiler) { + (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap('webpack-cli-test', () => { + console.log(`webpack ${webpack.version}`); + }); + }, + }, + ], }; diff --git a/test/target/flag-test/target-flag.test.js b/test/target/flag-test/target-flag.test.js index b761b9c7cc8..0705a117cee 100644 --- a/test/target/flag-test/target-flag.test.js +++ b/test/target/flag-test/target-flag.test.js @@ -9,8 +9,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -23,8 +22,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-t', `${val}`]); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); if (isWebpack5) { expect(stdout).toContain(`target: [ '${val}' ]`); @@ -53,8 +51,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target', 'node', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'node', 'async-node' ]`); }); @@ -78,8 +75,7 @@ describe('--target flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--target-reset', '--target', 'async-node']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: [ 'async-node' ]`); }); diff --git a/test/target/node/node-test.test.js b/test/target/node/node-test.test.js index d672dcb2d01..7eecf415504 100644 --- a/test/target/node/node-test.test.js +++ b/test/target/node/node-test.test.js @@ -6,8 +6,7 @@ describe('Node target', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-c', './webpack.config.js']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); diff --git a/test/utils/cli-plugin-test/plugin.test.js b/test/utils/cli-plugin-test/plugin.test.js index 9473f01064f..77b4a6e8d09 100644 --- a/test/utils/cli-plugin-test/plugin.test.js +++ b/test/utils/cli-plugin-test/plugin.test.js @@ -7,8 +7,7 @@ describe('webpack-cli-test-plugin Test', () => { const { exitCode, stderr, stdout } = run(__dirname); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toContain(`target: 'node'`); if (typeof cli !== 'undefined') { diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index 7b57ff9db22..329ae19a3d0 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -7,6 +7,7 @@ const { sync: spawnSync, node: execaNode } = execa; const { Writable } = require('readable-stream'); const concat = require('concat-stream'); const { version } = require('webpack'); +const stripAnsi = require('strip-ansi'); const { version: devServerVersion } = require('webpack-dev-server/package.json'); const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js'); @@ -51,7 +52,7 @@ const run = (testCase, args = [], setOutput = true, nodeOptions = [], env) => { return result; }; -const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'Compiler is watching files for updates...') => { +const runWatch = (testCase, args = [], setOutput = true, outputKillStr = /webpack \d+\.\d+\.\d/) => { const cwd = path.resolve(testCase); const outputPath = path.resolve(testCase, 'bin'); @@ -64,12 +65,12 @@ const runWatch = (testCase, args = [], setOutput = true, outputKillStr = 'Compil stdio: 'pipe', }); - proc.stderr.pipe( + proc.stdout.pipe( new Writable({ write(chunk, encoding, callback) { - const output = chunk.toString('utf8'); + const output = stripAnsi(chunk.toString('utf8')); - if (output.includes(outputKillStr)) { + if (outputKillStr.test(output)) { if (isWindows) { exec('taskkill /pid ' + proc.pid + ' /T /F'); } else { diff --git a/test/utils/test-utils.test.js b/test/utils/test-utils.test.js index daff27b08e9..0e4d3aeafb6 100644 --- a/test/utils/test-utils.test.js +++ b/test/utils/test-utils.test.js @@ -38,8 +38,7 @@ describe('run function', () => { it('should work correctly by default', () => { const { command, stdout, stderr } = run(__dirname); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Executes the correct command expect(command).toContain('cli.js'); // Should use apply a default output dir @@ -67,8 +66,7 @@ describe('run function', () => { // execution command contains info command expect(command).not.toContain('--output-path'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); }); @@ -82,8 +80,7 @@ describe('runAndGetWatchProc function', () => { // Should use apply a default output dir expect(command).toContain('--output-path'); expect(command).toContain('bin'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -106,8 +103,7 @@ describe('runAndGetWatchProc function', () => { // execution command contains info command expect(command).not.toContain('--output-path'); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); diff --git a/test/version/version-external-packages.test.js b/test/version/version-external-packages.test.js index bfd6f4ba23b..d936da17f0d 100644 --- a/test/version/version-external-packages.test.js +++ b/test/version/version-external-packages.test.js @@ -14,63 +14,63 @@ describe('version flag with external packages', () => { const { exitCode, stderr, stdout } = run(__dirname, ['init', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with the alias c for init', () => { const { exitCode, stderr, stdout } = run(__dirname, ['c', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(initPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with info', () => { const { exitCode, stderr, stdout } = run(__dirname, ['info', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(infoPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with serve', () => { const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(servePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with migrate', () => { const { exitCode, stderr, stdout } = run(__dirname, ['migrate', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(migratePkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with plugin', () => { const { exitCode, stderr, stdout } = run(__dirname, ['plugin', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pluginPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs version with loader', () => { const { exitCode, stderr, stdout } = run(__dirname, ['loader', '--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(loaderPkgJSON.version); expect(stdout).toContain(cliPkgJSON.version); - expect(stderr).toHaveLength(0); }); it(' should throw error for multiple commands', () => { @@ -89,7 +89,7 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); it(' should throw error if invalid argument is present with version command', () => { @@ -98,7 +98,7 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); it(' should throw error if invalid argument is present with -v alias', () => { @@ -107,6 +107,6 @@ describe('version flag with external packages', () => { expect(exitCode).toBe(2); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); - expect(stdout).toBe(''); + expect(stdout).toBeFalsy(); }); }); diff --git a/test/version/version-multi-args.test.js b/test/version/version-multi-args.test.js index f5de6205cb6..8059926546f 100644 --- a/test/version/version-multi-args.test.js +++ b/test/version/version-multi-args.test.js @@ -8,71 +8,71 @@ describe('version flag with multiple arguments', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', 'help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(pkgJSON.version); expect(stdout).toContain('The build tool for modern web applications'); - expect(stderr).toHaveLength(0); }); it('does not output version with help dashed', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', '--help'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).not.toContain(pkgJSON.version); expect(stdout).toContain('The build tool for modern web applications'); - expect(stderr).toHaveLength(0); }); it('throws error if invalid command is passed with version command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with version command', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid command is passed with --version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with --version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid command is passed with -v alias', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v', 'abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid command 'abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); it('throws error if invalid option is passed with -v alias', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v', '--abc', '--no-color'], false); expect(exitCode).toBe(2); - expect(stdout).not.toContain(pkgJSON.version); expect(stderr).toContain(`[webpack-cli] Invalid option '--abc'`); expect(stderr).toContain('[webpack-cli] Run webpack --help to see available commands and arguments'); + expect(stdout).not.toContain(pkgJSON.version); }); }); diff --git a/test/version/version-single-arg.test.js b/test/version/version-single-arg.test.js index 8516f802bb9..72b34cbcff6 100644 --- a/test/version/version-single-arg.test.js +++ b/test/version/version-single-arg.test.js @@ -8,23 +8,23 @@ describe('single version flag', () => { const { exitCode, stderr, stdout } = run(__dirname, ['version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs versions with dashed syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['--version'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); it('outputs versions with alias syntax', () => { const { exitCode, stderr, stdout } = run(__dirname, ['-v'], false); expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); expect(stdout).toContain(pkgJSON.version); - expect(stderr).toHaveLength(0); }); }); diff --git a/test/watch/watch-flag.test.js b/test/watch/watch-flag.test.js index caa2f970530..404a17fc568 100644 --- a/test/watch/watch-flag.test.js +++ b/test/watch/watch-flag.test.js @@ -13,8 +13,7 @@ describe('--watch flag', () => { const { exitCode, stderr, stdout } = await run(__dirname, ['-c', './watch.config.js', '--no-watch']); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); expect(stdout).toBeTruthy(); }); @@ -36,13 +35,7 @@ describe('--watch flag', () => { expect(data).toContain(word); } } - } - }); - - proc.stderr.on('data', (chunk) => { - const data = stripAnsi(chunk.toString()); - if (data.includes('Compiler is watching files for updates...')) { if (!modified) { process.nextTick(() => { writeFileSync(resolve(__dirname, './src/index.js'), `console.log('watch flag test');`); diff --git a/test/zero-config/entry-absent/zero-config.test.js b/test/zero-config/entry-absent/zero-config.test.js index 005e22689e2..c55f05e049a 100644 --- a/test/zero-config/entry-absent/zero-config.test.js +++ b/test/zero-config/entry-absent/zero-config.test.js @@ -5,8 +5,7 @@ describe('Zero Config tests', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(1); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Entry file is absent, should log the Error from the compiler expect(stdout).toContain("Error: Can't resolve './src'"); }); diff --git a/test/zero-config/entry-present/zero-config.test.js b/test/zero-config/entry-present/zero-config.test.js index b39db4d1243..671cf74933d 100644 --- a/test/zero-config/entry-present/zero-config.test.js +++ b/test/zero-config/entry-present/zero-config.test.js @@ -5,8 +5,7 @@ describe('Zero Config tests', () => { const { exitCode, stderr, stdout } = run(__dirname, [], false); expect(exitCode).toBe(0); - expect(stderr).toContain('Compilation starting...'); - expect(stderr).toContain('Compilation finished'); + expect(stderr).toBeFalsy(); // Should be able to find the entry file expect(stdout).toContain('./src/index.js'); // Should output at the default output dir and filename