-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
test.ts
52 lines (42 loc) · 1.84 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as path from 'path';
import { getAPIResponse, runServer } from '../../../../utils/index';
import { TestAPIResponse } from '../server';
test('Should assign `baggage` header which contains 3rd party trace baggage data to an outgoing request.', async () => {
const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`);
const response = (await getAPIResponse(new URL(`${url}/express`), {
baggage: 'foo=bar,bar=baz',
})) as TestAPIResponse;
expect(response).toBeDefined();
expect(response).toMatchObject({
test_data: {
host: 'somewhere.not.sentry',
baggage: 'foo=bar,bar=baz,sentry-environment=prod,sentry-release=1.0',
},
});
});
test('Should not overwrite baggage if the incoming request already has Sentry baggage data.', async () => {
const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`);
const response = (await getAPIResponse(new URL(`${url}/express`), {
baggage: 'sentry-version=2.0.0,sentry-environment=myEnv',
})) as TestAPIResponse;
expect(response).toBeDefined();
expect(response).toMatchObject({
test_data: {
host: 'somewhere.not.sentry',
baggage: 'sentry-version=2.0.0,sentry-environment=myEnv',
},
});
});
test('Should pass along sentry and 3rd party trace baggage data from an incoming to an outgoing request.', async () => {
const url = await runServer(__dirname, `${path.resolve(__dirname, '..')}/server.ts`);
const response = (await getAPIResponse(new URL(`${url}/express`), {
baggage: 'sentry-version=2.0.0,sentry-environment=myEnv,dogs=great',
})) as TestAPIResponse;
expect(response).toBeDefined();
expect(response).toMatchObject({
test_data: {
host: 'somewhere.not.sentry',
baggage: expect.stringContaining('dogs=great,sentry-version=2.0.0,sentry-environment=myEnv'),
},
});
});