@@ -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()' , ( ) => {
@@ -1651,6 +1681,22 @@ describe('BaseClient', () => {
1651
1681
message : 'hello' ,
1652
1682
} ) ;
1653
1683
} ) ;
1684
+
1685
+ test ( 'captures logger message' , ( ) => {
1686
+ const logSpy = jest . spyOn ( loggerModule . logger , 'log' ) . mockImplementation ( ( ) => undefined ) ;
1687
+
1688
+ const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
1689
+ const client = new TestClient ( options ) ;
1690
+
1691
+ client . captureEvent ( { message : 'hello' } ) ;
1692
+ // transactions are ignored and not logged
1693
+ client . captureEvent ( { type : 'transaction' , message : 'hello 2' } ) ;
1694
+
1695
+ expect ( logSpy ) . toHaveBeenCalledTimes ( 1 ) ;
1696
+ expect ( logSpy ) . toBeCalledWith ( 'Captured error event `hello`' ) ;
1697
+
1698
+ logSpy . mockRestore ( ) ;
1699
+ } ) ;
1654
1700
} ) ;
1655
1701
1656
1702
describe ( 'integrations' , ( ) => {
0 commit comments