Closed
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v6.0.2
ESLint version
v8.50.0
Node.js version
18.18.0
package manager and version
npm 9.8.1
Operating system
macOS Ventura 13.5.2 (22G91)
Bug description
The rule await-async-events
with Promise returned from
setUpUserEvents wrapper over async event method must be handled
when I call userEvent.setup()
from setUpUserEvents
.
Example:
import userEvent, { type UserEvent } from '@testing-library/user-event';
const setUpUserEvents = (): UserEvent =>
userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
test('Something', async () => {
const { click } = setUpUserEvents();
/* ... */
await click(someElement);
});
Steps to reproduce
- Create a test that uses
userEvent.setup()
- Run lint w/
await-async-events
(all ok) - Refactor the call to
userEvent.setup()
into another function - Run lint w/
await-async-events
(eslint fails)
Error output/screenshots
After the refactor (eslint error):

Eslint error:
error Promise returned from `setUpUserEvents` wrapper over async event method must be handled testing-library/await-async-events
ESLint configuration
I'm extending AirBnb rules with:
{
files: ['**/*.test.ts?(x)'],
env: {
jest: true,
},
extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'],
},
Rule(s) affected
testing-library/await-async-events
Anything else?
The PR #817 is checking for the name setup
.
Maybe that isn't enough.
Do you want to submit a pull request to fix this bug?
No