@@ -3,22 +3,16 @@ import * as React from 'react';
3
3
4
4
import { ErrorBoundary , ErrorBoundaryProps , FALLBACK_ERR_MESSAGE } from '../src/errorboundary' ;
5
5
6
- const mockSetExtra = jest . fn ( ) ;
7
6
const mockCaptureException = jest . fn ( ) ;
8
7
const mockShowReportDialog = jest . fn ( ) ;
9
8
10
9
jest . mock ( '@sentry/browser' , ( ) => ( {
11
- captureException : ( err : any ) => {
12
- mockCaptureException ( err ) ;
10
+ captureException : ( err : any , ctx : any ) => {
11
+ mockCaptureException ( err , ctx ) ;
13
12
} ,
14
13
showReportDialog : ( options : any ) => {
15
14
mockShowReportDialog ( options ) ;
16
15
} ,
17
- withScope : ( callback : Function ) => {
18
- callback ( {
19
- setExtra : mockSetExtra ,
20
- } ) ;
21
- } ,
22
16
} ) ) ;
23
17
24
18
const TestApp : React . FC < ErrorBoundaryProps > = ( { children, ...props } ) => {
@@ -45,7 +39,6 @@ describe('ErrorBoundary', () => {
45
39
46
40
afterEach ( ( ) => {
47
41
consoleErrorSpy . mockClear ( ) ;
48
- mockSetExtra . mockClear ( ) ;
49
42
mockCaptureException . mockClear ( ) ;
50
43
mockShowReportDialog . mockClear ( ) ;
51
44
} ) ;
@@ -179,7 +172,6 @@ describe('ErrorBoundary', () => {
179
172
180
173
expect ( mockOnError ) . toHaveBeenCalledTimes ( 0 ) ;
181
174
expect ( mockCaptureException ) . toHaveBeenCalledTimes ( 0 ) ;
182
- expect ( mockSetExtra ) . toHaveBeenCalledTimes ( 0 ) ;
183
175
184
176
const btn = screen . getByTestId ( 'errorBtn' ) ;
185
177
fireEvent . click ( btn ) ;
@@ -188,10 +180,9 @@ describe('ErrorBoundary', () => {
188
180
expect ( mockOnError ) . toHaveBeenCalledWith ( expect . any ( Error ) , expect . any ( String ) ) ;
189
181
190
182
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
+ } ) ;
195
186
} ) ;
196
187
197
188
it ( 'shows a Sentry Report Dialog with correct options' , ( ) => {
0 commit comments