@@ -3,23 +3,31 @@ const { run, isWebpack5 } = require('../../utils/test-utils');
33
44describe ( 'invalid schema' , ( ) => {
55 it ( 'should log error on invalid config' , ( ) => {
6- const { exitCode, stderr, stdout } = run ( __dirname , [ '--config' , './webpack.config. mock.js' ] ) ;
6+ const { exitCode, stderr, stdout } = run ( __dirname , [ '--config' , './webpack.mock.config .js' ] ) ;
77
88 expect ( exitCode ) . toEqual ( 2 ) ;
99 expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
1010 expect ( stdout ) . toBeFalsy ( ) ;
1111 } ) ;
1212
13+ it ( 'should log error on invalid plugin options' , ( ) => {
14+ const { exitCode, stderr, stdout } = run ( __dirname , [ '--config' , './webpack.plugin-mock.config.js' ] ) ;
15+
16+ expect ( exitCode ) . toEqual ( 2 ) ;
17+ expect ( stderr ) . toContain ( isWebpack5 ? 'Invalid options object' : 'Invalid Options' ) ;
18+ expect ( stdout ) . toBeFalsy ( ) ;
19+ } ) ;
20+
1321 it ( 'should log error on invalid config using the "bundle" command' , ( ) => {
14- const { exitCode, stderr, stdout } = run ( __dirname , [ 'bundle' , '--config' , './webpack.config. mock.js' ] ) ;
22+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'bundle' , '--config' , './webpack.mock.config .js' ] ) ;
1523
1624 expect ( exitCode ) . toEqual ( 2 ) ;
1725 expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
1826 expect ( stdout ) . toBeFalsy ( ) ;
1927 } ) ;
2028
2129 it ( 'should log error on invalid config using the "serve" command' , ( ) => {
22- const { exitCode, stderr, stdout } = run ( __dirname , [ 'serve' , '--config' , './webpack.config. mock.js' ] ) ;
30+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'serve' , '--config' , './webpack.mock.config .js' ] ) ;
2331
2432 expect ( exitCode ) . toEqual ( 2 ) ;
2533 expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
@@ -41,6 +49,21 @@ describe('invalid schema', () => {
4149 expect ( stdout ) . toBeFalsy ( ) ;
4250 } ) ;
4351
52+ it ( 'should log error on invalid option using "build" command' , ( ) => {
53+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'build' , '--mode' , 'Yukihira' ] ) ;
54+
55+ expect ( exitCode ) . toEqual ( 2 ) ;
56+
57+ if ( isWebpack5 ) {
58+ expect ( stderr ) . toContain ( "Invalid value 'Yukihira' for the '--mode' option" ) ;
59+ expect ( stderr ) . toContain ( "Expected: 'development | production | none'" ) ;
60+ } else {
61+ expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
62+ }
63+
64+ expect ( stdout ) . toBeFalsy ( ) ;
65+ } ) ;
66+
4467 it ( 'should log error on invalid option using "bundle" command' , ( ) => {
4568 const { exitCode, stderr, stdout } = run ( __dirname , [ 'bundle' , '--mode' , 'Yukihira' ] ) ;
4669
@@ -56,6 +79,51 @@ describe('invalid schema', () => {
5679 expect ( stdout ) . toBeFalsy ( ) ;
5780 } ) ;
5881
82+ it ( 'should log error on invalid option using "b" command' , ( ) => {
83+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'b' , '--mode' , 'Yukihira' ] ) ;
84+
85+ expect ( exitCode ) . toEqual ( 2 ) ;
86+
87+ if ( isWebpack5 ) {
88+ expect ( stderr ) . toContain ( "Invalid value 'Yukihira' for the '--mode' option" ) ;
89+ expect ( stderr ) . toContain ( "Expected: 'development | production | none'" ) ;
90+ } else {
91+ expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
92+ }
93+
94+ expect ( stdout ) . toBeFalsy ( ) ;
95+ } ) ;
96+
97+ it ( 'should log error on invalid option using "watch" command' , ( ) => {
98+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'watch' , '--mode' , 'Yukihira' ] ) ;
99+
100+ expect ( exitCode ) . toEqual ( 2 ) ;
101+
102+ if ( isWebpack5 ) {
103+ expect ( stderr ) . toContain ( "Invalid value 'Yukihira' for the '--mode' option" ) ;
104+ expect ( stderr ) . toContain ( "Expected: 'development | production | none'" ) ;
105+ } else {
106+ expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
107+ }
108+
109+ expect ( stdout ) . toBeFalsy ( ) ;
110+ } ) ;
111+
112+ it ( 'should log error on invalid option using "w" command' , ( ) => {
113+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'w' , '--mode' , 'Yukihira' ] ) ;
114+
115+ expect ( exitCode ) . toEqual ( 2 ) ;
116+
117+ if ( isWebpack5 ) {
118+ expect ( stderr ) . toContain ( "Invalid value 'Yukihira' for the '--mode' option" ) ;
119+ expect ( stderr ) . toContain ( "Expected: 'development | production | none'" ) ;
120+ } else {
121+ expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
122+ }
123+
124+ expect ( stdout ) . toBeFalsy ( ) ;
125+ } ) ;
126+
59127 it ( 'should log error on invalid option using "server" command' , ( ) => {
60128 const { exitCode, stderr, stdout } = run ( __dirname , [ 'serve' , '--mode' , 'Yukihira' ] ) ;
61129
@@ -70,4 +138,19 @@ describe('invalid schema', () => {
70138
71139 expect ( stdout ) . toBeFalsy ( ) ;
72140 } ) ;
141+
142+ it ( 'should log error on invalid option using "s" command' , ( ) => {
143+ const { exitCode, stderr, stdout } = run ( __dirname , [ 's' , '--mode' , 'Yukihira' ] ) ;
144+
145+ expect ( exitCode ) . toEqual ( 2 ) ;
146+
147+ if ( isWebpack5 ) {
148+ expect ( stderr ) . toContain ( "Invalid value 'Yukihira' for the '--mode' option" ) ;
149+ expect ( stderr ) . toContain ( "Expected: 'development | production | none'" ) ;
150+ } else {
151+ expect ( stderr ) . toContain ( 'Invalid configuration object' ) ;
152+ }
153+
154+ expect ( stdout ) . toBeFalsy ( ) ;
155+ } ) ;
73156} ) ;
0 commit comments