You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for your suggestion @pc-snatesan! It looks like a nice suggestion for the latest user-event version (we would have to mention that in the docs). A few clarifications:
The rule name shouldn't contain uppercase, so it should be prefer-user-event-setup
user-event actually applies to all frameworks supported by this plugin, not just the react one!
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
The text was updated successfully, but these errors were encountered: