@@ -4,14 +4,8 @@ const { run } = require('../utils/test-utils');
44const pkgJSON = require ( '../../packages/webpack-cli/package.json' ) ;
55
66describe ( 'version flag with multiple arguments' , ( ) => {
7- it ( 'outputs version with mixed syntax' , ( ) => {
8- const { stdout, stderr } = run ( __dirname , [ '--version' , '--target' , 'browser' ] ) ;
9- expect ( stdout ) . toContain ( pkgJSON . version ) ;
10- expect ( stderr ) . toHaveLength ( 0 ) ;
11- } ) ;
12-
137 it ( 'does not output version with help command' , ( ) => {
14- const { stdout, stderr } = run ( __dirname , [ 'version' , 'help' ] ) ;
8+ const { stdout, stderr } = run ( __dirname , [ 'version' , 'help' ] , false ) ;
159 expect ( stdout ) . not . toContain ( pkgJSON . version ) ;
1610
1711 const uniqueIdentifier = 'Made with ♥️ by the webpack team' ;
@@ -20,17 +14,32 @@ describe('version flag with multiple arguments', () => {
2014 } ) ;
2115
2216 it ( 'does not output version with help dashed' , ( ) => {
23- const { stdout, stderr } = run ( __dirname , [ 'version' , '--help' ] ) ;
17+ const { stdout, stderr } = run ( __dirname , [ 'version' , '--help' ] , false ) ;
2418 expect ( stdout ) . not . toContain ( pkgJSON . version ) ;
2519
2620 const uniqueIdentifier = 'Made with ♥️ by the webpack team' ;
2721 expect ( stdout ) . toContain ( uniqueIdentifier ) ;
2822 expect ( stderr ) . toHaveLength ( 0 ) ;
2923 } ) ;
3024
31- it ( 'outputs version with multiple dashed args and has precedence' , ( ) => {
32- const { stdout, stderr } = run ( __dirname , [ '--target' , 'browser' , '--version' ] ) ;
33- expect ( stdout ) . toContain ( pkgJSON . version ) ;
34- expect ( stderr ) . toHaveLength ( 0 ) ;
25+ it ( 'throws error if invalid arg is passed with version command' , ( ) => {
26+ const { stdout, stderr } = run ( __dirname , [ 'version' , 'abc' ] , false ) ;
27+ expect ( stdout ) . not . toContain ( pkgJSON . version ) ;
28+ expect ( stderr ) . toContain ( `Error: Invalid Option 'abc'` ) ;
29+ expect ( stdout ) . toContain ( 'Run webpack --help to see available commands and arguments' ) ;
30+ } ) ;
31+
32+ it ( 'throws error if invalid arg is passed with --version flag' , ( ) => {
33+ const { stdout, stderr } = run ( __dirname , [ '--version' , 'abc' ] , false ) ;
34+ expect ( stdout ) . not . toContain ( pkgJSON . version ) ;
35+ expect ( stderr ) . toContain ( `Error: Invalid Option 'abc'` ) ;
36+ expect ( stdout ) . toContain ( 'Run webpack --help to see available commands and arguments' ) ;
37+ } ) ;
38+
39+ it ( 'throws error if invalid arg is passed with -v alias' , ( ) => {
40+ const { stdout, stderr } = run ( __dirname , [ '-v' , 'abc' ] , false ) ;
41+ expect ( stdout ) . not . toContain ( pkgJSON . version ) ;
42+ expect ( stderr ) . toContain ( `Error: Invalid Option 'abc'` ) ;
43+ expect ( stdout ) . toContain ( 'Run webpack --help to see available commands and arguments' ) ;
3544 } ) ;
3645} ) ;
0 commit comments