-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
32 lines (26 loc) · 1.27 KB
/
test.ts
File metadata and controls
32 lines (26 loc) · 1.27 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
import { expect } from '@playwright/test';
import { extractTraceparentData } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
sentryTest(
'attaches traceparent header to tracing without performance (TWP) fetch requests, if `propagateTraceparent` is true',
async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
const [, request] = await Promise.all([page.goto(url), page.waitForRequest('http://sentry-test-site.example/0')]);
const requestHeaders = request.headers();
const traceparentData = extractTraceparentData(requestHeaders['sentry-trace']);
expect(traceparentData).toMatchObject({
traceId: expect.stringMatching(/^([a-f0-9]{32})$/),
parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/),
parentSampled: undefined,
});
expect(requestHeaders).toMatchObject({
'sentry-trace': `${traceparentData?.traceId}-${traceparentData?.parentSpanId}`,
baggage: expect.stringContaining(`sentry-trace_id=${traceparentData?.traceId}`),
traceparent: `00-${traceparentData?.traceId}-${traceparentData?.parentSpanId}-00`,
});
},
);