@@ -655,12 +655,14 @@ describe("CLI arguments", () => {
655655 describe ( `deprecation behaviour of ${ cliArg } ` , ( ) => {
656656 let cliArgs : CliOptions & UserConfig & { _ ?: string [ ] } ;
657657 let warn : ( msg : string ) => void ;
658+ let exit : ( status : number ) => void | never ;
658659
659660 beforeEach ( ( ) => {
660661 cliArgs = { [ cliArg ] : "RandomString" } as unknown as CliOptions & UserConfig & { _ ?: string [ ] } ;
661662 warn = vi . fn ( ) ;
663+ exit = vi . fn ( ) ;
662664
663- warnAboutDeprecatedOrUnknownCliArgs ( cliArgs as unknown as Record < string , unknown > , warn ) ;
665+ warnAboutDeprecatedOrUnknownCliArgs ( cliArgs as unknown as Record < string , unknown > , { warn, exit } ) ;
664666 } ) ;
665667
666668 it ( `warns the usage of ${ cliArg } as it is deprecated` , ( ) => {
@@ -670,22 +672,28 @@ describe("CLI arguments", () => {
670672 it ( `shows the reference message when ${ cliArg } was passed` , ( ) => {
671673 expect ( warn ) . toHaveBeenCalledWith ( referDocMessage ) ;
672674 } ) ;
675+
676+ it ( `should not exit the process` , ( ) => {
677+ expect ( exit ) . not . toHaveBeenCalled ( ) ;
678+ } ) ;
673679 } ) ;
674680 }
675681
676682 describe ( "invalid arguments" , ( ) => {
677683 let warn : ( msg : string ) => void ;
684+ let exit : ( status : number ) => void | never ;
678685
679686 beforeEach ( ( ) => {
680687 warn = vi . fn ( ) ;
688+ exit = vi . fn ( ) ;
681689 } ) ;
682690
683691 it ( "should show a warning when an argument is not known" , ( ) => {
684692 warnAboutDeprecatedOrUnknownCliArgs (
685693 {
686694 wakanda : "" ,
687695 } ,
688- warn
696+ { warn, exit }
689697 ) ;
690698
691699 expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'wakanda'." ) ;
@@ -694,12 +702,23 @@ describe("CLI arguments", () => {
694702 ) ;
695703 } ) ;
696704
705+ it ( "should exit the process on unknown cli args" , ( ) => {
706+ warnAboutDeprecatedOrUnknownCliArgs (
707+ {
708+ wakanda : "" ,
709+ } ,
710+ { warn, exit }
711+ ) ;
712+
713+ expect ( exit ) . toHaveBeenCalledWith ( 1 ) ;
714+ } ) ;
715+
697716 it ( "should show a suggestion when is a simple typo" , ( ) => {
698717 warnAboutDeprecatedOrUnknownCliArgs (
699718 {
700719 readonli : "" ,
701720 } ,
702- warn
721+ { warn, exit }
703722 ) ;
704723
705724 expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'readonli'. Did you mean 'readOnly'?" ) ;
@@ -713,7 +732,7 @@ describe("CLI arguments", () => {
713732 {
714733 readonly : "" ,
715734 } ,
716- warn
735+ { warn, exit }
717736 ) ;
718737
719738 expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'readonly'. Did you mean 'readOnly'?" ) ;
0 commit comments