testing-library/eslint-plugin-testing-library

Invalid autofix from `prefer-find-by`

tylerlaprade opened this issue · 1 comments

Have you read the Troubleshooting section?

Yes

Plugin version

5.10.2

ESLint version

8.33.0

Node.js version

18.14.0

package manager and version

npm 8.15.0

Operating system

macOS Ventura 13.0.1

Bug description

The rule flagged and "fixed" a line containing both await waitFor and getByText, but there were other functions in between. The autofix removed those other functions, breaking my code.

Steps to reproduce

  1. await waitFor(() => expect(screen.getByText('foo')).toBeInTheDocument());
  2. ESLint auto-fix
  3. await screen.findByText('foo');

Error output/screenshots

No response

ESLint configuration

"extends": ["plugin:testing-library/react"]

Rule(s) affected

prefer-find-by

Anything else?

No response

Do you want to submit a pull request to fix this bug?

No

Duplicated of #579