File tree 2 files changed +18
-8
lines changed
dev-packages/node-integration-tests/utils
packages/node/src/integrations/hapi
2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ export function createRunner(...paths: string[]) {
126
126
let withSentryServer = false ;
127
127
let dockerOptions : DockerOptions | undefined ;
128
128
let ensureNoErrorOutput = false ;
129
+ let expectError = false ;
129
130
130
131
if ( testPath . endsWith ( '.ts' ) ) {
131
132
flags . push ( '-r' , 'ts-node/register' ) ;
@@ -136,6 +137,10 @@ export function createRunner(...paths: string[]) {
136
137
expectedEnvelopes . push ( expected ) ;
137
138
return this ;
138
139
} ,
140
+ expectError : function ( ) {
141
+ expectError = true ;
142
+ return this ;
143
+ } ,
139
144
withFlags : function ( ...args : string [ ] ) {
140
145
flags . push ( ...args ) ;
141
146
return this ;
@@ -347,7 +352,18 @@ export function createRunner(...paths: string[]) {
347
352
}
348
353
349
354
const url = `http://localhost:${ scenarioServerPort } ${ path } ` ;
350
- if ( method === 'get' ) {
355
+ if ( expectError ) {
356
+ try {
357
+ if ( method === 'get' ) {
358
+ await axios . get ( url , { headers } ) ;
359
+ } else {
360
+ await axios . post ( url , { headers } ) ;
361
+ }
362
+ } catch ( e ) {
363
+ return ;
364
+ }
365
+ return ;
366
+ } else if ( method === 'get' ) {
351
367
return ( await axios . get ( url , { headers } ) ) . data ;
352
368
} else {
353
369
return ( await axios . post ( url , { headers } ) ) . data ;
Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ function isResponseObject(response: ResponseObject | Boom): response is Response
20
20
return response && ( response as ResponseObject ) . statusCode !== undefined ;
21
21
}
22
22
23
- function isBoomObject ( response : ResponseObject | Boom ) : response is Boom {
24
- return response && ( response as Boom ) . isBoom !== undefined ;
25
- }
26
-
27
23
function isErrorEvent ( event : RequestEvent ) : event is RequestEvent {
28
24
return event && ( event as RequestEvent ) . error !== undefined ;
29
25
}
@@ -51,9 +47,7 @@ export const hapiErrorPlugin = {
51
47
// eslint-disable-next-line deprecation/deprecation
52
48
const transaction = getActiveTransaction ( ) ;
53
49
54
- if ( request . response && isBoomObject ( request . response ) ) {
55
- sendErrorToSentry ( request . response ) ;
56
- } else if ( isErrorEvent ( event ) ) {
50
+ if ( isErrorEvent ( event ) ) {
57
51
sendErrorToSentry ( event . error ) ;
58
52
}
59
53
You can’t perform that action at this time.
0 commit comments