@@ -175,24 +175,24 @@ describe('SentryNode', () => {
175175 }
176176 } ) ;
177177
178- test ( 'capture an exception with pre/post context' , done => {
179- expect . assertions ( 10 ) ;
178+ test ( 'capture an exception with pre/post context' , async ( ) => {
179+ const beforeSend = jest . fn ( ( event : Event ) => {
180+ expect ( event . tags ) . toEqual ( { test : '1' } ) ;
181+ expect ( event . exception ) . not . toBeUndefined ( ) ;
182+ expect ( event . exception ! . values ! [ 0 ] ) . not . toBeUndefined ( ) ;
183+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! ) . not . toBeUndefined ( ) ;
184+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] ) . not . toBeUndefined ( ) ;
185+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . pre_context ) . not . toBeUndefined ( ) ;
186+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . post_context ) . not . toBeUndefined ( ) ;
187+ expect ( event . exception ! . values ! [ 0 ] . type ) . toBe ( 'Error' ) ;
188+ expect ( event . exception ! . values ! [ 0 ] . value ) . toBe ( 'test' ) ;
189+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ) . toBeTruthy ( ) ;
190+ return null ;
191+ } ) ;
192+
180193 const options = getDefaultNodeClientOptions ( {
181194 stackParser : defaultStackParser ,
182- beforeSend : ( event : Event ) => {
183- expect ( event . tags ) . toEqual ( { test : '1' } ) ;
184- expect ( event . exception ) . not . toBeUndefined ( ) ;
185- expect ( event . exception ! . values ! [ 0 ] ) . not . toBeUndefined ( ) ;
186- expect ( event . exception ! . values ! [ 0 ] . stacktrace ! ) . not . toBeUndefined ( ) ;
187- expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] ) . not . toBeUndefined ( ) ;
188- expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . pre_context ) . not . toBeUndefined ( ) ;
189- expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . post_context ) . not . toBeUndefined ( ) ;
190- expect ( event . exception ! . values ! [ 0 ] . type ) . toBe ( 'Error' ) ;
191- expect ( event . exception ! . values ! [ 0 ] . value ) . toBe ( 'test' ) ;
192- expect ( event . exception ! . values ! [ 0 ] . stacktrace ) . toBeTruthy ( ) ;
193- done ( ) ;
194- return null ;
195- } ,
195+ beforeSend,
196196 dsn,
197197 integrations : [ new ContextLines ( ) ] ,
198198 } ) ;
@@ -207,7 +207,9 @@ describe('SentryNode', () => {
207207 captureException ( e ) ;
208208 }
209209
210- void client . flush ( ) ;
210+ await client . flush ( ) ;
211+
212+ expect ( beforeSend ) . toHaveBeenCalledTimes ( 1 ) ;
211213 } ) ;
212214
213215 test ( 'capture a linked exception with pre/post context' , done => {
0 commit comments