@@ -12,6 +12,7 @@ import {
1212
1313import { detectProvider } from "../provider" ;
1414import { Output } from "../Output" ;
15+ import chalk from "chalk" ;
1516
1617vi . mock ( "../provider" ) ;
1718
@@ -338,6 +339,31 @@ describe("Output", () => {
338339 await output . write ( ) ;
339340 } ) ;
340341
342+ it ( "logs error when debug is enabled" , async ( ) => {
343+ setup ( { urlSendError : true } ) ;
344+
345+ const output = new Output ( {
346+ apiUrl : "http://localhost" ,
347+ bundleName : "output-test" ,
348+ debug : true ,
349+ dryRun : false ,
350+ enableBundleAnalysis : true ,
351+ retryCount : 1 ,
352+ uploadToken : "token" ,
353+ } ) ;
354+
355+ output . start ( ) ;
356+ output . end ( ) ;
357+
358+ await output . write ( ) ;
359+
360+ expect ( consoleSpy ) . toHaveBeenCalledWith (
361+ `[codecov] ${ chalk . italic . yellow (
362+ 'Error getting pre-signed URL: "Error: Failed to fetch pre-signed URL"' ,
363+ ) } `,
364+ ) ;
365+ } ) ;
366+
341367 it ( "optionally emits error" , async ( ) => {
342368 setup ( { urlSendError : true } ) ;
343369
@@ -430,6 +456,35 @@ describe("Output", () => {
430456 await output . write ( ) ;
431457 } ) ;
432458
459+ it ( "logs error when debug is enabled" , async ( ) => {
460+ setup ( {
461+ urlData : { url : "http://localhost/upload/stats/" } ,
462+ urlStatus : 200 ,
463+ statsSendError : true ,
464+ } ) ;
465+
466+ const output = new Output ( {
467+ apiUrl : "http://localhost" ,
468+ bundleName : "output-test" ,
469+ debug : true ,
470+ dryRun : false ,
471+ enableBundleAnalysis : true ,
472+ retryCount : 1 ,
473+ uploadToken : "token" ,
474+ } ) ;
475+
476+ output . start ( ) ;
477+ output . end ( ) ;
478+
479+ await output . write ( ) ;
480+
481+ expect ( consoleSpy ) . toHaveBeenCalledWith (
482+ `[codecov] ${ chalk . italic . yellow (
483+ 'Error uploading stats: "Error: Failed to upload stats"' ,
484+ ) } `,
485+ ) ;
486+ } ) ;
487+
433488 it ( "optionally emits error" , async ( ) => {
434489 setup ( {
435490 urlData : { url : "http://localhost/upload/stats/" } ,
0 commit comments