@@ -56,14 +56,18 @@ describe("Authorizer Lambda Function", () => {
5656 } ) ;
5757
5858 describe ( "Certificate expiry check" , ( ) => {
59+ let consoleLogSpy : jest . SpyInstance ;
60+
5961 beforeEach ( ( ) => {
6062 jest
6163 . useFakeTimers ( { doNotFake : [ "nextTick" ] } )
6264 . setSystemTime ( new Date ( "2025-11-03T14:19:00Z" ) ) ;
65+ consoleLogSpy = jest . spyOn ( console , "log" ) . mockImplementation ( ) ;
6366 } ) ;
6467
6568 afterEach ( ( ) => {
6669 jest . useRealTimers ( ) ;
70+ consoleLogSpy . mockRestore ( ) ;
6771 } ) ;
6872
6973 it ( "Should not log CloudWatch metric when certificate is null" , async ( ) => {
@@ -73,10 +77,7 @@ describe("Authorizer Lambda Function", () => {
7377 handler ( mockEvent , mockContext , mockCallback ) ;
7478 await new Promise ( process . nextTick ) ;
7579
76- const mockedInfo = mockedDeps . logger . info as jest . Mock ;
77- expect ( mockedInfo . mock . calls ) . not . toContainEqual (
78- expect . stringContaining ( "CloudWatchMetrics" ) ,
79- ) ;
80+ expect ( consoleLogSpy ) . not . toHaveBeenCalled ( ) ;
8081 } ) ;
8182
8283 it ( "Should log CloudWatch metric when the certificate expiry threshold is reached" , async ( ) => {
@@ -88,8 +89,7 @@ describe("Authorizer Lambda Function", () => {
8889 handler ( mockEvent , mockContext , mockCallback ) ;
8990 await new Promise ( process . nextTick ) ;
9091
91- const mockedInfo = mockedDeps . logger . info as jest . Mock ;
92- expect ( mockedInfo . mock . calls . map ( ( call ) => call [ 0 ] ) ) . toContain (
92+ expect ( consoleLogSpy ) . toHaveBeenCalledWith (
9393 JSON . stringify ( {
9494 _aws : {
9595 Timestamp : 1_762_179_540_000 ,
@@ -123,10 +123,7 @@ describe("Authorizer Lambda Function", () => {
123123 handler ( mockEvent , mockContext , mockCallback ) ;
124124 await new Promise ( process . nextTick ) ;
125125
126- const mockedInfo = mockedDeps . logger . info as jest . Mock ;
127- expect ( mockedInfo . mock . calls ) . not . toContainEqual (
128- expect . stringContaining ( "CloudWatchMetrics" ) ,
129- ) ;
126+ expect ( consoleLogSpy ) . not . toHaveBeenCalled ( ) ;
130127 } ) ;
131128 } ) ;
132129
0 commit comments