Skip to content

Commit 593d5b3

Browse files
RulaKhaledchargome
andauthored
test(react-router): Add and fix tests for pre rendered routes (#16346)
It was confirmed that static pre-renders don't pick up Sentry trace meta tags — this just adds a quick test. More context: https://linear.app/getsentry/issue/JS-392/rr7-evaluate-static-pre-rendering P.S. Not a priority, but for some reason, I had to add a trailing / to fetch the correct transactions and pass the tests. I’ll look into why this is happening for transaction route names and whether this behavior is expected in a later PR. --------- Co-authored-by: Charly Gomez <charly.gomez@sentry.io>
1 parent f00ddcb commit 593d5b3

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

dev-packages/e2e-tests/test-applications/react-router-7-framework/react-router.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ import type { Config } from '@react-router/dev/config';
22

33
export default {
44
ssr: true,
5-
// todo: check why this messes up client tracing in tests
6-
// prerender: ['/performance/static'],
5+
prerender: ['/performance/static'],
76
} satisfies Config;

dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/pageload.client.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { APP_NAME } from '../constants';
55
test.describe('client - pageload performance', () => {
66
test('should send pageload transaction', async ({ page }) => {
77
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
8-
return transactionEvent.transaction === '/performance';
8+
return transactionEvent.transaction === '/performance/';
99
});
1010

1111
await page.goto(`/performance`);
@@ -29,7 +29,7 @@ test.describe('client - pageload performance', () => {
2929
spans: expect.any(Array),
3030
start_timestamp: expect.any(Number),
3131
timestamp: expect.any(Number),
32-
transaction: '/performance',
32+
transaction: '/performance/',
3333
type: 'transaction',
3434
transaction_info: { source: 'url' },
3535
measurements: expect.any(Object),
@@ -103,18 +103,17 @@ test.describe('client - pageload performance', () => {
103103
});
104104
});
105105

106-
// todo: this page is currently not prerendered (see react-router.config.ts)
107106
test('should send pageload transaction for prerendered pages', async ({ page }) => {
108107
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
109-
return transactionEvent.transaction === '/performance/static';
108+
return transactionEvent.transaction === '/performance/static/';
110109
});
111110

112111
await page.goto(`/performance/static`);
113112

114113
const transaction = await txPromise;
115114

116115
expect(transaction).toMatchObject({
117-
transaction: '/performance/static',
116+
transaction: '/performance/static/',
118117
contexts: {
119118
trace: {
120119
span_id: expect.any(String),

dev-packages/e2e-tests/test-applications/react-router-7-framework/tests/performance/trace-propagation.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ test.describe('Trace propagation', () => {
3333
expect(clientTx.contexts?.trace?.trace_id).toEqual(serverTx.contexts?.trace?.trace_id);
3434
expect(clientTx.contexts?.trace?.parent_span_id).toBe(serverTx.contexts?.trace?.span_id);
3535
});
36+
37+
test('should not have trace connection for prerendered pages', async ({ page }) => {
38+
await page.goto('/performance/static');
39+
40+
const sentryTraceElement = await page.$('meta[name="sentry-trace"]');
41+
expect(sentryTraceElement).toBeNull();
42+
});
3643
});

0 commit comments

Comments
 (0)