diff --git a/bun.lockb b/bun.lockb index 8bcb822..f61139c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 9667744..a708405 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "prettier": "@jimmy.codes/prettier-config", "dependencies": { "@tanstack/react-query": "5.59.16", - "@tanstack/react-router": "1.76.3", + "@tanstack/react-router": "1.77.8", "clsx": "2.1.1", "react": "18.3.1", "react-dom": "18.3.1", @@ -48,8 +48,8 @@ "@storybook/react-vite": "8.3.6", "@tailwindcss/typography": "0.5.15", "@tanstack/react-query-devtools": "5.59.16", - "@tanstack/router-devtools": "1.76.3", - "@tanstack/router-vite-plugin": "1.76.0", + "@tanstack/router-devtools": "1.77.8", + "@tanstack/router-vite-plugin": "1.77.7", "@testing-library/dom": "10.4.0", "@testing-library/jest-dom": "6.6.2", "@testing-library/react": "16.0.1", @@ -59,18 +59,18 @@ "@types/react": "18.3.12", "@types/react-dom": "18.3.1", "@vitejs/plugin-react-swc": "3.7.1", - "@vitest/coverage-v8": "2.1.3", - "@vitest/ui": "2.1.3", + "@vitest/coverage-v8": "2.1.4", + "@vitest/ui": "2.1.4", "autoprefixer": "10.4.20", - "daisyui": "4.12.13", + "daisyui": "4.12.14", "eslint": "8.57.0", "eslint-plugin-storybook": "0.10.0--canary.156.408aed4.0", "gitzy": "5.4.0", "happy-dom": "15.7.4", "is-ci": "3.0.1", - "knip": "5.34.0", - "lefthook": "1.8.1", - "msw": "2.5.1", + "knip": "5.34.3", + "lefthook": "1.8.2", + "msw": "2.6.0", "postcss": "8.4.47", "prettier": "3.3.3", "storybook": "8.3.6", @@ -79,7 +79,7 @@ "typescript": "5.4.5", "vite": "5.4.10", "vite-tsconfig-paths": "5.0.1", - "vitest": "2.1.3" + "vitest": "2.1.4" }, "packageManager": "bun@1.1.33" } diff --git a/src/components/ext-link.spec.tsx b/src/components/ext-link.spec.tsx index fe05984..68c8bbd 100644 --- a/src/components/ext-link.spec.tsx +++ b/src/components/ext-link.spec.tsx @@ -14,8 +14,6 @@ describe("ExtLink", () => { ] as const)("should render %s link", async (to) => { await render({to}); - await expect( - screen.findByRole("link", { name: to }), - ).resolves.toBeInTheDocument(); + expect(screen.getByRole("link", { name: to })).toBeInTheDocument(); }); }); diff --git a/src/main.tsx b/src/main.tsx index e46a8e1..c51bb98 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,20 +2,12 @@ import "./main.css"; import { QueryClientProvider } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; -import { createRouter, RouterProvider } from "@tanstack/react-router"; +import { RouterProvider } from "@tanstack/react-router"; import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import queryClient from "./query.client"; -import { routeTree } from "./route-tree.gen"; - -const router = createRouter({ routeTree }); - -declare module "@tanstack/react-router" { - interface Register { - router: typeof router; - } -} +import { router } from "./router"; const root = document.getElementById("root"); diff --git a/src/pages/error.spec.tsx b/src/pages/error.spec.tsx new file mode 100644 index 0000000..1a99fb0 --- /dev/null +++ b/src/pages/error.spec.tsx @@ -0,0 +1,13 @@ +import { render, screen } from "@/testing/utils"; + +import { Error as ErrorPage } from "./error"; + +describe("", () => { + it('should render "Something went Wrong!" message', async () => { + await render( + , + ); + + expect(screen.getByText("Something went Wrong!")).toBeInTheDocument(); + }); +}); diff --git a/src/pages/error.tsx b/src/pages/error.tsx new file mode 100644 index 0000000..184df14 --- /dev/null +++ b/src/pages/error.tsx @@ -0,0 +1,21 @@ +import { type ErrorComponentProps, Link } from "@tanstack/react-router"; + +export const Error = ({ error }: ErrorComponentProps) => { + return ( +
+
+
+
+

+ Error +

+

{error.message}

+ + Go back + +
+
+
+
+ ); +}; diff --git a/src/pages/home.spec.tsx b/src/pages/home.spec.tsx index 9535c02..aa09f61 100644 --- a/src/pages/home.spec.tsx +++ b/src/pages/home.spec.tsx @@ -6,8 +6,8 @@ describe("", () => { it('should render "React Starter" heading', async () => { await render(); - await expect( - screen.findByRole("heading", { name: "React Starter", level: 1 }), - ).resolves.toBeInTheDocument(); + expect( + screen.getByRole("heading", { name: "React Starter", level: 1 }), + ).toBeInTheDocument(); }); }); diff --git a/src/pages/not-found.spec.tsx b/src/pages/not-found.spec.tsx new file mode 100644 index 0000000..ba2dda8 --- /dev/null +++ b/src/pages/not-found.spec.tsx @@ -0,0 +1,11 @@ +import { render, screen } from "@/testing/utils"; + +import { NotFound } from "./not-found"; + +describe("", () => { + it('should render "Not Found" message', async () => { + await render(); + + expect(screen.getByText("Not Found")).toBeInTheDocument(); + }); +}); diff --git a/src/pages/not-found.tsx b/src/pages/not-found.tsx new file mode 100644 index 0000000..a5d34ff --- /dev/null +++ b/src/pages/not-found.tsx @@ -0,0 +1,21 @@ +import { Link } from "@tanstack/react-router"; + +export const NotFound = () => { + return ( +
+
+
+
+

+ Error +

+

Not Found

+ + Go back + +
+
+
+
+ ); +}; diff --git a/src/router.tsx b/src/router.tsx new file mode 100644 index 0000000..584a172 --- /dev/null +++ b/src/router.tsx @@ -0,0 +1,17 @@ +import { createRouter } from "@tanstack/react-router"; + +import { Error } from "./pages/error"; +import { NotFound } from "./pages/not-found"; +import { routeTree } from "./route-tree.gen"; + +export const router = createRouter({ + routeTree, + defaultNotFoundComponent: NotFound, + defaultErrorComponent: Error, +}); + +declare module "@tanstack/react-router" { + interface Register { + router: typeof router; + } +}