From 45ce17cf07dc8654edb2164577b6772485dd64c6 Mon Sep 17 00:00:00 2001 From: m-tartari <37861893+m-tartari@users.noreply.github.com> Date: Thu, 3 Jul 2025 11:52:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(ErrorPage):=20suppress=20expec?= =?UTF-8?q?ted=20console=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/ErrorPage/ErrorPage.test.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/components/pages/ErrorPage/ErrorPage.test.tsx b/src/components/pages/ErrorPage/ErrorPage.test.tsx index ff6dac9..b4825b1 100644 --- a/src/components/pages/ErrorPage/ErrorPage.test.tsx +++ b/src/components/pages/ErrorPage/ErrorPage.test.tsx @@ -1,4 +1,4 @@ -import { screen, cleanup, render } from '@testing-library/react' +import { screen, render } from '@testing-library/react' import { RouterProvider, createMemoryRouter } from 'react-router-dom' // eslint-disable-next-line @typescript-eslint/no-unused-vars import { useAnalytics } from 'use-analytics' @@ -10,19 +10,14 @@ vi.mock('use-analytics', () => ({ useAnalytics: () => ({ plugins: { enable: vi.fn(), disable: vi.fn() } }), })) -// Tests -describe('Renders ErrorPage correctly', async () => { - /** - * Resets all renders after each test - */ - afterEach(() => { - cleanup() - }) +// Suppress console.error messages during tests +const originalConsoleError = console.error +console.error = vi.fn() - /** - * Passes - shows title correctly - */ +describe('Renders ErrorPage correctly', async () => { it('Should render the error page correctly', () => { + console.error = vi.fn() + const badRoute = '/some/bad/route' const router = createMemoryRouter([{ path: '/', element:
, errorElement: