Skip to content

Commit a0aae23

Browse files
committed
test(astro): Cover route resolution through the route provider
1 parent 1394fa6 commit a0aae23

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
import Layout from '../../layouts/Layout.astro';
3+
4+
export const prerender = false;
5+
---
6+
7+
<Layout title="Route provider">
8+
<button id="resolve-route">Resolve route</button>
9+
<div id="resolved-route"></div>
10+
</Layout>
11+
12+
<script>
13+
import * as Sentry from '@sentry/astro';
14+
15+
document.getElementById('resolve-route')?.addEventListener('click', () => {
16+
document.getElementById('resolved-route')!.textContent = Sentry.resolveCurrentRoute() ?? 'unresolved';
17+
});
18+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
// The route provider reads the route the middleware renders into the page, so this fails if that route
4+
// never reaches the browser.
5+
test('resolves the parameterized route through the route provider', async ({ page }) => {
6+
await page.goto('/route-provider/123');
7+
await page.locator('#resolve-route').click();
8+
9+
await expect(page.locator('#resolved-route')).toHaveText('/route-provider/[id]');
10+
});

0 commit comments

Comments
 (0)