Skip to content

Commit 159426a

Browse files
SG60Lms24
authored andcommitted
test(sveltekit-cloudflare): add test of prerendered page
test(sveltekit-cloudflare): actually test the prerendered page
1 parent f6da869 commit 159426a

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

dev-packages/e2e-tests/test-applications/sveltekit-cloudflare-pages/src/routes/+page.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
<h1>Welcome to SvelteKit</h1>
66
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>
77

8+
<a href="/prerender-test">prerender test</a>
9+
810
<p>{data.message}</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { PageServerLoad } from './$types';
2+
3+
export const prerender = true;
4+
5+
export const load: PageServerLoad = async function load() {
6+
return {
7+
message: 'From server load function.',
8+
};
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script lang="ts">
2+
let { data } = $props();
3+
</script>
4+
5+
<h1>{data.message}</h1>
6+
<p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>

dev-packages/e2e-tests/test-applications/sveltekit-cloudflare-pages/tests/demo.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ test('home page has expected h1', async ({ page }) => {
44
await page.goto('/');
55
await expect(page.locator('h1')).toBeVisible();
66
});
7+
8+
test('prerendered page has expected h1', async ({ page }) => {
9+
await page.goto('/prerender-test');
10+
await expect(page.locator('h1')).toHaveText('From server load function.');
11+
});

0 commit comments

Comments
 (0)