@@ -305,9 +305,12 @@ describe('Flexible Breadcrumbs System', () => {
305305
306306 describe ( 'Error Handling' , ( ) => {
307307 it ( 'should handle transformer errors gracefully with debug enabled' , async ( ) => {
308- const consoleSpy = vi
308+ const errorSpy = vi
309309 . spyOn ( console , 'error' )
310310 . mockImplementation ( ( ) => { } ) ;
311+ const warnSpy = vi
312+ . spyOn ( console , 'warn' )
313+ . mockImplementation ( ( ) => { } ) ;
311314
312315 function testFunction ( data : string ) {
313316 throw new Error ( 'test' ) ;
@@ -325,20 +328,28 @@ describe('Flexible Breadcrumbs System', () => {
325328 ] )
326329 . value ( ) ;
327330
328- expect ( consoleSpy ) . toHaveBeenCalledWith (
331+ expect ( warnSpy ) . toHaveBeenCalledWith (
332+ '[try-catch] breadcrumb transformer threw; breadcrumb dropped:' ,
333+ expect . any ( Error ) ,
334+ ) ;
335+ expect ( errorSpy ) . toHaveBeenCalledWith (
329336 'Error in breadcrumb transformer:' ,
330337 expect . any ( Error ) ,
331338 ) ;
332339 // Transformer error yields empty data — reporter call is short-circuited.
333340 expect ( Sentry . addBreadcrumb ) . not . toHaveBeenCalled ( ) ;
334341
335- consoleSpy . mockRestore ( ) ;
342+ errorSpy . mockRestore ( ) ;
343+ warnSpy . mockRestore ( ) ;
336344 } ) ;
337345
338- it ( 'should handle transformer errors gracefully with debug disabled' , async ( ) => {
339- const consoleSpy = vi
346+ it ( 'should always warn on transformer errors even with debug disabled' , async ( ) => {
347+ const errorSpy = vi
340348 . spyOn ( console , 'error' )
341349 . mockImplementation ( ( ) => { } ) ;
350+ const warnSpy = vi
351+ . spyOn ( console , 'warn' )
352+ . mockImplementation ( ( ) => { } ) ;
342353
343354 function testFunction ( data : string ) {
344355 throw new Error ( 'test' ) ;
@@ -355,17 +366,25 @@ describe('Flexible Breadcrumbs System', () => {
355366 ] )
356367 . value ( ) ;
357368
358- expect ( consoleSpy ) . not . toHaveBeenCalled ( ) ;
369+ expect ( warnSpy ) . toHaveBeenCalledWith (
370+ '[try-catch] breadcrumb transformer threw; breadcrumb dropped:' ,
371+ expect . any ( Error ) ,
372+ ) ;
373+ expect ( errorSpy ) . not . toHaveBeenCalled ( ) ;
359374 // Transformer error yields empty data — reporter call is short-circuited.
360375 expect ( Sentry . addBreadcrumb ) . not . toHaveBeenCalled ( ) ;
361376
362- consoleSpy . mockRestore ( ) ;
377+ errorSpy . mockRestore ( ) ;
378+ warnSpy . mockRestore ( ) ;
363379 } ) ;
364380
365381 it ( 'should handle predefined transformer errors gracefully' , async ( ) => {
366- const consoleSpy = vi
382+ const errorSpy = vi
367383 . spyOn ( console , 'error' )
368384 . mockImplementation ( ( ) => { } ) ;
385+ const warnSpy = vi
386+ . spyOn ( console , 'warn' )
387+ . mockImplementation ( ( ) => { } ) ;
369388
370389 function testFunction ( data : any ) {
371390 throw new Error ( 'test' ) ;
@@ -382,11 +401,16 @@ describe('Flexible Breadcrumbs System', () => {
382401 . breadcrumbs ( [ { param : 0 , as : 'toString' } ] )
383402 . value ( ) ;
384403
385- expect ( consoleSpy ) . toHaveBeenCalledWith (
404+ expect ( warnSpy ) . toHaveBeenCalledWith (
405+ '[try-catch] predefined breadcrumb transformer threw; breadcrumb dropped:' ,
406+ expect . any ( Error ) ,
407+ ) ;
408+ expect ( errorSpy ) . toHaveBeenCalledWith (
386409 'Error in predefined transformer:' ,
387410 expect . any ( Error ) ,
388411 ) ;
389- consoleSpy . mockRestore ( ) ;
412+ errorSpy . mockRestore ( ) ;
413+ warnSpy . mockRestore ( ) ;
390414 } ) ;
391415
392416 it ( 'should handle non-object parameters for key extraction gracefully' , async ( ) => {
0 commit comments