66 getSentry ,
77 getSentryHubWrapper ,
88} from '../src/sentry' ;
9+ import { SCRIPT_ERROR } from '../src/constants.js' ;
910
1011jest . mock ( '@sentry/browser' , ( ) => ( {
1112 BrowserClient : jest . fn ( ) ,
@@ -64,7 +65,7 @@ describe('Sentry', () => {
6465 const mockHub = {
6566 addBreadcrumb : jest . fn ( ) ,
6667 captureMessage : jest . fn ( ) ,
67- captureException : jest . fn ( ) ,
68+ captureEvent : jest . fn ( ) ,
6869 withScope : jest . fn ( callback => callback ( mockScope ) ) ,
6970 } ;
7071
@@ -79,8 +80,19 @@ describe('Sentry', () => {
7980 sentryHubWrapper . captureMessage ( 'test message' ) ;
8081 expect ( mockHub . captureMessage ) . toHaveBeenCalledWith ( 'test message' ) ;
8182
82- sentryHubWrapper . captureException ( 'test exception' ) ;
83- expect ( mockHub . captureException ) . toHaveBeenCalledWith ( 'test exception' ) ;
83+ sentryHubWrapper . captureException ( new Error ( 'test error' ) ) ;
84+ expect ( mockHub . captureEvent ) . toHaveBeenCalledWith ( {
85+ message : SCRIPT_ERROR ,
86+ level : 'error' ,
87+ extra : new Error ( 'test error' ) ,
88+ } ) ;
89+
90+ sentryHubWrapper . captureException ( 'test non error' ) ;
91+ expect ( mockHub . captureEvent ) . toHaveBeenCalledWith ( {
92+ message : SCRIPT_ERROR ,
93+ level : 'error' ,
94+ extra : 'test non error' ,
95+ } ) ;
8496 } ) ;
8597} ) ;
8698
0 commit comments