You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/accessibility/configuration/significantattributes.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,6 @@ sidebar_position: 40
9
9
10
10
# significantAttributes
11
11
12
+
The `significantAttributes` property allows you to specify which attributes should be considered significant when identifying elements in Cypress Accessibility.
The `significantAttributes` property allows you to specify which attributes should be considered significant for UI Coverage analysis.
2
-
3
1
## Why use significant attributes?
4
2
5
-
-**Focus on Important Changes**: Track attributes that are most relevant to user interaction and functionality
6
-
-**Reduce False Positives**: Avoid flagging changes in non-essential attributes as coverage issues
7
-
-**Improve Report Clarity**: Make coverage reports more meaningful by focusing on attributes that matter
3
+
Cypress uses a [default set of attributes](/accessibility/core-concepts/element-identification) (such as common test ID patterns), in a priority order, as the preferred way to identify elements in reports.
4
+
5
+
The values of these attributes are used as element identifiers, which helps us recognize the same element in multiple contexts and deduplicate the findings. This helps when reviewing run reports, or comparing reports in Branch Review.
6
+
7
+
You may have attributes already in place in your application that would help with element organization, such as `data-component-name`. If you would like Cypress to use and prioritize these attributes, or you want to change the default priority order, you can define your own list of significant attributes.
8
8
9
9
## Scope
10
10
@@ -16,48 +16,33 @@ supported, if you need to split them up.
16
16
17
17
## Syntax
18
18
19
+
`significantAttributes` is an array of strings, with each string being the name of a HTML attribute.
20
+
19
21
```json
20
22
{
21
23
"significantAttributes": [
22
-
{
23
-
"selector": string,
24
-
"attributes": string[]
25
-
}
24
+
string
26
25
]
27
26
}
28
27
```
29
28
30
-
### Options
31
-
32
-
The first `significantAttributes` rule for which the selector property matches the element is used to determine which attributes should be considered significant. Attributes that do not match any rules are not considered significant by default.
|`selector`| Required || A CSS selector to identify elements. Supports standard CSS selector syntax, including IDs, classes, attributes, and combinators. |
37
-
|`attributes`| Required || An array of attribute names that should be considered significant for coverage analysis. |
38
-
39
29
## Examples
40
30
41
-
### Marking specific attributes as significant for all elements
Copy file name to clipboardExpand all lines: docs/ui-coverage/core-concepts/interactivity.mdx
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
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, [
19
19
20
20
These elements are tracked for interaction to provide actionable insights into test coverage.
21
21
22
+
### Customizing interactive elements
23
+
24
+
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:
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.
31
+
22
32
## Interaction Commands
23
33
24
34
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
39
49
-`type`
40
50
-`uncheck`
41
51
42
-
By ensuring these commands interact with the appropriate elements, UI Coverage accurately reflects your test coverage.
52
+
By ensuring that at least one of these commands is used on every interactive element, UI Coverage accurately reflects your test coverage.
53
+
54
+
### Customizing interaction commands
55
+
56
+
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.
57
+
58
+
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.
0 commit comments