Skip to content

test(react-router): Add and fix tests for pre rendered routes #16346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2025
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
Expand Up @@ -2,6 +2,5 @@ import type { Config } from '@react-router/dev/config';

export default {
ssr: true,
// todo: check why this messes up client tracing in tests
// prerender: ['/performance/static'],
prerender: ['/performance/static'],
} satisfies Config;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { APP_NAME } from '../constants';
test.describe('client - pageload performance', () => {
test('should send pageload transaction', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance';
return transactionEvent.transaction === '/performance/';
});

await page.goto(`/performance`);
Expand All @@ -29,7 +29,7 @@ test.describe('client - pageload performance', () => {
spans: expect.any(Array),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
transaction: '/performance',
transaction: '/performance/',
type: 'transaction',
transaction_info: { source: 'url' },
measurements: expect.any(Object),
Expand Down Expand Up @@ -103,18 +103,17 @@ test.describe('client - pageload performance', () => {
});
});

// todo: this page is currently not prerendered (see react-router.config.ts)
test('should send pageload transaction for prerendered pages', async ({ page }) => {
const txPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance/static';
return transactionEvent.transaction === '/performance/static/';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange 🤔

});

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

const transaction = await txPromise;

expect(transaction).toMatchObject({
transaction: '/performance/static',
transaction: '/performance/static/',
contexts: {
trace: {
span_id: expect.any(String),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ test.describe('Trace propagation', () => {
expect(clientTx.contexts?.trace?.trace_id).toEqual(serverTx.contexts?.trace?.trace_id);
expect(clientTx.contexts?.trace?.parent_span_id).toBe(serverTx.contexts?.trace?.span_id);
});

test('should not have trace connection for prerendered pages', async ({ page }) => {
await page.goto('/performance/static');

const sentryTraceElement = await page.$('meta[name="sentry-trace"]');
expect(sentryTraceElement).toBeNull();
});
});
Loading