Open
Description
Plugin version
v5.3.1
ESLint version
v8.14.0
Node.js version
v16.3.0
npm/yarn version
npm v8.9.0
Operating system
macOS v12.3.1
Bug description
The autofix of the rule prefer-find-by
doesn't work correctly when waitFor
options are provided, or there is an assertion involved.
Steps to reproduce
- Providing waitFor options (✅ fixed):
const button = await waitFor(() => screen.getByText('Count is: 0'), { timeout: 100, })
- There is an assertion involved
await waitFor(() => expect( screen.getByRole('button', { name: 'Count is: 0' }), ).toBeInTheDocument(), )
Error output/screenshots
These are fixed as:
- Providing waitFor options:
const button = await screen.findByText('Count is: 0')
- There is an assertion involved
await screen.findByRole('button', { name: 'Count is: 0' })
ESLint configuration
N/A
Rule(s) affected
prefer-find-by
Anything else?
They should be fixed as:
- Providing waitFor options:
const button = await screen.findByText('Count is: 0', { timeout: 100 })
- There is an assertion involved
expect( await screen.findByRole('button', { name: 'Count is: 0' }), ).toBeInTheDocument(),
Do you want to submit a pull request to fix this bug?
Yes