@@ -10,12 +10,8 @@ vi.mock('@sentry/core', async importOriginal => {
1010 ...( mod as any ) ,
1111 debug : { log : vi . fn ( ) } ,
1212 startSpan : vi . fn ( ) ,
13- withIsolationScope : vi . fn ( ) ,
14- getIsolationScope : vi . fn ( ) ,
15- getDefaultIsolationScope : vi . fn ( ) ,
1613 getClient : vi . fn ( ) ,
1714 httpHeadersToSpanAttributes : vi . fn ( ) ,
18- httpRequestToRequestData : vi . fn ( ) ,
1915 captureException : vi . fn ( ) ,
2016 flushIfServerless : vi . fn ( ) ,
2117 } ;
@@ -39,22 +35,13 @@ describe('wrapMiddlewareHandler', () => {
3935 end : vi . fn ( ) ,
4036 } ;
4137
42- const mockIsolationScope = {
43- clone : vi . fn ( ) . mockReturnValue ( 'cloned-scope' ) ,
44- setSDKProcessingMetadata : vi . fn ( ) ,
45- } ;
46-
4738 beforeEach ( ( ) => {
4839 vi . clearAllMocks ( ) ;
4940
5041 // Setup minimal required mocks
51- ( SentryCore . getIsolationScope as any ) . mockReturnValue ( mockIsolationScope ) ;
52- ( SentryCore . getDefaultIsolationScope as any ) . mockReturnValue ( 'default-scope' ) ;
53- ( SentryCore . withIsolationScope as any ) . mockImplementation ( ( _scope : any , callback : any ) => callback ( ) ) ;
5442 ( SentryCore . startSpan as any ) . mockImplementation ( ( _config : any , callback : any ) => callback ( mockSpan ) ) ;
5543 ( SentryCore . getClient as any ) . mockReturnValue ( { getOptions : ( ) => ( { sendDefaultPii : false } ) } ) ;
5644 ( SentryCore . httpHeadersToSpanAttributes as any ) . mockReturnValue ( { 'http.request.header.user_agent' : 'test-agent' } ) ;
57- ( SentryCore . httpRequestToRequestData as any ) . mockReturnValue ( { url : '/test-path' , method : 'GET' } ) ;
5845 ( SentryCore . flushIfServerless as any ) . mockResolvedValue ( undefined ) ;
5946 } ) ;
6047
@@ -109,7 +96,6 @@ describe('wrapMiddlewareHandler', () => {
10996
11097 // Verify Sentry APIs were called but error was not masked
11198 expect ( SentryCore . captureException ) . toHaveBeenCalledWith ( originalError , expect . any ( Object ) ) ;
112- expect ( mockSpan . recordException ) . toHaveBeenCalledWith ( originalError ) ;
11399 } ) ;
114100
115101 it ( 'should propagate sync errors without modification' , async ( ) => {
@@ -151,9 +137,6 @@ describe('wrapMiddlewareHandler', () => {
151137
152138 // This should handle the Sentry error gracefully and still call user code
153139 await expect ( wrapped ( mockEvent ) ) . rejects . toThrow ( 'Sentry API failure' ) ;
154-
155- // But user handler should still have been attempted to be called
156- // (this tests that we don't fail before reaching user code)
157140 } ) ;
158141 } ) ;
159142
@@ -169,20 +152,14 @@ describe('wrapMiddlewareHandler', () => {
169152 expect . objectContaining ( {
170153 name : 'api-middleware' ,
171154 attributes : expect . objectContaining ( {
172- [ SentryCore . SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'http.server. middleware' ,
155+ [ SentryCore . SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'middleware.nuxt ' ,
173156 'nuxt.middleware.name' : 'api-middleware' ,
174157 'http.request.method' : 'GET' ,
175158 'http.route' : '/test-path' ,
176159 } ) ,
177160 } ) ,
178161 expect . any ( Function ) ,
179162 ) ;
180-
181- expect ( SentryCore . httpRequestToRequestData ) . toHaveBeenCalledWith ( {
182- method : 'GET' ,
183- url : '/test-path' ,
184- headers : { 'user-agent' : 'test-agent' } ,
185- } ) ;
186163 } ) ;
187164
188165 it ( 'should handle missing optional data gracefully' , async ( ) => {
0 commit comments