@@ -10,8 +10,8 @@ vi.mock('../../../src/logs/exports', () => ({
1010 _INTERNAL_captureLog : vi . fn ( ) ,
1111} ) ) ;
1212
13- vi . mock ( '../../../src/logs/utils' , ( ) => ( {
14- formatConsoleArgs : vi . fn ( ) ,
13+ vi . mock ( '../../../src/logs/utils' , async actual => ( {
14+ formatConsoleArgs : vi . fn ( ( ( await actual ( ) ) as any ) . formatConsoleArgs ) ,
1515} ) ) ;
1616
1717vi . mock ( '../../../src/currentScopes' , ( ) => ( {
@@ -33,7 +33,6 @@ describe('createConsolaReporter', () => {
3333 } ) ;
3434
3535 vi . mocked ( getClient ) . mockReturnValue ( mockClient ) ;
36- vi . mocked ( formatConsoleArgs ) . mockImplementation ( args => args . join ( ' ' ) ) ;
3736 } ) ;
3837
3938 afterEach ( ( ) => {
@@ -48,37 +47,6 @@ describe('createConsolaReporter', () => {
4847 log : expect . any ( Function ) ,
4948 } ) ;
5049 } ) ;
51-
52- it ( 'should use provided client for normalization options' , ( ) => {
53- const customClient = new TestClient ( {
54- ...getDefaultTestClientOptions ( { dsn : 'https://custom@domain/123' } ) ,
55- enableLogs : true ,
56- normalizeDepth : 5 ,
57- normalizeMaxBreadth : 2000 ,
58- } ) ;
59-
60- const reporter = createConsolaReporter ( { client : customClient } ) ;
61-
62- reporter . log ( {
63- type : 'info' ,
64- args : [ 'test' , { complex : 'object' } ] ,
65- } ) ;
66-
67- expect ( formatConsoleArgs ) . toHaveBeenCalledWith ( [ 'test' , { complex : 'object' } ] , 5 , 2000 ) ;
68- } ) ;
69-
70- it ( 'should not capture logs when no client is available' , ( ) => {
71- vi . mocked ( getClient ) . mockReturnValue ( undefined ) ;
72-
73- const reporter = createConsolaReporter ( ) ;
74-
75- reporter . log ( {
76- type : 'error' ,
77- message : 'Should not be captured' ,
78- } ) ;
79-
80- expect ( _INTERNAL_captureLog ) . not . toHaveBeenCalled ( ) ;
81- } ) ;
8250 } ) ;
8351
8452 describe ( 'log capturing' , ( ) => {
@@ -107,7 +75,6 @@ describe('createConsolaReporter', () => {
10775 'consola.tag' : 'test' ,
10876 'consola.type' : 'error' ,
10977 'consola.level' : 0 ,
110- 'consola.timestamp' : '2023-01-01T00:00:00.000Z' ,
11178 } ,
11279 } ) ;
11380 } ) ;
@@ -232,10 +199,9 @@ describe('createConsolaReporter', () => {
232199
233200 sentryReporter . log ( logObj ) ;
234201
235- expect ( formatConsoleArgs ) . toHaveBeenCalledWith ( [ 'Message' , circular ] , 3 , 1000 ) ;
236202 expect ( _INTERNAL_captureLog ) . toHaveBeenCalledWith ( {
237203 level : 'info' ,
238- message : 'Message [object Object] ' ,
204+ message : 'Message {"self":"[Circular ~]"} ' ,
239205 attributes : {
240206 'sentry.origin' : 'auto.logging.consola' ,
241207 'consola.type' : 'info' ,
@@ -290,20 +256,6 @@ describe('createConsolaReporter', () => {
290256 } ) ;
291257 } ) ;
292258 } ) ;
293-
294- it ( 'should handle errors in reporter gracefully' , ( ) => {
295- vi . mocked ( _INTERNAL_captureLog ) . mockImplementation ( ( ) => {
296- throw new Error ( 'Capture error' ) ;
297- } ) ;
298-
299- // Should not throw
300- expect ( ( ) => {
301- sentryReporter . log ( {
302- type : 'error' ,
303- message : 'Test message' ,
304- } ) ;
305- } ) . not . toThrow ( ) ;
306- } ) ;
307259 } ) ;
308260
309261 describe ( 'level filtering' , ( ) => {
0 commit comments