-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update UI Coverage documenation #6236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a0ecae3
48dfa1f
627f9ca
0cabb78
427c156
3ec23b6
8fe848c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,16 @@ UI Coverage determines interactivity based on a combination of HTML semantics, [ | |
|
||
These elements are tracked for interaction to provide actionable insights into test coverage. | ||
|
||
### Customizing interactive elements | ||
|
||
Custom interactive elements that do not meet the criteria above can also be declared with a `data-cy-ui-interactive="include"` attribute, used as follows: | ||
|
||
```html | ||
<div data-cy-ui-interactive="include">Custom interactive widget</div> | ||
``` | ||
|
||
It most cases we recommend **not** using this override, and instead updating the HTML to be something the browser would already consider to be interactive. This will likely produce better overall behavior, including for accessibility purposes. `data-cy-ui-interactive` is a fallback for situations where that may not be possible. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I would word this a bit more strongly - something like "use of this attribute is a strong signal there is an issue with the HTML structure of your application which likely has real-world impacts for users, particularly those using screen readers or with disabilities. If possible we recommend updating your HTML to better convey the interactive nature of this element; this would improve the functionality of your application for these users as well as automatically detect the element in the report. As a fallback for scenarios where this isn't possible......." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not so sure about this. Since we can now support requiring custom commands and the "assert" command - you might have a totally valid reason to want to change the definition of what we consider interactive without it implying the elements themselves are broken. Still might need another pass at this though - the framing of everything in terms of "interactions" might not be the most accurate, long term. Will think on it a bit. |
||
|
||
## Interaction Commands | ||
|
||
Interactive elements are marked as "tested" when they are interacted with using specific Cypress commands. These include: | ||
|
@@ -39,7 +49,13 @@ Interactive elements are marked as "tested" when they are interacted with using | |
- `type` | ||
- `uncheck` | ||
|
||
By ensuring these commands interact with the appropriate elements, UI Coverage accurately reflects your test coverage. | ||
By ensuring that at least one of these commands is used on every interactive element, UI Coverage accurately reflects your test coverage. | ||
|
||
### Customizing interaction commands | ||
|
||
Configuration is available to support adding [additional interaction commands](/ui-coverage/configuration/additionalinteractioncommands), such as custom commands or ones from third-party libraries, to count towards UI Coverage scores. | ||
|
||
It is also possible to adjust the [allowed commands](/ui-coverage/configuration/allowedinteractioncommands) for specific elements, to restrict or expand the commands that are accepted as coverage for specific elements. | ||
|
||
## Untested Links | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC this doesn't support wildcarding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not totally sure if this API exactly matches what unique-selector accepts, but if it does, it would be something like
['attribute:aria-label', 'attribute:role', 'id', 'class']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennifer-shehane That's abstracted away by UICov logic here https://github.com/cypress-io/cypress-services/blob/develop/discovery/packages/common/src/elementProcessingUtils.ts#L72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I didn't verify on the wildcarding, I'll remove this from the PR