-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
40 lines (33 loc) · 1.35 KB
/
test.ts
File metadata and controls
40 lines (33 loc) · 1.35 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
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
shouldSkipTracingTest,
waitForTransactionRequestOnUrl,
} from '../../../../utils/helpers';
sentryTest('should create spans for fetch requests called directly after init', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
await page.route('http://sentry-test-site.example/*', route => route.fulfill({ body: 'ok' }));
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);
const tracingEvent = envelopeRequestParser(req);
const requestSpans = tracingEvent.spans?.filter(({ op }) => op === 'http.client');
expect(requestSpans).toHaveLength(1);
expect(requestSpans![0]).toMatchObject({
description: 'GET http://sentry-test-site.example/0',
parent_span_id: tracingEvent.contexts?.trace?.span_id,
span_id: expect.stringMatching(/[a-f0-9]{16}/),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: tracingEvent.contexts?.trace?.trace_id,
data: {
'http.method': 'GET',
'http.url': 'http://sentry-test-site.example/0',
url: 'http://sentry-test-site.example/0',
'server.address': 'sentry-test-site.example',
type: 'fetch',
},
});
});