six-webcomponents
six-webcomponents copied to clipboard
Add data-testid attributes to internal elements to facilitate testing
What problem does this feature solve?
When one writes tests for a UI using the components, it sometimes requires to access the 'internals' of the component. An example is the DatePicker. You need to search into the shadowroot for an 'input' element to simulate the user clicking the picker. Or you need to search using the '.next' css class to get to the button to navigate to the next month. This makes the tests fragile wrt to changes in the component.
What does the proposed API look like?
I would suggest to add 'data-testid' attributes to internal elements that could be necessary for testing. These attributes should be documented.