1
- import { BaseClient } from '@sentry/core' ;
2
1
import { RewriteFrames } from '@sentry/integrations' ;
3
2
import * as SentryNode from '@sentry/node' ;
4
3
import { getCurrentHub , NodeClient } from '@sentry/node' ;
@@ -17,7 +16,6 @@ const global = getGlobalObject();
17
16
( global as typeof global & { __rewriteFramesDistDir__ : string } ) . __rewriteFramesDistDir__ = '.next' ;
18
17
19
18
const nodeInit = jest . spyOn ( SentryNode , 'init' ) ;
20
- const captureEvent = jest . spyOn ( BaseClient . prototype , 'captureEvent' ) ;
21
19
const logError = jest . spyOn ( logger , 'error' ) ;
22
20
23
21
describe ( 'Server init()' , ( ) => {
@@ -91,7 +89,7 @@ describe('Server init()', () => {
91
89
expect ( currentScope . _tags . vercel ) . toBeUndefined ( ) ;
92
90
} ) ;
93
91
94
- it ( 'adds 404 transaction filter' , ( ) => {
92
+ it ( 'adds 404 transaction filter' , async ( ) => {
95
93
init ( {
96
94
dsn :
'https://[email protected] /12312012' ,
97
95
tracesSampleRate : 1.0 ,
@@ -102,8 +100,10 @@ describe('Server init()', () => {
102
100
const transaction = hub . startTransaction ( { name : '/404' } ) ;
103
101
transaction . finish ( ) ;
104
102
103
+ // We need to flush because the event processor pipeline is async whereas transaction.finish() is sync.
104
+ await SentryNode . flush ( ) ;
105
+
105
106
expect ( sendEvent ) . not . toHaveBeenCalled ( ) ;
106
- expect ( captureEvent . mock . results [ 0 ] . value ) . toBeUndefined ( ) ;
107
107
expect ( logError ) . toHaveBeenCalledWith ( new SentryError ( 'An event processor returned null, will not send event.' ) ) ;
108
108
} ) ;
109
109
0 commit comments