Closed
Description
Plugin version
4.12.4
ESLint version
7.24.0
Node.js version
14.16.0
npm/yarn version
6.14.11
Operating system
macOS Big Sur
Bug description
I expect this code snippet NOT to be reported. Furthermore, error message and auto-fix have undefined
instead of a meaningful message/fix.
it('renders', async () => {
const { container } = render(<App />)
await waitFor(() =>
expect(container.querySelector("[data-icon-name='bookmark-filled']")).toBeInTheDocument(), // reported
)
})
Auto-fixed to: await container.findByundefined("[data-icon-name='bookmark-filled']")
Steps to reproduce
- Setup
eslint-plugin-testing-library
4.12.4 - Enable
prefer-find-by
rule - Create a test with the above code snippet
- Run eslint with
--fix
Error output/screenshots
error Prefer `findByundefined` query over using `waitFor` + `querySelector` testing-library/prefer-find-by
ESLint configuration
{
files: ['*.test.ts', '*.test.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['testing-library'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'testing-library/prefer-find-by': 'error',
},
},
Rule(s) affected
prefer-find-by
Anything else?
No response
Do you want to submit a pull request to fix this bug?
No