Skip to content

Commit adf2ac8

Browse files
committed
make axios config method on testEnv class
1 parent a5b8eea commit adf2ac8

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

packages/node-integration-tests/utils/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ async function makeRequest(
121121
}
122122

123123
export class TestEnv {
124+
private _axiosConfig: AxiosRequestConfig = undefined;
125+
124126
public constructor(public readonly server: http.Server, public readonly url: string) {
125127
this.server = server;
126128
this.url = url;
@@ -165,10 +167,7 @@ export class TestEnv {
165167
* @param {DataCollectorOptions} options
166168
* @returns The intercepted envelopes.
167169
*/
168-
public async getMultipleEnvelopeRequest(
169-
options: DataCollectorOptions,
170-
axiosConfig?: AxiosRequestConfig,
171-
): Promise<Record<string, unknown>[][]> {
170+
public async getMultipleEnvelopeRequest(options: DataCollectorOptions): Promise<Record<string, unknown>[][]> {
172171
const envelopeTypeArray =
173172
typeof options.envelopeType === 'string'
174173
? [options.envelopeType]
@@ -180,7 +179,7 @@ export class TestEnv {
180179
envelopeTypeArray,
181180
);
182181

183-
void makeRequest(options.method, options.url || this.url, axiosConfig);
182+
void makeRequest(options.method, options.url || this.url, this._axiosConfig);
184183
return resProm;
185184
}
186185

@@ -190,11 +189,8 @@ export class TestEnv {
190189
* @param {DataCollectorOptions} options
191190
* @returns The extracted envelope.
192191
*/
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];
192+
public async getEnvelopeRequest(options?: DataCollectorOptions): Promise<Array<Record<string, unknown>>> {
193+
return (await this.getMultipleEnvelopeRequest({ ...options, count: 1 }))[0];
198194
}
199195

200196
/**
@@ -256,4 +252,8 @@ export class TestEnv {
256252
.reply(200);
257253
});
258254
}
255+
256+
public setAxiosConfig(axiosConfig: AxiosRequestConfig): void {
257+
this._axiosConfig = axiosConfig;
258+
}
259259
}

packages/remix/test/integration/test/server/loader.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,14 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
162162
const env = await RemixTestEnv.init(adapter);
163163
const url = `${env.url}/loader-json-response/3`;
164164

165-
const envelope = await env.getEnvelopeRequest(
166-
{ url, envelopeType: 'transaction' },
167-
{
168-
headers: {
169-
'sentry-trace': '12312012123120121231201212312012-1121201211212012-1',
170-
baggage: 'sentry-version=1.0,sentry-environment=production,sentry-trace_id=12312012123120121231201212312012',
171-
},
165+
// send sentry-trace and baggage headers to loader
166+
env.setAxiosConfig({
167+
headers: {
168+
'sentry-trace': '12312012123120121231201212312012-1121201211212012-1',
169+
baggage: 'sentry-version=1.0,sentry-environment=production,sentry-trace_id=12312012123120121231201212312012',
172170
},
173-
);
171+
});
172+
const envelope = await env.getEnvelopeRequest({ url, envelopeType: 'transaction' });
174173

175174
expect(envelope[0].trace).toMatchObject({
176175
trace_id: '12312012123120121231201212312012',

0 commit comments

Comments
 (0)