Ensures that HTML elements or React components have testId attribute if there are event handlers.
Examples of incorrect code for this rule:
<div onClick={() => {}}>Hello</div>
<MyComponent onClick={() => {}} />
Examples of correct code for this rule:
<div onClick={() => {}} data-test-id="someTestId">Hello</div>
<MyComponent onClick={() => {}} data-test-id="someTestId">Hello</MyComponent>
...
"jsx-enforce-test-id": [<enabled>, {
"testIdAtribute": <testIdAtribute>,
}]
...
testIdAtribute
: Attribute for finding a node with testId. Defaults todata-test-id
If you are not using JSX, or if you don't want to enforce specific naming conventions for event handlers.