-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
47 lines (45 loc) · 1.97 KB
/
test.ts
File metadata and controls
47 lines (45 loc) · 1.97 KB
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
import { createTestServer } from '@sentry-internal/test-utils';
import { describe, expect } from 'vitest';
import { createEsmAndCjsTests } from '../../../../utils/runner';
import { expectConsistentTraceId, expectNoDuplicateSentryBaggageKeys, expectUserSetTraceId } from '../expects';
describe('double baggage prevention', () => {
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
test('fetch with manual getTraceData() does not duplicate sentry baggage entries', async () => {
const [SERVER_URL, closeTestServer] = await createTestServer()
.get('/api/fetch-custom-headers', headers => {
// fetch with manual getTraceData() headers
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^[a-f\d]{32}-[a-f\d]{16}$/));
expectNoDuplicateSentryBaggageKeys(headers['baggage']);
expectConsistentTraceId(headers);
expectUserSetTraceId(headers);
})
.get('/api/fetch', headers => {
// fetch without manual headers (baseline)
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^[a-f\d]{32}-[a-f\d]{16}$/));
expectNoDuplicateSentryBaggageKeys(headers['baggage']);
expectConsistentTraceId(headers);
})
.get('/api/http-custom-headers', headers => {
// http.request with manual getTraceData() headers
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^[a-f\d]{32}-[a-f\d]{16}$/));
expectNoDuplicateSentryBaggageKeys(headers['baggage']);
expectConsistentTraceId(headers);
expectUserSetTraceId(headers);
})
.start();
await createRunner()
.withEnv({ SERVER_URL })
.ignore('transaction')
.expect({
event: {
exception: {
values: [{ type: 'Error', value: 'done' }],
},
},
})
.start()
.completed();
closeTestServer();
});
});
});