-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
β enhancementNew feature or requestNew feature or requestπ eslint-pluginIssue concerning the eslint pluginIssue concerning the eslint plugin
Description
Why?
This rules helps ensure that we use getBy matchers when we want to assert element exists, are check, are accessible etc and queryBy only when elements don't exist. This is our standard for clear code and easy debugging in tests.
Issues so far:
- it does not seem to work with findBy for now
- nor does it wok with "not" assertions (I'd like to use queryBy only for "not.toBeOnTheScreen"
Rule Documentation π
Config Selection π
tests
(Optional) Additional Details π
Here is a possible configuration for this rule
'testing-library/prefer-query-matchers': [
2,
{
validEntries: [
{ matcher: 'toBeChecked', query: 'get' },
{ matcher: 'toHaveAccessibleName', query: 'get' },
{ matcher: 'toBeBusy', query: 'get' },
{ matcher: 'toBeSelected', query: 'get' },
{ matcher: 'toBeExpanded', query: 'get' },
{ matcher: 'toBePartiallyChecked', query: 'get' },
{ matcher: 'toHaveDisplayValue', query: 'get' },
{ matcher: 'toHaveTextContent', query: 'get' },
{ matcher: 'toHaveStyle', query: 'get' },
{ matcher: 'toHaveProp', query: 'get' },
{ matcher: 'toContainElement', query: 'get' },
{ matcher: 'toBeEnabled', query: 'get' },
{ matcher: 'toBeDisabled', query: 'get' },
{ matcher: 'toBeEmptyElement', query: 'get' },
],
},
],Metadata
Metadata
Assignees
Labels
β enhancementNew feature or requestNew feature or requestπ eslint-pluginIssue concerning the eslint pluginIssue concerning the eslint plugin