From c0c36b3a792367e51a21418a084d8efb6b18c959 Mon Sep 17 00:00:00 2001 From: Shawn Esquivel <94336773+shawnesquivel@users.noreply.github.com> Date: Tue, 13 Dec 2022 14:18:55 -0800 Subject: [PATCH] "findByRole" query over "waitFor and getByRole" By implementing tis change, the eslint suggestion "Prefer `findByRole` query over using `waitFor` + `getByRole" is removed. The change implements the recommended suggestions by these two articles, which is the same as the automatic command line "quickfix." [1] https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-find-by.md [2] https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#using-waitfor-to-wait-for-elements-that-can-be-queried-with-find --- docs/react-testing-library/example-intro.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react-testing-library/example-intro.mdx b/docs/react-testing-library/example-intro.mdx index a6d429ab1..c28f68d27 100644 --- a/docs/react-testing-library/example-intro.mdx +++ b/docs/react-testing-library/example-intro.mdx @@ -93,7 +93,7 @@ test('loads and displays greeting', async () => { fireEvent.click(screen.getByText('Load Greeting')) - await waitFor(() => screen.getByRole('heading')) + await screen.findByRole('heading') expect(screen.getByRole('heading')).toHaveTextContent('hello there') expect(screen.getByRole('button')).toBeDisabled()