Skip to content

Commit

Permalink
fix: 🐛 show not found when deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman committed Oct 29, 2024
1 parent 6fa1ce4 commit e3ddd67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand Down
7 changes: 6 additions & 1 deletion src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
import { lazy, Suspense } from "react";

import { NotFound } from "@/pages/not-found";

const RouterDevTools = import.meta.env.DEV
? lazy(async () => {
return import("@tanstack/router-devtools").then((res) => {
Expand All @@ -24,4 +26,7 @@ const Root = () => {
);
};

export const Route = createRootRouteWithContext()({ component: Root });
export const Route = createRootRouteWithContext()({
component: Root,
notFoundComponent: NotFound,
});

0 comments on commit e3ddd67

Please sign in to comment.