@@ -437,19 +437,27 @@ describe('notices configuration tests', () => {
437437} ) ;
438438
439439describe ( 'gc command tests' , ( ) => {
440+ let originalCliIoHostInstance : any ;
441+
440442 beforeEach ( ( ) => {
441443 jest . clearAllMocks ( ) ;
444+ originalCliIoHostInstance = CliIoHost . instance ;
445+ } ) ;
446+
447+ afterEach ( ( ) => {
448+ CliIoHost . instance = originalCliIoHostInstance ;
442449 } ) ;
443450
444451 test ( 'should warn when --role-arn is used with gc command' , async ( ) => {
445452 const gcSpy = jest . spyOn ( cdkToolkitModule . CdkToolkit . prototype , 'garbageCollect' ) . mockResolvedValue ( ) ;
446-
447- // Make exec use our TestIoHost and adds properties to TestIoHost to match ClioHosr
453+
454+ // Make exec use our TestIoHost and adds properties to TestIoHost to match CliIoHost
448455 const warnSpy = jest . fn ( ) ;
449- ( ioHost as any ) . defaults = { warn : warnSpy , debug : jest . fn ( ) } ;
456+ ( ioHost as any ) . defaults = { warn : warnSpy , debug : jest . fn ( ) , result : jest . fn ( ) } ;
450457 ( ioHost as any ) . asIoHelper = ( ) => ioHelper ;
458+ ( ioHost as any ) . logLevel = 'info' ;
451459 jest . spyOn ( CliIoHost , 'instance' ) . mockReturnValue ( ioHost as any ) ;
452-
460+
453461 const mockConfig = {
454462 loadConfigFiles : jest . fn ( ) . mockResolvedValue ( undefined ) ,
455463 settings : {
@@ -462,13 +470,13 @@ describe('gc command tests', () => {
462470 get : jest . fn ( ) . mockReturnValue ( [ ] ) ,
463471 } ,
464472 } ;
465-
473+
466474 Configuration . fromArgsAndFiles = jest . fn ( ) . mockResolvedValue ( mockConfig ) ;
467475
468476 await exec ( [ 'gc' , '--unstable=gc' , '--role-arn' , 'arn:aws:iam::123456789012:role/TestRole' ] ) ;
469477
470478 expect ( warnSpy ) . toHaveBeenCalledWith (
471- 'The --role-arn option is not supported for the gc command and will be ignored.'
479+ 'The --role-arn option is not supported for the gc command and will be ignored.' ,
472480 ) ;
473481 expect ( gcSpy ) . toHaveBeenCalled ( ) ;
474482 } ) ;
0 commit comments