File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,43 @@ describe("withTelemetry", () => {
138138 } )
139139 ) . rejects . toThrow ( error ) ;
140140 } ) ;
141+
142+ describe ( "with telemetry enabled" , ( ) => {
143+ beforeEach ( ( ) => {
144+ delete process . env [ ENV_VAR ] ;
145+ } ) ;
146+
147+ test ( "propagates 4xx ApiError through enabled SDK path" , async ( ) => {
148+ const error = new ApiError ( "Not found" , 404 , "Issue not found" ) ;
149+ await expect (
150+ withTelemetry ( ( ) => {
151+ throw error ;
152+ } )
153+ ) . rejects . toThrow ( error ) ;
154+ } ) ;
155+
156+ test ( "propagates 5xx ApiError through enabled SDK path" , async ( ) => {
157+ const error = new ApiError ( "Server error" , 500 , "Internal error" ) ;
158+ await expect (
159+ withTelemetry ( ( ) => {
160+ throw error ;
161+ } )
162+ ) . rejects . toThrow ( error ) ;
163+ } ) ;
164+
165+ test ( "propagates generic Error through enabled SDK path" , async ( ) => {
166+ await expect (
167+ withTelemetry ( ( ) => {
168+ throw new Error ( "unexpected bug" ) ;
169+ } )
170+ ) . rejects . toThrow ( "unexpected bug" ) ;
171+ } ) ;
172+
173+ test ( "returns result through enabled SDK path" , async ( ) => {
174+ const result = await withTelemetry ( ( ) => 42 ) ;
175+ expect ( result ) . toBe ( 42 ) ;
176+ } ) ;
177+ } ) ;
141178} ) ;
142179
143180describe ( "isClientApiError" , ( ) => {
You can’t perform that action at this time.
0 commit comments