-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Open
Feature
Copy link
Labels
help wantedExtra attention is neededExtra attention is needednew ruleNew rule to be included in the pluginNew rule to be included in the plugin
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
Leland, erquhart, chmmpagne, mstefaniak, neriyarden and 2 more
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needednew ruleNew rule to be included in the pluginNew rule to be included in the plugin