@@ -3,22 +3,16 @@ import * as React from 'react';
33
44import { ErrorBoundary , ErrorBoundaryProps , FALLBACK_ERR_MESSAGE } from '../src/errorboundary' ;
55
6- const mockSetExtra = jest . fn ( ) ;
76const mockCaptureException = jest . fn ( ) ;
87const mockShowReportDialog = jest . fn ( ) ;
98
109jest . mock ( '@sentry/browser' , ( ) => ( {
11- captureException : ( err : any ) => {
12- mockCaptureException ( err ) ;
10+ captureException : ( err : any , ctx : any ) => {
11+ mockCaptureException ( err , ctx ) ;
1312 } ,
1413 showReportDialog : ( options : any ) => {
1514 mockShowReportDialog ( options ) ;
1615 } ,
17- withScope : ( callback : Function ) => {
18- callback ( {
19- setExtra : mockSetExtra ,
20- } ) ;
21- } ,
2216} ) ) ;
2317
2418const TestApp : React . FC < ErrorBoundaryProps > = ( { children, ...props } ) => {
@@ -45,7 +39,6 @@ describe('ErrorBoundary', () => {
4539
4640 afterEach ( ( ) => {
4741 consoleErrorSpy . mockClear ( ) ;
48- mockSetExtra . mockClear ( ) ;
4942 mockCaptureException . mockClear ( ) ;
5043 mockShowReportDialog . mockClear ( ) ;
5144 } ) ;
@@ -179,7 +172,6 @@ describe('ErrorBoundary', () => {
179172
180173 expect ( mockOnError ) . toHaveBeenCalledTimes ( 0 ) ;
181174 expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 0 ) ;
182- expect ( mockSetExtra ) . toHaveBeenCalledTimes ( 0 ) ;
183175
184176 const btn = screen . getByTestId ( 'errorBtn' ) ;
185177 fireEvent . click ( btn ) ;
@@ -188,10 +180,9 @@ describe('ErrorBoundary', () => {
188180 expect ( mockOnError ) . toHaveBeenCalledWith ( expect . any ( Error ) , expect . any ( String ) ) ;
189181
190182 expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 1 ) ;
191- expect ( mockCaptureException ) . toHaveBeenCalledWith ( expect . any ( Error ) ) ;
192-
193- expect ( mockSetExtra ) . toHaveBeenCalledTimes ( 1 ) ;
194- expect ( mockSetExtra ) . toHaveBeenCalledWith ( 'componentStack' , expect . any ( String ) ) ;
183+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( expect . any ( Error ) , {
184+ contexts : { componentStack : expect . any ( String ) } ,
185+ } ) ;
195186 } ) ;
196187
197188 it ( 'shows a Sentry Report Dialog with correct options' , ( ) => {
0 commit comments