@@ -655,12 +655,14 @@ describe("CLI arguments", () => {
655
655
describe ( `deprecation behaviour of ${ cliArg } ` , ( ) => {
656
656
let cliArgs : CliOptions & UserConfig & { _ ?: string [ ] } ;
657
657
let warn : ( msg : string ) => void ;
658
+ let exit : ( status : number ) => void | never ;
658
659
659
660
beforeEach ( ( ) => {
660
661
cliArgs = { [ cliArg ] : "RandomString" } as unknown as CliOptions & UserConfig & { _ ?: string [ ] } ;
661
662
warn = vi . fn ( ) ;
663
+ exit = vi . fn ( ) ;
662
664
663
- warnAboutDeprecatedOrUnknownCliArgs ( cliArgs as unknown as Record < string , unknown > , warn ) ;
665
+ warnAboutDeprecatedOrUnknownCliArgs ( cliArgs as unknown as Record < string , unknown > , { warn, exit } ) ;
664
666
} ) ;
665
667
666
668
it ( `warns the usage of ${ cliArg } as it is deprecated` , ( ) => {
@@ -670,22 +672,28 @@ describe("CLI arguments", () => {
670
672
it ( `shows the reference message when ${ cliArg } was passed` , ( ) => {
671
673
expect ( warn ) . toHaveBeenCalledWith ( referDocMessage ) ;
672
674
} ) ;
675
+
676
+ it ( `should not exit the process` , ( ) => {
677
+ expect ( exit ) . not . toHaveBeenCalled ( ) ;
678
+ } ) ;
673
679
} ) ;
674
680
}
675
681
676
682
describe ( "invalid arguments" , ( ) => {
677
683
let warn : ( msg : string ) => void ;
684
+ let exit : ( status : number ) => void | never ;
678
685
679
686
beforeEach ( ( ) => {
680
687
warn = vi . fn ( ) ;
688
+ exit = vi . fn ( ) ;
681
689
} ) ;
682
690
683
691
it ( "should show a warning when an argument is not known" , ( ) => {
684
692
warnAboutDeprecatedOrUnknownCliArgs (
685
693
{
686
694
wakanda : "" ,
687
695
} ,
688
- warn
696
+ { warn, exit }
689
697
) ;
690
698
691
699
expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'wakanda'." ) ;
@@ -694,12 +702,23 @@ describe("CLI arguments", () => {
694
702
) ;
695
703
} ) ;
696
704
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
+
697
716
it ( "should show a suggestion when is a simple typo" , ( ) => {
698
717
warnAboutDeprecatedOrUnknownCliArgs (
699
718
{
700
719
readonli : "" ,
701
720
} ,
702
- warn
721
+ { warn, exit }
703
722
) ;
704
723
705
724
expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'readonli'. Did you mean 'readOnly'?" ) ;
@@ -713,7 +732,7 @@ describe("CLI arguments", () => {
713
732
{
714
733
readonly : "" ,
715
734
} ,
716
- warn
735
+ { warn, exit }
717
736
) ;
718
737
719
738
expect ( warn ) . toHaveBeenCalledWith ( "Invalid command line argument 'readonly'. Did you mean 'readOnly'?" ) ;
0 commit comments