@@ -143,40 +143,36 @@ describe('integration', function() {
143143 ) ;
144144 } ) ;
145145
146- it ( 'should reject duplicate, back-to-back errors from captureError ' , function ( done ) {
146+ it ( 'should reject duplicate, back-to-back errors from captureException ' , function ( done ) {
147147 var iframe = this . iframe ;
148148 iframeExecute (
149149 iframe ,
150150 done ,
151151 function ( ) {
152- var count = 5 ;
153- setTimeout ( function invoke ( ) {
154- // use setTimeout to capture new error objects that have
155- // identical stack traces (can't call sequentially or callsite
156- // line number will change)
157- //
158- // order:
159- // Error: foo
160- // Error: foo (suppressed)
161- // Error: foo (suppressed)
162- // Error: bar
163- // Error: foo
164- if ( count === 2 ) {
165- Sentry . captureException ( new Error ( 'bar' ) ) ;
166- } else {
167- Sentry . captureException ( new Error ( 'foo' ) ) ;
168- }
152+ setTimeout ( done ) ;
169153
170- if ( -- count === 0 ) return setTimeout ( done ) ;
171- else setTimeout ( invoke ) ;
172- } ) ;
154+ for ( var i = 0 ; i < 2 ; i ++ ) {
155+ // Different exceptions, don't dedupe
156+ Sentry . captureException ( new Error ( `Exception no ${ Date . now ( ) } ` ) ) ;
157+ }
158+
159+ for ( var i = 0 ; i < 2 ; i ++ ) {
160+ // Same exception, dedupe
161+ Sentry . captureException ( new Error ( 'foo' ) ) ;
162+ }
163+
164+ // Same exceptions, different stacktrace (different line number), don't dedupe
165+ Sentry . captureException ( new Error ( 'bar' ) ) ;
166+ Sentry . captureException ( new Error ( 'bar' ) ) ;
173167 } ,
174168 function ( ) {
175169 var sentryData = iframe . contentWindow . sentryData ;
176- assert . equal ( sentryData . length , 3 ) ;
177- assert . equal ( sentryData [ 0 ] . exception . values [ 0 ] . value , 'foo' ) ;
178- assert . equal ( sentryData [ 1 ] . exception . values [ 0 ] . value , 'bar' ) ;
170+ assert . equal ( sentryData . length , 5 ) ;
171+ assert . match ( sentryData [ 0 ] . exception . values [ 0 ] . value , / E x c e p t i o n n o \d + / ) ;
172+ assert . match ( sentryData [ 1 ] . exception . values [ 0 ] . value , / E x c e p t i o n n o \d + / ) ;
179173 assert . equal ( sentryData [ 2 ] . exception . values [ 0 ] . value , 'foo' ) ;
174+ assert . equal ( sentryData [ 3 ] . exception . values [ 0 ] . value , 'bar' ) ;
175+ assert . equal ( sentryData [ 4 ] . exception . values [ 0 ] . value , 'bar' ) ;
180176 } ,
181177 ) ;
182178 } ) ;
0 commit comments