File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -98,14 +98,18 @@ export class Breadcrumbs implements Integration {
9898 if ( args [ 0 ] === false ) {
9999 breadcrumbData . message = `Assertion failed: ${ safeJoin ( args . slice ( 1 ) , ' ' ) || 'console.assert' } ` ;
100100 breadcrumbData . data . extra . arguments = normalize ( args . slice ( 1 ) , 3 ) ;
101+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
102+ input : args ,
103+ level,
104+ } ) ;
101105 }
106+ } else {
107+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
108+ input : args ,
109+ level,
110+ } ) ;
102111 }
103112
104- Breadcrumbs . addBreadcrumb ( breadcrumbData , {
105- input : args ,
106- level,
107- } ) ;
108-
109113 // this fails for some browsers. :(
110114 if ( originalConsoleLevel ) {
111115 Function . prototype . apply . call ( originalConsoleLevel , global . console , args ) ;
Original file line number Diff line number Diff line change 11console . log ( "One" ) ;
22console . warn ( "Two" , { a : 1 } ) ;
33console . error ( "Error 2" , { b : { c : [ ] } } ) ;
4+
5+ // Passed assertions _should not_ be captured
6+ console . assert ( 1 + 1 === 2 , "math works" ) ;
7+ // Failed assertions _should_ be captured
8+ console . assert ( 1 + 1 === 3 , "math broke" ) ;
9+
410function a ( ) {
511 throw new Error ( "Error thrown 3" ) ;
612}
Original file line number Diff line number Diff line change @@ -712,7 +712,7 @@ describe("breadcrumbs", function() {
712712 }
713713 ) ;
714714
715- it ( "should add breadcrumbs on thrown errors " , function ( ) {
715+ it ( "should capture console breadcrumbs " , function ( ) {
716716 return runInSandbox ( sandbox , { manual : true } , function ( ) {
717717 window . allowConsoleBreadcrumbs = true ;
718718 var logs = document . createElement ( "script" ) ;
@@ -726,8 +726,15 @@ describe("breadcrumbs", function() {
726726 // The async loader doesn't capture breadcrumbs, but we should receive the event without them
727727 assert . lengthOf ( summary . events , 1 ) ;
728728 } else {
729- assert . ok ( summary . breadcrumbs ) ;
730- assert . lengthOf ( summary . breadcrumbs , 3 ) ;
729+ if ( "assert" in console ) {
730+ assert . lengthOf ( summary . breadcrumbs , 4 ) ;
731+ assert . deepEqual ( summary . breadcrumbs [ 3 ] . data . extra . arguments , [
732+ "math broke" ,
733+ ] ) ;
734+ } else {
735+ assert . lengthOf ( summary . breadcrumbs , 3 ) ;
736+ }
737+
731738 assert . deepEqual ( summary . breadcrumbs [ 0 ] . data . extra . arguments , [ "One" ] ) ;
732739 assert . deepEqual ( summary . breadcrumbs [ 1 ] . data . extra . arguments , [
733740 "Two" ,
You can’t perform that action at this time.
0 commit comments