Skip to content

Commit cf60aeb

Browse files
committed
fix: add test load root layout
1 parent 7bfd2bd commit cf60aeb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
import { redirect } from '@sveltejs/kit';
2+
13
export const ssr = false;
4+
5+
export async function load({ route }) {
6+
//@ts-ignore
7+
if (route.id == '/bad-route' || route.id == '/good-route') {
8+
throw redirect(302, '/');
9+
}
10+
}

packages/kit/test/apps/no-ssr/src/routes/good-route/+page.svelte

Whitespace-only changes.

packages/kit/test/apps/no-ssr/test/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ test('navigating to a non-existent route renders the default error page', async
1313
await page.waitForLoadState('networkidle');
1414
expect(await page.textContent('h1')).toBe('404');
1515
});
16+
17+
test('error occur in load function at root layout renders the default error page', async ({
18+
page
19+
}) => {
20+
test.setTimeout(3000);
21+
await page.goto('/bad-route');
22+
await page.waitForLoadState('networkidle');
23+
expect(await page.textContent('h1')).toBe('404');
24+
});

0 commit comments

Comments
 (0)