Skip to content

Commit c763d48

Browse files
committed
add node integration tests
1 parent 063dbea commit c763d48

File tree

3 files changed

+72
-1
lines changed
  • packages/node-integration-tests/suites/express/sentry-trace

3 files changed

+72
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as path from 'path';
2+
3+
import { getAPIResponse, runServer } from '../../../../utils/index';
4+
import { TestAPIResponse } from '../server';
5+
6+
test('should attach a `baggage` header to 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`))) as TestAPIResponse;
10+
11+
expect(response).toBeDefined();
12+
expect(response).toMatchObject({
13+
test_data: {
14+
host: 'somewhere.not.sentry',
15+
// TODO this is currently still empty but eventually it should contain sentry data
16+
baggage: expect.stringMatching(''),
17+
},
18+
});
19+
});

packages/node-integration-tests/suites/express/sentry-trace/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import http from 'http';
66

77
const app = express();
88

9-
export type TestAPIResponse = { test_data: { host: string; 'sentry-trace': string } };
9+
export type TestAPIResponse = { test_data: { host: string; 'sentry-trace': string; baggage: string } };
1010

1111
Sentry.init({
1212
dsn: 'https://[email protected]/1337',

0 commit comments

Comments
 (0)