Skip to content

Commit fc17dae

Browse files
committed
test(astro): Add E2E test for catch-all routes
1 parent cb88e70 commit fc17dae

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
import Layout from '../../layouts/Layout.astro';
3+
4+
export const prerender = false;
5+
6+
const params = Astro.params;
7+
8+
---
9+
10+
<Layout title="CatchAll SSR page">
11+
<p>params: {params}</p>
12+
</Layout>

dev-packages/e2e-tests/test-applications/astro-5/tests/tracing.dynamic.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,53 @@ test.describe('nested SSR routes (client, server, server request)', () => {
262262
request: { url: expect.stringContaining('/api/user/myUsername123.json') },
263263
});
264264
});
265+
266+
test('sends parametrized pageload and server transaction names for catch-all routes', async ({ page }) => {
267+
const clientPageloadTxnPromise = waitForTransaction('astro-5', txnEvent => {
268+
return txnEvent?.transaction?.startsWith('/catchAll/') ?? false;
269+
});
270+
271+
const serverPageRequestTxnPromise = waitForTransaction('astro-5', txnEvent => {
272+
return txnEvent?.transaction?.startsWith('GET /catchAll/') ?? false;
273+
});
274+
275+
await page.goto('/catchAll/hell0/whatever-do');
276+
277+
const clientPageloadTxn = await clientPageloadTxnPromise;
278+
const serverPageRequestTxn = await serverPageRequestTxnPromise;
279+
280+
expect(clientPageloadTxn).toMatchObject({
281+
transaction: '/catchAll/hell0/whatever-do', // todo: parametrize to '/catchAll/[...path]'
282+
transaction_info: { source: 'url' },
283+
contexts: {
284+
trace: {
285+
op: 'pageload',
286+
origin: 'auto.pageload.browser',
287+
data: {
288+
'sentry.op': 'pageload',
289+
'sentry.origin': 'auto.pageload.browser',
290+
'sentry.source': 'url',
291+
},
292+
},
293+
},
294+
});
295+
296+
expect(serverPageRequestTxn).toMatchObject({
297+
transaction: 'GET /catchAll/[path]',
298+
transaction_info: { source: 'route' },
299+
contexts: {
300+
trace: {
301+
op: 'http.server',
302+
origin: 'auto.http.astro',
303+
data: {
304+
'sentry.op': 'http.server',
305+
'sentry.origin': 'auto.http.astro',
306+
'sentry.source': 'route',
307+
url: expect.stringContaining('/catchAll/hell0/whatever-do'),
308+
},
309+
},
310+
},
311+
request: { url: expect.stringContaining('/catchAll/hell0/whatever-do') },
312+
});
313+
});
265314
});

0 commit comments

Comments
 (0)