1- import { BaseClient } from '@sentry/core' ;
21import { RewriteFrames } from '@sentry/integrations' ;
32import * as SentryNode from '@sentry/node' ;
43import { getCurrentHub , NodeClient } from '@sentry/node' ;
@@ -17,7 +16,6 @@ const global = getGlobalObject();
1716( global as typeof global & { __rewriteFramesDistDir__ : string } ) . __rewriteFramesDistDir__ = '.next' ;
1817
1918const nodeInit = jest . spyOn ( SentryNode , 'init' ) ;
20- const captureEvent = jest . spyOn ( BaseClient . prototype , 'captureEvent' ) ;
2119const logError = jest . spyOn ( logger , 'error' ) ;
2220
2321describe ( 'Server init()' , ( ) => {
@@ -91,7 +89,7 @@ describe('Server init()', () => {
9189 expect ( currentScope . _tags . vercel ) . toBeUndefined ( ) ;
9290 } ) ;
9391
94- it ( 'adds 404 transaction filter' , ( ) => {
92+ it ( 'adds 404 transaction filter' , async ( ) => {
9593 init ( {
9694 dsn : 'https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012' ,
9795 tracesSampleRate : 1.0 ,
@@ -102,8 +100,10 @@ describe('Server init()', () => {
102100 const transaction = hub . startTransaction ( { name : '/404' } ) ;
103101 transaction . finish ( ) ;
104102
103+ // We need to flush because the event processor pipeline is async whereas transaction.finish() is sync.
104+ await SentryNode . flush ( ) ;
105+
105106 expect ( sendEvent ) . not . toHaveBeenCalled ( ) ;
106- expect ( captureEvent . mock . results [ 0 ] . value ) . toBeUndefined ( ) ;
107107 expect ( logError ) . toHaveBeenCalledWith ( new SentryError ( 'An event processor returned null, will not send event.' ) ) ;
108108 } ) ;
109109
0 commit comments