File tree 3 files changed +25
-8
lines changed 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 {
98
98
if ( args [ 0 ] === false ) {
99
99
breadcrumbData . message = `Assertion failed: ${ safeJoin ( args . slice ( 1 ) , ' ' ) || 'console.assert' } ` ;
100
100
breadcrumbData . data . extra . arguments = normalize ( args . slice ( 1 ) , 3 ) ;
101
+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
102
+ input : args ,
103
+ level,
104
+ } ) ;
101
105
}
106
+ } else {
107
+ Breadcrumbs . addBreadcrumb ( breadcrumbData , {
108
+ input : args ,
109
+ level,
110
+ } ) ;
102
111
}
103
112
104
- Breadcrumbs . addBreadcrumb ( breadcrumbData , {
105
- input : args ,
106
- level,
107
- } ) ;
108
-
109
113
// this fails for some browsers. :(
110
114
if ( originalConsoleLevel ) {
111
115
Function . prototype . apply . call ( originalConsoleLevel , global . console , args ) ;
Original file line number Diff line number Diff line change 1
1
console . log ( "One" ) ;
2
2
console . warn ( "Two" , { a : 1 } ) ;
3
3
console . 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
+
4
10
function a ( ) {
5
11
throw new Error ( "Error thrown 3" ) ;
6
12
}
Original file line number Diff line number Diff line change @@ -712,7 +712,7 @@ describe("breadcrumbs", function() {
712
712
}
713
713
) ;
714
714
715
- it ( "should add breadcrumbs on thrown errors " , function ( ) {
715
+ it ( "should capture console breadcrumbs " , function ( ) {
716
716
return runInSandbox ( sandbox , { manual : true } , function ( ) {
717
717
window . allowConsoleBreadcrumbs = true ;
718
718
var logs = document . createElement ( "script" ) ;
@@ -726,8 +726,15 @@ describe("breadcrumbs", function() {
726
726
// The async loader doesn't capture breadcrumbs, but we should receive the event without them
727
727
assert . lengthOf ( summary . events , 1 ) ;
728
728
} 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
+
731
738
assert . deepEqual ( summary . breadcrumbs [ 0 ] . data . extra . arguments , [ "One" ] ) ;
732
739
assert . deepEqual ( summary . breadcrumbs [ 1 ] . data . extra . arguments , [
733
740
"Two" ,
You can’t perform that action at this time.
0 commit comments