-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
52 lines (43 loc) · 1.54 KB
/
test.ts
File metadata and controls
52 lines (43 loc) · 1.54 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
48
49
50
51
52
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers';
sentryTest('should call onRequestSpanStart hook', async ({ browserName, getLocalTestUrl, page }) => {
const supportedBrowsers = ['chromium', 'firefox'];
if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) {
sentryTest.skip();
}
await page.route('http://sentry-test-site-fetch.example/', async route => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: '',
});
});
await page.route('http://sentry-test-site-xhr.example/', async route => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: '',
});
});
const url = await getLocalTestUrl({ testDir: __dirname });
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url, timeout: 10000 });
const tracingEvent = envelopes[envelopes.length - 1]; // last envelope contains tracing data on all browsers
expect(tracingEvent.spans).toContainEqual(
expect.objectContaining({
op: 'http.client',
data: expect.objectContaining({
'hook.called.headers': 'xhr',
}),
}),
);
expect(tracingEvent.spans).toContainEqual(
expect.objectContaining({
op: 'http.client',
data: expect.objectContaining({
'hook.called.headers': 'fetch',
}),
}),
);
});