@@ -404,6 +404,43 @@ describe('runInCI', () => {
404404 expect ( logger . info ) . toHaveBeenCalled ( ) ;
405405 expect ( logger . debug ) . toHaveBeenCalled ( ) ;
406406 } ) ;
407+
408+ it ( 'should skip comment if disabled' , async ( ) => {
409+ const api : ProviderAPIClient = {
410+ maxCommentChars : 1_000_000 ,
411+ createComment : vi . fn ( ) ,
412+ updateComment : vi . fn ( ) ,
413+ listComments : vi . fn ( ) . mockResolvedValue ( [ ] ) ,
414+ } ;
415+
416+ await expect (
417+ runInCI ( refs , api , { ...options , skipComment : true } , git ) ,
418+ ) . resolves . toEqual ( {
419+ mode : 'standalone' ,
420+ commentId : undefined ,
421+ newIssues : [ ] ,
422+ files : {
423+ report : {
424+ json : path . join ( outputDir , 'report.json' ) ,
425+ md : path . join ( outputDir , 'report.md' ) ,
426+ } ,
427+ diff : {
428+ json : path . join ( outputDir , 'report-diff.json' ) ,
429+ md : path . join ( outputDir , 'report-diff.md' ) ,
430+ } ,
431+ } ,
432+ } satisfies RunResult ) ;
433+
434+ expect ( api . listComments ) . not . toHaveBeenCalled ( ) ;
435+ expect ( api . createComment ) . not . toHaveBeenCalled ( ) ;
436+ expect ( api . updateComment ) . not . toHaveBeenCalled ( ) ;
437+
438+ expect ( utils . executeProcess ) . toHaveBeenCalledWith ( {
439+ command : options . bin ,
440+ args : expect . arrayContaining ( [ 'compare' ] ) ,
441+ cwd : workDir ,
442+ } satisfies utils . ProcessConfig ) ;
443+ } ) ;
407444 } ) ;
408445 } ) ;
409446
@@ -743,6 +780,60 @@ describe('runInCI', () => {
743780 expect ( logger . info ) . toHaveBeenCalled ( ) ;
744781 expect ( logger . debug ) . toHaveBeenCalled ( ) ;
745782 } ) ;
783+
784+ it ( 'should skip comment if disabled' , async ( ) => {
785+ const api : ProviderAPIClient = {
786+ maxCommentChars : 1_000_000 ,
787+ createComment : vi . fn ( ) ,
788+ updateComment : vi . fn ( ) ,
789+ listComments : vi . fn ( ) ,
790+ } ;
791+
792+ await expect (
793+ runInCI (
794+ refs ,
795+ api ,
796+ { ...options , monorepo : tool , skipComment : true } ,
797+ git ,
798+ ) ,
799+ ) . resolves . toEqual ( {
800+ mode : 'monorepo' ,
801+ commentId : undefined ,
802+ diffPath : path . join ( workDir , '.code-pushup/merged-report-diff.md' ) ,
803+ projects : [
804+ expect . objectContaining ( { name : 'cli' } ) ,
805+ expect . objectContaining ( { name : 'core' } ) ,
806+ expect . objectContaining ( { name : 'utils' } ) ,
807+ ] ,
808+ } satisfies RunResult ) ;
809+
810+ await expect (
811+ readFile (
812+ path . join ( workDir , '.code-pushup/merged-report-diff.md' ) ,
813+ 'utf8' ,
814+ ) ,
815+ ) . resolves . toBe ( diffMdString ) ;
816+
817+ expect ( api . listComments ) . not . toHaveBeenCalled ( ) ;
818+ expect ( api . createComment ) . not . toHaveBeenCalled ( ) ;
819+ expect ( api . updateComment ) . not . toHaveBeenCalled ( ) ;
820+
821+ expect ( utils . executeProcess ) . toHaveBeenCalledWith ( {
822+ command : runMany ,
823+ args : expect . any ( Array ) ,
824+ cwd : expect . stringContaining ( workDir ) ,
825+ } satisfies utils . ProcessConfig ) ;
826+ expect ( utils . executeProcess ) . toHaveBeenCalledWith ( {
827+ command : run ,
828+ args : expect . arrayContaining ( [ 'compare' ] ) ,
829+ cwd : expect . stringContaining ( workDir ) ,
830+ } satisfies utils . ProcessConfig ) ;
831+ expect ( utils . executeProcess ) . toHaveBeenCalledWith ( {
832+ command : run ,
833+ args : expect . arrayContaining ( [ 'merge-diffs' ] ) ,
834+ cwd : expect . stringContaining ( workDir ) ,
835+ } satisfies utils . ProcessConfig ) ;
836+ } ) ;
746837 } ) ;
747838 } ) ;
748839
0 commit comments