|  | 
|  | 1 | +import * as path from 'path'; | 
|  | 2 | + | 
|  | 3 | +import { getAPIResponse, runServer } from '../../../../utils/index'; | 
|  | 4 | +import { TestAPIResponse } from '../server'; | 
|  | 5 | + | 
|  | 6 | +test('Should assign `baggage` header which contains 3rd party trace baggage data of an outgoing request.', async () => { | 
|  | 7 | +  const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | 
|  | 8 | + | 
|  | 9 | +  const response = (await getAPIResponse(new URL(`${url}/express`), { | 
|  | 10 | +    baggage: 'foo=bar,bar=baz', | 
|  | 11 | +  })) as TestAPIResponse; | 
|  | 12 | + | 
|  | 13 | +  expect(response).toBeDefined(); | 
|  | 14 | +  expect(response).toMatchObject({ | 
|  | 15 | +    test_data: { | 
|  | 16 | +      host: 'somewhere.not.sentry', | 
|  | 17 | +      baggage: expect.stringContaining('foo=bar,bar=baz'), | 
|  | 18 | +    }, | 
|  | 19 | +  }); | 
|  | 20 | +}); | 
|  | 21 | + | 
|  | 22 | +test('Should assign `baggage` header which contains sentry trace baggage data of an outgoing request.', async () => { | 
|  | 23 | +  const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | 
|  | 24 | + | 
|  | 25 | +  const response = (await getAPIResponse(new URL(`${url}/express`), { | 
|  | 26 | +    baggage: 'sentry-version=1.0.0,sentry-environment=production', | 
|  | 27 | +  })) as TestAPIResponse; | 
|  | 28 | + | 
|  | 29 | +  expect(response).toBeDefined(); | 
|  | 30 | +  expect(response).toMatchObject({ | 
|  | 31 | +    test_data: { | 
|  | 32 | +      host: 'somewhere.not.sentry', | 
|  | 33 | +      baggage: expect.stringContaining('sentry-version=1.0.0,sentry-environment=production'), | 
|  | 34 | +    }, | 
|  | 35 | +  }); | 
|  | 36 | +}); | 
|  | 37 | + | 
|  | 38 | +test('Should assign `baggage` header which contains sentry and 3rd party trace baggage data of an outgoing request.', async () => { | 
|  | 39 | +  const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`); | 
|  | 40 | + | 
|  | 41 | +  const response = (await getAPIResponse(new URL(`${url}/express`), { | 
|  | 42 | +    baggage: 'sentry-version=1.0.0,sentry-environment=production,dogs=great', | 
|  | 43 | +  })) as TestAPIResponse; | 
|  | 44 | + | 
|  | 45 | +  expect(response).toBeDefined(); | 
|  | 46 | +  expect(response).toMatchObject({ | 
|  | 47 | +    test_data: { | 
|  | 48 | +      host: 'somewhere.not.sentry', | 
|  | 49 | +      baggage: expect.stringContaining('dogs=great,sentry-version=1.0.0,sentry-environment=production'), | 
|  | 50 | +    }, | 
|  | 51 | +  }); | 
|  | 52 | +}); | 
0 commit comments