@@ -8,6 +8,11 @@ vi.mock('@sentry/core', () => ({
8
8
flushIfServerless : vi . fn ( ) . mockResolvedValue ( undefined ) ,
9
9
} ) ) ;
10
10
11
+ const mechanism = {
12
+ handled : false ,
13
+ type : 'react-router' ,
14
+ } ;
15
+
11
16
describe ( 'createSentryHandleError' , ( ) => {
12
17
const mockCaptureException = vi . mocked ( core . captureException ) ;
13
18
const mockFlushIfServerless = vi . mocked ( core . flushIfServerless ) ;
@@ -50,7 +55,7 @@ describe('createSentryHandleError', () => {
50
55
51
56
await handleError ( mockError , mockArgs ) ;
52
57
53
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
58
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
54
59
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
55
60
expect ( mockConsoleError ) . not . toHaveBeenCalled ( ) ;
56
61
} ) ;
@@ -74,7 +79,7 @@ describe('createSentryHandleError', () => {
74
79
75
80
await handleError ( mockError , mockArgs ) ;
76
81
77
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
82
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
78
83
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
79
84
expect ( mockConsoleError ) . toHaveBeenCalledWith ( mockError ) ;
80
85
} ) ;
@@ -98,7 +103,7 @@ describe('createSentryHandleError', () => {
98
103
99
104
await handleError ( mockError , mockArgs ) ;
100
105
101
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
106
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
102
107
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
103
108
expect ( mockConsoleError ) . not . toHaveBeenCalled ( ) ;
104
109
} ) ;
@@ -112,7 +117,7 @@ describe('createSentryHandleError', () => {
112
117
113
118
await handleError ( stringError , mockArgs ) ;
114
119
115
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( stringError ) ;
120
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( stringError , { mechanism } ) ;
116
121
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
117
122
} ) ;
118
123
@@ -122,7 +127,7 @@ describe('createSentryHandleError', () => {
122
127
123
128
await handleError ( null , mockArgs ) ;
124
129
125
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( null ) ;
130
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( null , { mechanism } ) ;
126
131
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
127
132
} ) ;
128
133
@@ -133,7 +138,7 @@ describe('createSentryHandleError', () => {
133
138
134
139
await handleError ( customError , mockArgs ) ;
135
140
136
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( customError ) ;
141
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( customError , { mechanism } ) ;
137
142
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
138
143
} ) ;
139
144
} ) ;
@@ -145,7 +150,7 @@ describe('createSentryHandleError', () => {
145
150
146
151
await handleError ( mockError , mockArgs ) ;
147
152
148
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
153
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
149
154
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
150
155
expect ( mockConsoleError ) . toHaveBeenCalledWith ( mockError ) ;
151
156
} ) ;
@@ -177,7 +182,7 @@ describe('createSentryHandleError', () => {
177
182
await handleErrorPromise ;
178
183
const endTime = Date . now ( ) ;
179
184
180
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
185
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
181
186
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
182
187
expect ( endTime - startTime ) . toBeGreaterThanOrEqual ( 10 ) ;
183
188
} ) ;
@@ -193,7 +198,7 @@ describe('createSentryHandleError', () => {
193
198
// This should not throw
194
199
await expect ( handleError ( mockError , mockArgs ) ) . resolves . toBeUndefined ( ) ;
195
200
196
- expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError ) ;
201
+ expect ( mockCaptureException ) . toHaveBeenCalledWith ( mockError , { mechanism } ) ;
197
202
expect ( mockFlushIfServerless ) . toHaveBeenCalled ( ) ;
198
203
} ) ;
199
204
} ) ;
0 commit comments