Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="{{htmlWebpackPlugin.options.initialization}}"></script>
</head>
<body>
<div>Rendered</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { expect, Page } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';

sentryTest.beforeEach(({ browserName }) => {
if (browserName !== 'chromium') {
sentryTest.skip();
}
});

async function createSessionWithLatency(page: Page, latency: number) {
const session = await page.context().newCDPSession(page);
await session.send('Network.emulateNetworkConditions', {
offline: false,
latency: latency,
downloadThroughput: (25 * 1024) / 8,
uploadThroughput: (5 * 1024) / 8,
});

return session;
}

sentryTest('should capture a `connection.rtt` metric.', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
const eventData = await getSentryTransactionRequest(page, url);

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.['connection.rtt']?.value).toBe(0);
});

sentryTest(
'should capture a `connection.rtt` metric with emulated value 200ms on Chromium.',
async ({ getLocalTestPath, page }) => {
const session = await createSessionWithLatency(page, 200);

const url = await getLocalTestPath({ testDir: __dirname });
const eventData = await getSentryTransactionRequest(page, url);

await session.detach();

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.['connection.rtt']?.value).toBe(200);
},
);

sentryTest(
'should capture a `connection.rtt` metric with emulated value 100ms on Chromium.',
async ({ getLocalTestPath, page }) => {
const session = await createSessionWithLatency(page, 100);

const url = await getLocalTestPath({ testDir: __dirname });
const eventData = await getSentryTransactionRequest(page, url);

await session.detach();

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.['connection.rtt']?.value).toBe(100);
},
);

sentryTest(
'should capture a `connection.rtt` metric with emulated value 50ms on Chromium.',
async ({ getLocalTestPath, page }) => {
const session = await createSessionWithLatency(page, 50);

const url = await getLocalTestPath({ testDir: __dirname });
const eventData = await getSentryTransactionRequest(page, url);

await session.detach();

expect(eventData.measurements).toBeDefined();
expect(eventData.measurements?.['connection.rtt']?.value).toBe(50);
},
);