Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

testing-library/await-async-queries false positives with optional chaining ?. #882

Copy link
Copy link
Closed
@tronguye

Description

@tronguye
Issue body actions

Have you read the Troubleshooting section?

Yes

Plugin version

6.2.0

ESLint version

8.45.0

Node.js version

18.16.0

package manager and version

yarn 1.22.19

Operating system

Windows 10 Enterprise version 22H2

Bug description

await renderResult?.findBy* is reporting testing-library/await-async-queries, even though the query is in fact getting awaited

Steps to reproduce

  1. Go to a test file
  2. Add code like
it('...', async () => {
  let renderResult: RenderResult | undefined;
  renderResult = render(<div>text</div>);
   
  expect(await renderResult?.findByText('text')).toBeDefined();
));
  1. Observe error reported on line with expect, when we are in fact awaiting the returned promise of findByText

Error output/screenshots

No response

ESLint configuration

{
  ...,
  plugins: [
     ...,
     'eslint-plugin-testing-library'
  ],
  rules: {
    ...,
    'testing-library/await-async-queries': 'error'
  }
}

Rule(s) affected

testing-library/await-async-queries

Anything else?

No response

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

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.