22import * as Sentry from '@sentry/node' ;
33import { EnvelopeItemType } from '@sentry/types' ;
44import { logger , parseSemver } from '@sentry/utils' ;
5- import axios from 'axios' ;
5+ import axios , { AxiosRequestConfig } from 'axios' ;
66import { Express } from 'express' ;
77import * as http from 'http' ;
88import nock from 'nock' ;
@@ -102,12 +102,16 @@ export async function runScenario(url: string): Promise<void> {
102102 await Sentry . flush ( ) ;
103103}
104104
105- async function makeRequest ( method : 'get' | 'post' = 'get' , url : string ) : Promise < void > {
105+ async function makeRequest (
106+ method : 'get' | 'post' = 'get' ,
107+ url : string ,
108+ axiosConfig ?: AxiosRequestConfig ,
109+ ) : Promise < void > {
106110 try {
107111 if ( method === 'get' ) {
108- await axios . get ( url ) ;
112+ await axios . get ( url , axiosConfig ) ;
109113 } else {
110- await axios . post ( url ) ;
114+ await axios . post ( url , axiosConfig ) ;
111115 }
112116 } catch ( e ) {
113117 // We sometimes expect the request to fail, but not the test.
@@ -161,7 +165,10 @@ export class TestEnv {
161165 * @param {DataCollectorOptions } options
162166 * @returns The intercepted envelopes.
163167 */
164- public async getMultipleEnvelopeRequest ( options : DataCollectorOptions ) : Promise < Record < string , unknown > [ ] [ ] > {
168+ public async getMultipleEnvelopeRequest (
169+ options : DataCollectorOptions ,
170+ axiosConfig ?: AxiosRequestConfig ,
171+ ) : Promise < Record < string , unknown > [ ] [ ] > {
165172 const envelopeTypeArray =
166173 typeof options . envelopeType === 'string'
167174 ? [ options . envelopeType ]
@@ -173,7 +180,7 @@ export class TestEnv {
173180 envelopeTypeArray ,
174181 ) ;
175182
176- void makeRequest ( options . method , options . url || this . url ) ;
183+ void makeRequest ( options . method , options . url || this . url , axiosConfig ) ;
177184 return resProm ;
178185 }
179186
@@ -183,8 +190,11 @@ export class TestEnv {
183190 * @param {DataCollectorOptions } options
184191 * @returns The extracted envelope.
185192 */
186- public async getEnvelopeRequest ( options ?: DataCollectorOptions ) : Promise < Array < Record < string , unknown > > > {
187- return ( await this . getMultipleEnvelopeRequest ( { ...options , count : 1 } ) ) [ 0 ] ;
193+ public async getEnvelopeRequest (
194+ options ?: DataCollectorOptions ,
195+ axiosConfig ?: AxiosRequestConfig ,
196+ ) : Promise < Array < Record < string , unknown > > > {
197+ return ( await this . getMultipleEnvelopeRequest ( { ...options , count : 1 } , axiosConfig ) ) [ 0 ] ;
188198 }
189199
190200 /**
0 commit comments