@@ -4,17 +4,38 @@ const { run } = require('../utils/test-utils');
44
55describe ( 'progress flag' , ( ) => {
66 it ( 'should show progress' , ( ) => {
7- const { stderr, stdout } = run ( __dirname , [ '--progress' ] ) ;
7+ const { stderr, stdout, exitCode } = run ( __dirname , [ '--progress' ] ) ;
8+
9+ expect ( exitCode ) . toBe ( 0 ) ;
10+ expect ( stderr ) . not . toMatch ( / \[ w e b p a c k \. P r o g r e s s ] \d + m s s e t u p / ) ;
11+ expect ( stderr ) . toContain ( '[webpack.Progress] 100%' ) ;
12+ expect ( stdout ) . toContain ( 'main.js' ) ;
13+ } ) ;
14+
15+ it ( 'should support the "profile" value' , ( ) => {
16+ const { stderr, stdout, exitCode } = run ( __dirname , [ '--progress=profile' ] ) ;
17+
18+ expect ( exitCode ) . toBe ( 0 ) ;
19+ expect ( stderr ) . toMatch ( / \[ w e b p a c k \. P r o g r e s s ] \d + m s s e t u p / ) ;
820 expect ( stderr ) . toContain ( '[webpack.Progress] 100%' ) ;
921 expect ( stdout ) . toContain ( 'main.js' ) ;
1022 } ) ;
1123
24+ it ( 'should not support invalid value' , ( ) => {
25+ const { stderr, stdout, exitCode } = run ( __dirname , [ '--progress=unknown' ] ) ;
26+
27+ expect ( exitCode ) . toBe ( 2 ) ;
28+ expect ( stderr ) . toContain ( 'Invalid unknown value for the progress option. Allowed value is profile.' ) ;
29+ expect ( stdout ) . toBeFalsy ( ) ;
30+ } ) ;
31+
1232 it ( 'should not add duplicate plugins' , ( ) => {
1333 const { stderr, stdout, exitCode } = run ( __dirname , [ '-c' , 'webpack.progress.config.js' , '--progress' ] ) ;
14- // Only 1 progress plugin should be applied to the compiler
34+
35+ expect ( exitCode ) . toEqual ( 0 ) ;
1536 expect ( stdout . match ( / P r o g r e s s P l u g i n / g) ) . toHaveLength ( 1 ) ;
37+ expect ( stderr ) . not . toMatch ( / \[ w e b p a c k \. P r o g r e s s ] \d + m s s e t u p / ) ;
1638 expect ( stderr ) . toContain ( '[webpack.Progress] 100%' ) ;
1739 expect ( stdout ) . toContain ( 'main.js' ) ;
18- expect ( exitCode ) . toEqual ( 0 ) ;
1940 } ) ;
2041} ) ;
0 commit comments