Skip to content

Bug: prefer-query-by-disappearance reports error in an incorrect part of the code #600

Closed
@Belco90

Description

@Belco90

Have you read the Troubleshooting section?

Yes

Plugin version

v5.5.0

ESLint version

v8.14.0

Node.js version

v16.15.0

package manager and version

npm v8.9.0

Operating system

macOS v12.3.1

Bug description

When there is an error reported by prefer-query-by-disappearance, it's displayed at the very beginning of the callback passed to waitForElementToBeRemoved. Instead, the error should be placed in the query within the callback.

Steps to reproduce

it('should do something', async () => {
  render(<App />)

  fireEvent.click(screen.getByRole('button'))

  await waitForElementToBeRemoved(() => screen.getByText('Loading'))
})

Error output/screenshots

CleanShot 2022-06-03 at 01 23 52

ESLint configuration

N/A

Rule(s) affected

prefer-query-by-disappearance

Anything else?

No response

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

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions