We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
await-async-events
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yes
v6.2.0
v8.56.0
v20.10.0
pnpm 7.33.7
macOS Sonoma, version 14.3.1
The userEvent.setup() method is treated as if it were returning a Promise when wrapped by an arrow function expression.
userEvent.setup()
Promise
While exposing a getUser wrapper around userEvent.setup for reuse:
getUser
userEvent.setup
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.
No response
{ "extends": ["plugin:testing-library/react"] }
or
{ "plugins": ["testing-library"], "rules": { "testing-library/await-async-events": "error" } }
testing-library/await-async-events
No
The text was updated successfully, but these errors were encountered:
Just in case it helps.
If I change getUser to
export const getUser = () => { const user = userEvent.setup({ advanceTimers: (msToRun: number) => jest.advanceTimersByTime(msToRun), }); return user; }
...then the false-positive error is gone.
Sorry, something went wrong.
Thanks for reporting @kripod
🎉 This issue has been resolved in version 6.2.2 🎉
The release is available on:
Your semantic-release bot 📦🚀
Successfully merging a pull request may close this issue.
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 aPromise
when wrapped by an arrow function expression.Steps to reproduce
While exposing a
getUser
wrapper arounduserEvent.setup
for reuse:Usages like:
Produce a false-positive error as follows:
However,
userEvent.setup
isn‘t an async method, so there isn‘t anything to await.Error output/screenshots
No response
ESLint configuration
or
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
The text was updated successfully, but these errors were encountered: