diff --git a/src/components/pages/ErrorPage/ErrorPage.test.tsx b/src/components/pages/ErrorPage/ErrorPage.test.tsx index d2ca2df..574aa9f 100644 --- a/src/components/pages/ErrorPage/ErrorPage.test.tsx +++ b/src/components/pages/ErrorPage/ErrorPage.test.tsx @@ -17,12 +17,13 @@ describe('Renders ErrorPage correctly', async () => { * Passes - shows title correctly */ it('Should render the error page correctly', () => { - const router = createMemoryRouter([{ path: '/', element:
, errorElement: }], { initialEntries: ['/some/bad/route'] }) + const badRoute = '/some/bad/route' + const router = createMemoryRouter([{ path: '/', element:
, errorElement: }], { initialEntries: [badRoute] }) render() expect(screen.getByText('Oops!')).toBeInTheDocument() expect(screen.getByText('Sorry, an unexpected error has occurred.')).toBeInTheDocument() - expect(screen.getByText('404 Not Found')).toBeInTheDocument() + expect(screen.getByText(`404 Error: No route matches URL "${badRoute}"`)).toBeInTheDocument() }) }) diff --git a/src/components/pages/ErrorPage/ErrorPage.tsx b/src/components/pages/ErrorPage/ErrorPage.tsx index 8d4184b..0c70e08 100644 --- a/src/components/pages/ErrorPage/ErrorPage.tsx +++ b/src/components/pages/ErrorPage/ErrorPage.tsx @@ -1,22 +1,21 @@ import { isRouteErrorResponse, useRouteError } from 'react-router-dom' +import { Box, Typography } from '@mui/material' const ErrorPage: React.FC = () => { const error: unknown = useRouteError() - if (isRouteErrorResponse(error)) { - return ( -
-

Oops!

-

Sorry, an unexpected error has occurred.

- {isRouteErrorResponse(error) && ( -

- - {error.status} {error.statusText} - -

- )} -
- ) - } + return ( + + + Oops! + + Sorry, an unexpected error has occurred. + {isRouteErrorResponse(error) && ( + + {error.status} {error.data} + + )} + + ) } export default ErrorPage