From 43ce2acafcd4c7b9cffc81b0b24b4ecd128a19ef Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 16 Dec 2025 13:16:37 +0000 Subject: [PATCH] "fix" loki decoupled plugin tests --- .../MonacoFieldWrapper.test.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/public/app/plugins/datasource/loki/components/monaco-query-field/MonacoFieldWrapper.test.tsx b/public/app/plugins/datasource/loki/components/monaco-query-field/MonacoFieldWrapper.test.tsx index 4cf68235459..ff42e079976 100644 --- a/public/app/plugins/datasource/loki/components/monaco-query-field/MonacoFieldWrapper.test.tsx +++ b/public/app/plugins/datasource/loki/components/monaco-query-field/MonacoFieldWrapper.test.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from '@testing-library/react'; +import { act, render, screen, waitFor } from '@testing-library/react'; import { selectors } from '@grafana/e2e-selectors'; @@ -13,24 +13,32 @@ jest.mock('@grafana/runtime', () => ({ }), })); -function renderComponent({ initialValue = '', onChange = jest.fn(), onRunQuery = jest.fn() }: Partial = {}) { +async function renderComponent({ + initialValue = '', + onChange = jest.fn(), + onRunQuery = jest.fn(), +}: Partial = {}) { const datasource = createLokiDatasource(); - render( - + // TODO investigate why we need act + // see https://github.com/testing-library/react-testing-library/issues/1375 + await act(() => + render( + + ) ); } describe('MonacoFieldWrapper', () => { test('Renders with no errors', async () => { - renderComponent(); + await renderComponent(); await waitFor( async () => {