Skip to content

Commit ac1b7c8

Browse files
committed
add node http integration unit tests
1 parent 7271640 commit ac1b7c8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/node/test/integrations/http.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,43 @@ describe('tracing', () => {
8686

8787
expect(sentryTraceHeader).not.toBeDefined();
8888
});
89+
90+
it('attaches the baggage header to outgoing non-sentry requests', async () => {
91+
nock('http://dogs.are.great').get('/').reply(200);
92+
93+
createTransactionOnScope();
94+
95+
const request = http.get('http://dogs.are.great/');
96+
const baggageHeader = request.getHeader('baggage') as string;
97+
98+
expect(baggageHeader).toBeDefined();
99+
// this might change once we actually add our baggage data to the header
100+
expect(baggageHeader).toEqual('');
101+
});
102+
103+
it('propagates 3rd party baggage header data to outgoing non-sentry requests', async () => {
104+
nock('http://dogs.are.great').get('/').reply(200);
105+
106+
createTransactionOnScope();
107+
108+
const request = http.get({ host: 'http://dogs.are.great/', headers: { baggage: 'dog=great' } });
109+
const baggageHeader = request.getHeader('baggage') as string;
110+
111+
expect(baggageHeader).toBeDefined();
112+
// this might change once we actually add our baggage data to the header
113+
expect(baggageHeader).toEqual('dog=great');
114+
});
115+
116+
it("doesn't attach the sentry-trace header to outgoing sentry requests", () => {
117+
nock('http://squirrelchasers.ingest.sentry.io').get('/api/12312012/store/').reply(200);
118+
119+
createTransactionOnScope();
120+
121+
const request = http.get('http://squirrelchasers.ingest.sentry.io/api/12312012/store/');
122+
const baggage = request.getHeader('baggage');
123+
124+
expect(baggage).not.toBeDefined();
125+
});
89126
});
90127

91128
describe('default protocols', () => {

0 commit comments

Comments
 (0)