six-webcomponents icon indicating copy to clipboard operation
six-webcomponents copied to clipboard

Add data-testid attributes to internal elements to facilitate testing

Open franckdervaux opened this issue 1 year ago • 0 comments

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.

franckdervaux avatar Feb 01 '24 10:02 franckdervaux