Consistent data testid configuration #389
-
Hello everybody,
But I need a way to avoid developers to use as testIdAttribute other values like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @agugut ! Thanks for posting. I am not sure if I understood correctly your doubt. Is what you want to prevent them from adding new elements into the array of I think the scope of the rule is to ensure values used inside |
Beta Was this translation helpful? Give feedback.
-
I'm afraid this plugin can't force the property name used for test id attribute as you wish. The rule mentioned will take care of the property value so it follows desired pattern, but not its property name. I don't think it's even possible to disallow specific property names in favor of a The only way this could be implemented is by indicating a list of Not sure if the described behaviour is already available under some ESLint rule (maybe |
Beta Was this translation helpful? Give feedback.
I'm afraid this plugin can't force the property name used for test id attribute as you wish. The rule mentioned will take care of the property value so it follows desired pattern, but not its property name.
I don't think it's even possible to disallow specific property names in favor of a
data-testid
since anydata-*
could be used for literally anything, not just test id, so it wouldn't be possible to restrict such attributes.The only way this could be implemented is by indicating a list of
data-*
attributes to be reported (e.g.["data-test-name"]
) and suggest using desired property name instead. This wouldn't catch cases not included in that list tho.Not sure if the described behaviour…