prefer-find-by autofix doesn't respect extra code
See original GitHub issuePlugin 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:
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
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
React typescript: eslint max-length autofix does not work
But seems like my eslint max-lenght auto-fix does not work. I just go warn and when i click the quick its just disable...
Read more >could not determine executable to run git commit - You.com
Assuming that the remote repository has a copy of the develop branch (your initial description describes it in a local repository, but it...
Read more >Release Notes - Documentation ・ CoreMedia
If you use these libraries in project code, please check their respective release notes ... doesn't require any additional Studio development anymore.
Read more >Draft: [RUN ALL RSPEC] Draft: CI decomposition PoC - GitLab
Have a well-written commit message. · Has all tests passing when used on its own (e.g. when using git checkout SHA). · Can...
Read more >Fishing Buddy : TradeSkill Mods : World of Warcraft AddOns
preferred equipment manager. alt-clicking on an item in your outfit display will clear it ... If your unzip program doesn't let you specify...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s right, but this is referring to
findBy*
queries, which is a wrapper overwaitFor
util +getBy*
queries. This is mentioned in the official docs (I should have linked this in the ticket description, my bad):So based on this, we should keep the options found in the
waitFor
util, and pass them as the last argument tofindBy*
queries. You can reproduce this with the examples I left in the description: the options disappear.Reopening since only the first half is done (GitHub automation closed it, my bad).