From 39f7e63955fab2355c445a72c430d0e7c4fab24f Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Tue, 29 Oct 2024 18:24:16 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20show=20not=20found=20when?= =?UTF-8?q?=20deployed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- e2e/app.spec.ts | 10 ++++++++++ src/router.tsx | 1 + 2 files changed, 11 insertions(+) diff --git a/e2e/app.spec.ts b/e2e/app.spec.ts index 2dcfd03..93a7f82 100644 --- a/e2e/app.spec.ts +++ b/e2e/app.spec.ts @@ -6,6 +6,16 @@ test("has title", async ({ page }) => { await expect(page).toHaveTitle(/React Starter/); }); +test("not found", async ({ page }) => { + await page.goto("/lost"); + + await expect(page).toHaveTitle(/React Starter/); + + await expect( + page.getByRole("heading", { name: "Error", level: 1 }), + ).toBeInViewport(); +}); + test.describe("external links", () => { test.beforeEach(async ({ page }) => { await page.goto("/"); diff --git a/src/router.tsx b/src/router.tsx index 584a172..fb9f57d 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -8,6 +8,7 @@ export const router = createRouter({ routeTree, defaultNotFoundComponent: NotFound, defaultErrorComponent: Error, + notFoundMode: "root", }); declare module "@tanstack/react-router" {