-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
41 lines (32 loc) · 1.33 KB
/
Copy pathtest.ts
File metadata and controls
41 lines (32 loc) · 1.33 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
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
sentryTest(
'should not create span for fetch requests with no active span but should attach sentry-trace header',
async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const sentryTraceHeaders: string[] = [];
await page.route('http://example.com/**', route => {
const sentryTraceHeader = route.request().headers()['sentry-trace'];
if (sentryTraceHeader) {
sentryTraceHeaders.push(sentryTraceHeader);
}
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({}),
});
});
const url = await getLocalTestUrl({ testDir: __dirname });
await Promise.all([page.goto(url), ...[0, 1, 2].map(idx => page.waitForRequest(`http://example.com/${idx}`))]);
expect(await page.evaluate('window._sentryTransactionsCount')).toBe(0);
expect(sentryTraceHeaders).toHaveLength(3);
expect(sentryTraceHeaders).toEqual([
expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/),
expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/),
expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/),
]);
},
);