@@ -366,6 +366,22 @@ describe('BaseClient', () => {
366
366
// `captureException` should bail right away this second time around and not get as far as calling this again
367
367
expect ( clientEventFromException ) . toHaveBeenCalledTimes ( 1 ) ;
368
368
} ) ;
369
+
370
+ test ( 'captures logger message' , ( ) => {
371
+ const logSpy = jest . spyOn ( loggerModule . logger , 'log' ) . mockImplementation ( ( ) => undefined ) ;
372
+
373
+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
374
+ const client = new TestClient ( options ) ;
375
+
376
+ client . captureException ( new Error ( 'test error here' ) ) ;
377
+ client . captureException ( { } ) ;
378
+
379
+ expect ( logSpy ) . toHaveBeenCalledTimes ( 2 ) ;
380
+ expect ( logSpy ) . toBeCalledWith ( 'Captured error event `test error here`' ) ;
381
+ expect ( logSpy ) . toBeCalledWith ( 'Captured error event `<unknown>`' ) ;
382
+
383
+ logSpy . mockRestore ( ) ;
384
+ } ) ;
369
385
} ) ;
370
386
371
387
describe ( 'captureMessage' , ( ) => {
@@ -442,6 +458,20 @@ describe('BaseClient', () => {
442
458
} ) ,
443
459
) ;
444
460
} ) ;
461
+
462
+ test ( 'captures logger message' , ( ) => {
463
+ const logSpy = jest . spyOn ( loggerModule . logger , 'log' ) . mockImplementation ( ( ) => undefined ) ;
464
+
465
+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
466
+ const client = new TestClient ( options ) ;
467
+
468
+ client . captureMessage ( 'test error here' ) ;
469
+
470
+ expect ( logSpy ) . toHaveBeenCalledTimes ( 1 ) ;
471
+ expect ( logSpy ) . toBeCalledWith ( 'Captured error event `test error here`' ) ;
472
+
473
+ logSpy . mockRestore ( ) ;
474
+ } ) ;
445
475
} ) ;
446
476
447
477
describe ( 'captureEvent() / prepareEvent()' , ( ) => {
@@ -1658,6 +1688,22 @@ describe('BaseClient', () => {
1658
1688
message : 'hello' ,
1659
1689
} ) ;
1660
1690
} ) ;
1691
+
1692
+ test ( 'captures logger message' , ( ) => {
1693
+ const logSpy = jest . spyOn ( loggerModule . logger , 'log' ) . mockImplementation ( ( ) => undefined ) ;
1694
+
1695
+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
1696
+ const client = new TestClient ( options ) ;
1697
+
1698
+ client . captureEvent ( { message : 'hello' } ) ;
1699
+ // transactions are ignored and not logged
1700
+ client . captureEvent ( { type : 'transaction' , message : 'hello 2' } ) ;
1701
+
1702
+ expect ( logSpy ) . toHaveBeenCalledTimes ( 1 ) ;
1703
+ expect ( logSpy ) . toBeCalledWith ( 'Captured error event `hello`' ) ;
1704
+
1705
+ logSpy . mockRestore ( ) ;
1706
+ } ) ;
1661
1707
} ) ;
1662
1708
1663
1709
describe ( 'integrations' , ( ) => {
0 commit comments