From e4534deab3b8bba584fa63c5c1e286d70530c066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 9 Feb 2022 14:07:28 +0100 Subject: [PATCH] Chore: Reduce console output in NavBarItem.test.tsx (#45139) * Chore: Reduce console ouput in NavBarItem.test.tsx * Chore: remove async --- .../core/components/NavBar/NavBarItem.test.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/public/app/core/components/NavBar/NavBarItem.test.tsx b/public/app/core/components/NavBar/NavBarItem.test.tsx index d8d0aca7409..9425298a4ab 100644 --- a/public/app/core/components/NavBar/NavBarItem.test.tsx +++ b/public/app/core/components/NavBar/NavBarItem.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render, screen, waitFor } from '@testing-library/react'; +import { act, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; import { locationUtil } from '@grafana/data'; @@ -53,8 +53,9 @@ describe('NavBarItem', () => { it('then the onClick handler should be called', () => { getTestContext(); - userEvent.click(screen.getByRole('button')); - + act(() => { + userEvent.click(screen.getByRole('button')); + }); expect(onClickMock).toHaveBeenCalledTimes(1); }); }); @@ -194,7 +195,9 @@ describe('NavBarItem', () => { expect(screen.getByText('New')).toBeInTheDocument(); }); - userEvent.click(screen.getByText('New')); + act(() => { + userEvent.click(screen.getByText('New')); + }); await waitFor(() => { expect(pushMock).toHaveBeenCalledTimes(1); expect(pushMock).toHaveBeenCalledWith('/dashboard/new'); @@ -218,7 +221,9 @@ describe('NavBarItem', () => { expect(screen.getByText('New')).toBeInTheDocument(); }); - userEvent.click(screen.getByText('New')); + act(() => { + userEvent.click(screen.getByText('New')); + }); await waitFor(() => { expect(pushMock).toHaveBeenCalledTimes(1); expect(pushMock).toHaveBeenCalledWith('/grafana/dashboard/new');