Skip to content

await-async-events produces false-positives #881

Closed
@kripod

Description

@kripod

Have you read the Troubleshooting section?

Yes

Plugin version

v6.2.0

ESLint version

v8.56.0

Node.js version

v20.10.0

package manager and version

pnpm 7.33.7

Operating system

macOS Sonoma, version 14.3.1

Bug description

The userEvent.setup() method is treated as if it were returning a Promise when wrapped by an arrow function expression.

Steps to reproduce

While exposing a getUser wrapper around userEvent.setup for reuse:

export const getUser = () =>
  userEvent.setup({
    advanceTimers: (msToRun: number) => jest.advanceTimersByTime(msToRun),
  });

Usages like:

const user = getUser();

Produce a false-positive error as follows:

error  Promise returned from `getUser` wrapper over async event method must be handled  testing-library/await-async-events

However, userEvent.setup isn‘t an async method, so there isn‘t anything to await.

Error output/screenshots

No response

ESLint configuration

{
  "extends": ["plugin:testing-library/react"]
}

or

{
  "plugins": ["testing-library"],
  "rules": {
    "testing-library/await-async-events": "error"
  }
}

Rule(s) affected

testing-library/await-async-events

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 workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions