@@ -2059,28 +2059,48 @@ describe('Raven (public API)', function() {
2059
2059
} ) ;
2060
2060
} ) ;
2061
2061
2062
- it ( 'should include a synthetic stacktrace if stacktrace:true is passed' , function ( ) {
2063
- this . sinon . stub ( Raven , 'isSetup' ) . returns ( true ) ;
2064
- this . sinon . stub ( Raven , '_send' ) ;
2065
2062
2066
- function foo ( ) {
2067
- Raven . captureMessage ( 'foo' , {
2068
- stacktrace : true
2069
- } ) ;
2063
+ describe ( 'synthetic traces' , function ( ) {
2064
+ function assertSynthetic ( frames ) {
2065
+ // Raven.captureMessage
2066
+ var last = frames [ frames . length - 1 ] ;
2067
+ assert . isTrue ( / ( c a p t u r e M e s s a g e | ^ \? ) $ / . test ( last . function ) ) ; // loose equality check because differs per-browser
2068
+ assert . equal ( last . in_app , false ) ;
2069
+
2070
+ // foo
2071
+ var secondLast = frames [ frames . length - 2 ] ;
2072
+ assert . equal ( secondLast . function , 'foo' ) ;
2073
+ assert . equal ( secondLast . in_app , true ) ;
2070
2074
}
2071
2075
2072
- foo ( ) ;
2073
- var frames = Raven . _send . lastCall . args [ 0 ] . stacktrace . frames ;
2076
+ it ( 'should get collected if stacktrace:true is passed via options' , function ( ) {
2077
+ this . sinon . stub ( Raven , 'isSetup' ) . returns ( true ) ;
2078
+ this . sinon . stub ( Raven , '_send' ) ;
2079
+
2080
+ function foo ( ) {
2081
+ Raven . captureMessage ( 'foo' , {
2082
+ stacktrace : true
2083
+ } ) ;
2084
+ }
2085
+
2086
+ foo ( ) ;
2087
+ var frames = Raven . _send . lastCall . args [ 0 ] . stacktrace . frames ;
2088
+ assertSynthetic ( frames ) ;
2089
+ } ) ;
2090
+
2091
+ it ( 'should get collected if stacktrace:true is set via globalOptions' , function ( ) {
2092
+ this . sinon . stub ( Raven , 'isSetup' ) . returns ( true ) ;
2093
+ this . sinon . stub ( Raven , '_send' ) ;
2074
2094
2075
- // Raven.captureMessage
2076
- var last = frames [ frames . length - 1 ] ;
2077
- assert . isTrue ( / ( c a p t u r e M e s s a g e | ^ \? ) $ / . test ( last . function ) ) ; // loose equality check because differs per-browser
2078
- assert . equal ( last . in_app , false ) ;
2095
+ Raven . _globalOptions . stacktrace = true ;
2096
+ function foo ( ) {
2097
+ Raven . captureMessage ( 'foo' ) ;
2098
+ }
2079
2099
2080
- // foo
2081
- var secondLast = frames [ frames . length - 2 ] ;
2082
- assert . equal ( secondLast . function , 'foo' ) ;
2083
- assert . equal ( secondLast . in_app , true ) ;
2100
+ foo ( ) ;
2101
+ var frames = Raven . _send . lastCall . args [ 0 ] . stacktrace . frames ;
2102
+ assertSynthetic ( frames ) ;
2103
+ } ) ;
2084
2104
} ) ;
2085
2105
} ) ;
2086
2106
0 commit comments