@@ -184,12 +184,22 @@ describe('unknown behaviour', () => {
184
184
expect ( stdout ) . toBeFalsy ( ) ;
185
185
} ) ;
186
186
187
- it ( 'should ask to install command if an unknown command passed' , ( ) => {
187
+ it ( 'should log error if an unknown command passed' , ( ) => {
188
188
const { exitCode, stderr, stdout } = run ( __dirname , [ 'qqq' ] , true , [ ] , { TERM_PROGRAM : false } ) ;
189
189
190
- expect ( exitCode ) . toBe ( 0 ) ;
191
- expect ( stripAnsi ( stderr ) ) . toContain ( "For using this command you need to install: 'qqq' package" ) ;
192
- expect ( stripAnsi ( stderr ) ) . toContain ( "Would you like to install 'qqq' package? (That will run 'npm install -D qqq')" ) ;
190
+ expect ( exitCode ) . toBe ( 2 ) ;
191
+ expect ( stripAnsi ( stderr ) ) . toContain ( "Unknown command 'qqq'" ) ;
192
+ expect ( stripAnsi ( stderr ) ) . toContain ( "Run 'webpack --help' to see available commands and options" ) ;
193
+ expect ( stdout ) . toBeFalsy ( ) ;
194
+ } ) ;
195
+
196
+ it ( 'should log error and provide suggestion if an unknown command passed' , ( ) => {
197
+ const { exitCode, stderr, stdout } = run ( __dirname , [ 'server' ] , true , [ ] , { TERM_PROGRAM : false } ) ;
198
+
199
+ expect ( exitCode ) . toBe ( 2 ) ;
200
+ expect ( stripAnsi ( stderr ) ) . toContain ( "Unknown command 'server'" ) ;
201
+ expect ( stripAnsi ( stderr ) ) . toContain ( "Did you mean 'serve' (alias 's')?" ) ;
202
+ expect ( stripAnsi ( stderr ) ) . toContain ( "Run 'webpack --help' to see available commands and options" ) ;
193
203
expect ( stdout ) . toBeFalsy ( ) ;
194
204
} ) ;
195
205
} ) ;
0 commit comments