From d2f4cf5f42bb4cd2b41bc1993ed4cc5cbb5d3297 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 25 Jan 2021 23:47:00 +0300 Subject: [PATCH] tests: fix --- test/serve/basic/serve-basic.test.js | 11 ----------- test/serve/help/serve-help.test.js | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index c8feaae2326..a57308f0a00 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -7,9 +7,6 @@ const { runServe, isWebpack5, isDevServer4 } = require('../../utils/test-utils') const testPath = path.resolve(__dirname); -const usageText = 'webpack serve|s [options]'; -const descriptionText = 'Run the webpack dev server'; - describe('basic serve usage', () => { let port; @@ -161,14 +158,6 @@ describe('basic serve usage', () => { expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull(); }); - it('should log help information and respect the "--no-color" option', async () => { - const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); - - expect(stderr).toBeFalsy(); - expect(stdout).toContain(usageText); - expect(stdout).toContain(descriptionText); - }); - it('should work with the "--client-log-level" option', async () => { const { stdout, stderr } = await runServe(testPath, ['--client-log-level', 'info']); diff --git a/test/serve/help/serve-help.test.js b/test/serve/help/serve-help.test.js index c1f4cc840c2..eb8cabef807 100644 --- a/test/serve/help/serve-help.test.js +++ b/test/serve/help/serve-help.test.js @@ -1,11 +1,12 @@ const { runServe, isWebpack5 } = require('../../utils/test-utils'); -const usageText = 'webpack serve|s [options]'; +const usageText = 'webpack serve|s [entries...] [options]'; const descriptionText = 'Run the webpack dev server'; describe('serve help', () => { - it('should output serve help', async () => { + it('should log help information', async () => { const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help']); + expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); expect(stdout).toContain(descriptionText); @@ -18,15 +19,25 @@ describe('serve help', () => { expect(stdout).toContain('--open [value]'); }); - it('should output all flags when verbose help is set', async () => { + it('should log help information using "verbose"', async () => { const { stderr, stdout, exitCode } = await runServe(__dirname, ['--help', 'verbose']); + expect(stderr).toBeFalsy(); expect(exitCode).toBe(0); expect(stdout).toContain(descriptionText); expect(stdout).toContain(usageText); expect(stdout).toContain('Options:'); + if (isWebpack5) { expect(stdout).toContain('--cache-type'); } }); + + it('should log help information and respect the "--no-color" option', async () => { + const { stdout, stderr } = await runServe(__dirname, ['--help', '--no-color']); + + expect(stderr).toBeFalsy(); + expect(stdout).toContain(usageText); + expect(stdout).toContain(descriptionText); + }); });