@@ -10,8 +10,8 @@ vi.mock('../../../src/logs/exports', () => ({
10
10
_INTERNAL_captureLog : vi . fn ( ) ,
11
11
} ) ) ;
12
12
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 ) ,
15
15
} ) ) ;
16
16
17
17
vi . mock ( '../../../src/currentScopes' , ( ) => ( {
@@ -33,7 +33,6 @@ describe('createConsolaReporter', () => {
33
33
} ) ;
34
34
35
35
vi . mocked ( getClient ) . mockReturnValue ( mockClient ) ;
36
- vi . mocked ( formatConsoleArgs ) . mockImplementation ( args => args . join ( ' ' ) ) ;
37
36
} ) ;
38
37
39
38
afterEach ( ( ) => {
@@ -48,37 +47,6 @@ describe('createConsolaReporter', () => {
48
47
log : expect . any ( Function ) ,
49
48
} ) ;
50
49
} ) ;
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
- } ) ;
82
50
} ) ;
83
51
84
52
describe ( 'log capturing' , ( ) => {
@@ -107,7 +75,6 @@ describe('createConsolaReporter', () => {
107
75
'consola.tag' : 'test' ,
108
76
'consola.type' : 'error' ,
109
77
'consola.level' : 0 ,
110
- 'consola.timestamp' : '2023-01-01T00:00:00.000Z' ,
111
78
} ,
112
79
} ) ;
113
80
} ) ;
@@ -232,10 +199,9 @@ describe('createConsolaReporter', () => {
232
199
233
200
sentryReporter . log ( logObj ) ;
234
201
235
- expect ( formatConsoleArgs ) . toHaveBeenCalledWith ( [ 'Message' , circular ] , 3 , 1000 ) ;
236
202
expect ( _INTERNAL_captureLog ) . toHaveBeenCalledWith ( {
237
203
level : 'info' ,
238
- message : 'Message [object Object] ' ,
204
+ message : 'Message {"self":"[Circular ~]"} ' ,
239
205
attributes : {
240
206
'sentry.origin' : 'auto.logging.consola' ,
241
207
'consola.type' : 'info' ,
@@ -290,20 +256,6 @@ describe('createConsolaReporter', () => {
290
256
} ) ;
291
257
} ) ;
292
258
} ) ;
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
- } ) ;
307
259
} ) ;
308
260
309
261
describe ( 'level filtering' , ( ) => {
0 commit comments