@@ -2,6 +2,7 @@ import { mkdirSync, rmdirSync, unlinkSync, writeFileSync } from 'fs';
22import * as path from 'path' ;
33import { afterAll , beforeAll , describe , expect , test } from 'vitest' ;
44import { cleanupChildProcesses , createRunner } from '../../../utils/runner' ;
5+ import { RUNTIME } from '../../../utils' ;
56
67const EXPECTED_LOCAL_VARIABLES_EVENT = {
78 exception : {
@@ -79,14 +80,15 @@ module.exports = { out_of_app_function };`,
7980 . completed ( ) ;
8081 } ) ;
8182
82- test ( 'Should include local variables when enabled' , async ( ) => {
83+ // Bun and Deno: the error events have no local variables.
84+ test . skipIf ( RUNTIME !== 'node' ) ( 'Should include local variables when enabled' , async ( ) => {
8385 await createRunner ( __dirname , 'local-variables.js' )
8486 . expect ( { event : EXPECTED_LOCAL_VARIABLES_EVENT } )
8587 . start ( )
8688 . completed ( ) ;
8789 } ) ;
8890
89- test ( 'Should include local variables when instrumenting via --import' , async ( ) => {
91+ test . skipIf ( RUNTIME !== 'node' ) ( 'Should include local variables when instrumenting via --import' , async ( ) => {
9092 const instrumentPath = path . resolve ( __dirname , 'local-variables-instrument.cjs' ) ;
9193
9294 await createRunner ( __dirname , 'local-variables-no-sentry.js' )
@@ -96,7 +98,7 @@ module.exports = { out_of_app_function };`,
9698 . completed ( ) ;
9799 } ) ;
98100
99- test ( 'Should include local variables with ESM' , async ( ) => {
101+ test . skipIf ( RUNTIME !== 'node' ) ( 'Should include local variables with ESM' , async ( ) => {
100102 await createRunner ( __dirname , 'local-variables-caught.mjs' )
101103 . expect ( { event : EXPECTED_LOCAL_VARIABLES_EVENT } )
102104 . start ( )
@@ -107,36 +109,39 @@ module.exports = { out_of_app_function };`,
107109 await createRunner ( __dirname , 'deny-inspector.mjs' ) . ensureNoErrorOutput ( ) . start ( ) . completed ( ) ;
108110 } ) ;
109111
110- test ( 'Should retain original local variables when error is re-thrown' , async ( ) => {
112+ test . skipIf ( RUNTIME !== 'node' ) ( 'Should retain original local variables when error is re-thrown' , async ( ) => {
111113 await createRunner ( __dirname , 'local-variables-rethrow.js' )
112114 . expect ( { event : EXPECTED_LOCAL_VARIABLES_EVENT } )
113115 . start ( )
114116 . completed ( ) ;
115117 } ) ;
116118
117- test ( 'Includes local variables for caught exceptions when enabled' , async ( ) => {
119+ test . skipIf ( RUNTIME !== 'node' ) ( 'Includes local variables for caught exceptions when enabled' , async ( ) => {
118120 await createRunner ( __dirname , 'local-variables-caught.js' )
119121 . expect ( { event : EXPECTED_LOCAL_VARIABLES_EVENT } )
120122 . start ( )
121123 . completed ( ) ;
122124 } ) ;
123125
124- test ( 'Filters local variables by name via dataCollection.stackFrameVariables' , async ( ) => {
125- await createRunner ( __dirname , 'local-variables-filtered.js' )
126- . expect ( {
127- event : event => {
128- const frame = event . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. find ( frame => frame . function === 'one' ) ;
129-
130- expect ( frame ?. vars ) . toEqual ( {
131- name : 'some name' ,
132- keepVar : 'keep me' ,
133- secretVar : '[Filtered]' ,
134- } ) ;
135- } ,
136- } )
137- . start ( )
138- . completed ( ) ;
139- } ) ;
126+ test . skipIf ( RUNTIME !== 'node' ) (
127+ 'Filters local variables by name via dataCollection.stackFrameVariables' ,
128+ async ( ) => {
129+ await createRunner ( __dirname , 'local-variables-filtered.js' )
130+ . expect ( {
131+ event : event => {
132+ const frame = event . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames ?. find ( frame => frame . function === 'one' ) ;
133+
134+ expect ( frame ?. vars ) . toEqual ( {
135+ name : 'some name' ,
136+ keepVar : 'keep me' ,
137+ secretVar : '[Filtered]' ,
138+ } ) ;
139+ } ,
140+ } )
141+ . start ( )
142+ . completed ( ) ;
143+ } ,
144+ ) ;
140145
141146 test ( 'Does not attach local variables when dataCollection.stackFrameVariables is false' , async ( ) => {
142147 await createRunner ( __dirname , 'local-variables-disabled.js' )
@@ -151,7 +156,7 @@ module.exports = { out_of_app_function };`,
151156 . completed ( ) ;
152157 } ) ;
153158
154- test ( 'Should handle different function name formats' , async ( ) => {
159+ test . skipIf ( RUNTIME !== 'node' ) ( 'Should handle different function name formats' , async ( ) => {
155160 await createRunner ( __dirname , 'local-variables-name-matching.js' )
156161 . expect ( {
157162 event : {
@@ -177,30 +182,33 @@ module.exports = { out_of_app_function };`,
177182 . completed ( ) ;
178183 } ) ;
179184
180- test ( 'adds local variables to out of app frames when includeOutOfAppFrames is true' , async ( ) => {
181- await createRunner ( __dirname , 'local-variables-out-of-app.js' )
182- . expect ( {
183- event : event => {
184- const frames = event . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames || [ ] ;
185-
186- const inAppFrame = frames . find ( frame => frame . function === 'in_app_function' ) ;
187- const outOfAppFrame = frames . find ( frame => frame . function === 'out_of_app_function' ) ;
188-
189- expect ( inAppFrame ?. vars ) . toEqual ( { inAppVar : 'in app value' } ) ;
190- expect ( inAppFrame ?. in_app ) . toEqual ( true ) ;
191-
192- expect ( outOfAppFrame ?. vars ) . toEqual ( {
193- outOfAppVar : 'out of app value modified value' ,
194- passedArg : 'in app value modified value' ,
195- } ) ;
196- expect ( outOfAppFrame ?. in_app ) . toEqual ( false ) ;
197- } ,
198- } )
199- . start ( )
200- . completed ( ) ;
201- } ) ;
185+ test . skipIf ( RUNTIME !== 'node' ) (
186+ 'adds local variables to out of app frames when includeOutOfAppFrames is true' ,
187+ async ( ) => {
188+ await createRunner ( __dirname , 'local-variables-out-of-app.js' )
189+ . expect ( {
190+ event : event => {
191+ const frames = event . exception ?. values ?. [ 0 ] ?. stacktrace ?. frames || [ ] ;
192+
193+ const inAppFrame = frames . find ( frame => frame . function === 'in_app_function' ) ;
194+ const outOfAppFrame = frames . find ( frame => frame . function === 'out_of_app_function' ) ;
195+
196+ expect ( inAppFrame ?. vars ) . toEqual ( { inAppVar : 'in app value' } ) ;
197+ expect ( inAppFrame ?. in_app ) . toEqual ( true ) ;
198+
199+ expect ( outOfAppFrame ?. vars ) . toEqual ( {
200+ outOfAppVar : 'out of app value modified value' ,
201+ passedArg : 'in app value modified value' ,
202+ } ) ;
203+ expect ( outOfAppFrame ?. in_app ) . toEqual ( false ) ;
204+ } ,
205+ } )
206+ . start ( )
207+ . completed ( ) ;
208+ } ,
209+ ) ;
202210
203- test ( 'does not add local variables to out of app frames by default' , async ( ) => {
211+ test . skipIf ( RUNTIME !== 'node' ) ( 'does not add local variables to out of app frames by default' , async ( ) => {
204212 await createRunner ( __dirname , 'local-variables-out-of-app-default.js' )
205213 . expect ( {
206214 event : event => {
0 commit comments