Open

Description
Name for new rule
prefer-userEvent-setup
Description of the new rule
Rule should recommend using the methods on the instances returned by userEvent.setup() from userEvent as inline or using setup functions.
Testing Library feature
Enforce using the methods on the instances returned by userEvent.setup()
Testing Library framework(s)
React
What category of rule is this?
Suggests an alternate way of doing something
Optional: other category of rule
No response
Code examples
// inlining
test('trigger some awesome feature when clicking the button', async () => {
const user = userEvent.setup()
render()
await user.click(screen.getByRole('button', {name: /click me!/i}))
// ...assertions...
})
// setup function
function setup(jsx) {
return {
user: userEvent.setup(),
...render(jsx),
}
}
test('render with a setup function', async () => {
const {user} = setup()
// ...
})
Anything else?
No response
Do you want to submit a pull request to make the new rule?
Yes, but need help