|
| 1 | +The `profiles` property allows you to create configuration overrides that are applied based on run tags. This enables you to use different configuration settings for different types of runs, such as regression tests compared to smoke tests environments, or providing scoped results relevant to specific teams. |
| 2 | + |
| 3 | +## Why use profiles? |
| 4 | + |
| 5 | +- **Team specific reporting**: If multiple teams use the same Cypress Cloud project, they may have completely different areas of concern for which pages or DOM elements are included in reports about accessibility or UI Coverage. Profiles allow each team to see and track against only the results that matter to them, and remove all other findings. |
| 6 | +- **Run-type customization**: Use different filters or settings for regression runs versus pull requests. It can be useful to have a narrow config for blocking a merge, optimized for the most critical areas of your app -- while still running a wide config on a full regression suite to manage on a difference cadence. |
| 7 | +- **Skip runs when needed**: If you know that certain kinds of runs are not going to be valuable for App Quality reporting, you can ignore all view on these runs so that no report is created. In some situations this can improve clarity about when to look at a report and which reports are considered significant. |
| 8 | + |
| 9 | +## How profiles work |
| 10 | + |
| 11 | +Profiles are selected by matching run tags to profile names. When you run Cypress with the [`--tag`](/app/references/command-line#cypress-run-tag-lt-tag-gt) flag, Cypress Cloud looks for a profile whose `name` matches one of the tags. If a match is found, properties defined in profile's `config` properties override the root configuration. Properties defined in the root that are not referenced in the profile will be inherited, meaning you do not need to repeat config values that you want to keep the same. |
| 12 | + |
| 13 | +If more than one tag provided to a run matches a profile in your App Quality profiles array, the first matching profile in the array will be used. The order in which the tags are passed to the run doesn't matter. |
| 14 | + |
| 15 | +## Best practices |
| 16 | + |
| 17 | +Use a naming convention like `aq-config-x` (e.g., `aq-config-regression`, `aq-config-staging`) to make it clear that a tag is used for configuration lookup purposes. |
| 18 | + |
| 19 | +While relying on existing tags works just fine, but being explicit will help avoid accidental removal or changes of important tags. |
| 20 | + |
| 21 | +## Syntax |
| 22 | + |
| 23 | +```json |
| 24 | +{ |
| 25 | + "profiles": [ |
| 26 | + { |
| 27 | + "name": string, |
| 28 | + "config": { |
| 29 | + // Any App Quality configuration options |
| 30 | + }, |
| 31 | + "comment": string |
| 32 | + } |
| 33 | + ] |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +### Options |
| 38 | + |
| 39 | +| Option | Required | Description | |
| 40 | +| --------- | -------- | --------------------------------------------------------------------------------------------------------- | |
| 41 | +| `name` | Required | The profile name that must match a run tag to activate this profile. | |
| 42 | +| `config` | Required | An object containing any App Quality configuration options. These values override the root configuration. | |
| 43 | +| `comment` | Optional | A comment describing the purpose of this profile. | |
| 44 | + |
| 45 | +## Examples |
| 46 | + |
| 47 | +### Basic profile structure |
| 48 | + |
| 49 | +#### Config |
| 50 | + |
| 51 | +```json |
| 52 | +{ |
| 53 | + "elementFilters": [ |
| 54 | + { |
| 55 | + "selector": "[data-testid*='temp']", |
| 56 | + "include": false, |
| 57 | + "comment": "Exclude temporary test elements" |
| 58 | + } |
| 59 | + ], |
| 60 | + "profiles": [ |
| 61 | + { |
| 62 | + "name": "aq-config-regression", |
| 63 | + "config": { |
| 64 | + "elementFilters": [ |
| 65 | + { |
| 66 | + "selector": "[data-testid*='temp']", |
| 67 | + "include": false, |
| 68 | + "comment": "Exclude temporary test elements in regression runs" |
| 69 | + }, |
| 70 | + { |
| 71 | + "selector": "[data-role='debug']", |
| 72 | + "include": false, |
| 73 | + "comment": "Exclude debug elements in regression runs" |
| 74 | + } |
| 75 | + ] |
| 76 | + } |
| 77 | + } |
| 78 | + ] |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +#### Usage |
| 83 | + |
| 84 | +To use this profile, run Cypress with a matching tag: |
| 85 | + |
| 86 | +```shell |
| 87 | +cypress run --record --tag "aq-config-regression" |
| 88 | +``` |
| 89 | + |
| 90 | +When this tag is used, the profile's `elementFilters` configuration will override the base `elementFilters`, excluding both temporary test elements and debug elements. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### Multiple profiles |
| 95 | + |
| 96 | +You can define multiple profiles for different scenarios: |
| 97 | + |
| 98 | +#### Config |
| 99 | + |
| 100 | +```json |
| 101 | +{ |
| 102 | + "elementFilters": [ |
| 103 | + { |
| 104 | + "selector": "[data-testid*='temp']", |
| 105 | + "include": false |
| 106 | + } |
| 107 | + ], |
| 108 | + "profiles": [ |
| 109 | + { |
| 110 | + "name": "aq-config-regression", |
| 111 | + "config": { |
| 112 | + "elementFilters": [ |
| 113 | + { |
| 114 | + "selector": "[data-testid*='temp']", |
| 115 | + "include": false |
| 116 | + }, |
| 117 | + { |
| 118 | + "selector": "[data-role='debug']", |
| 119 | + "include": false, |
| 120 | + "comment": "Exclude debug elements in regression runs" |
| 121 | + } |
| 122 | + ] |
| 123 | + } |
| 124 | + }, |
| 125 | + { |
| 126 | + "name": "aq-config-staging", |
| 127 | + "config": { |
| 128 | + "viewFilters": [ |
| 129 | + { |
| 130 | + "pattern": "https://staging.example.com/admin/*", |
| 131 | + "include": false, |
| 132 | + "comment": "Exclude admin pages in staging runs" |
| 133 | + } |
| 134 | + ] |
| 135 | + } |
| 136 | + } |
| 137 | + ] |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +#### Usage |
| 142 | + |
| 143 | +Use different tags to activate different profiles: |
| 144 | + |
| 145 | +```shell |
| 146 | +# For regression runs |
| 147 | +cypress run --record --tag "aq-config-regression" |
| 148 | + |
| 149 | +# For staging runs |
| 150 | +cypress run --record --tag "aq-config-staging" |
| 151 | +``` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +### Profile with nested configuration |
| 156 | + |
| 157 | +Profiles can override configuration at any level, including nested configuration specific to Cypress Accessibility or UI Coverage, if your project has both projects enabled. For example: |
| 158 | + |
| 159 | +#### Config |
| 160 | + |
| 161 | +```json |
| 162 | +{ |
| 163 | + "elementFilters": [ |
| 164 | + { |
| 165 | + "selector": "[data-testid*='temp']", |
| 166 | + "include": false |
| 167 | + } |
| 168 | + ], |
| 169 | + "uiCoverage": { |
| 170 | + "attributeFilters": [ |
| 171 | + { |
| 172 | + "attribute": "id", |
| 173 | + "value": ":r.*:", |
| 174 | + "include": false, |
| 175 | + "comment": "Filter out React auto-generated IDs" |
| 176 | + } |
| 177 | + ] |
| 178 | + }, |
| 179 | + "profiles": [ |
| 180 | + { |
| 181 | + "name": "aq-config-feature-branch", |
| 182 | + "config": { |
| 183 | + "uiCoverage": { |
| 184 | + "elementGroups": [ |
| 185 | + { |
| 186 | + "selector": "[data-feature='new-checkout']", |
| 187 | + "name": "New Checkout Flow", |
| 188 | + "comment": "Group new checkout elements for feature branch testing" |
| 189 | + } |
| 190 | + ] |
| 191 | + } |
| 192 | + } |
| 193 | + } |
| 194 | + ] |
| 195 | +} |
| 196 | +``` |
| 197 | + |
| 198 | +#### Usage |
| 199 | + |
| 200 | +```shell |
| 201 | +cypress run --record --tag "aq-config-feature-branch" |
| 202 | +``` |
| 203 | + |
| 204 | +This profile adds element grouping for the new checkout flow while keeping the base configuration for element filters and attribute filters. |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +### Profile selection with multiple matching tags |
| 209 | + |
| 210 | +If you pass multiple tags and more than one matches a profile name, the first matching profile in the `profiles` array is used: |
| 211 | + |
| 212 | +#### Config |
| 213 | + |
| 214 | +```json |
| 215 | +{ |
| 216 | + "profiles": [ |
| 217 | + { |
| 218 | + "name": "aq-config-regression", |
| 219 | + "config": { |
| 220 | + "elementFilters": [ |
| 221 | + { |
| 222 | + "selector": "[data-role='debug']", |
| 223 | + "include": false |
| 224 | + } |
| 225 | + ] |
| 226 | + } |
| 227 | + }, |
| 228 | + { |
| 229 | + "name": "aq-config-staging", |
| 230 | + "config": { |
| 231 | + "viewFilters": [ |
| 232 | + { |
| 233 | + "pattern": "https://staging.example.com/admin/*", |
| 234 | + "include": false |
| 235 | + } |
| 236 | + ] |
| 237 | + } |
| 238 | + } |
| 239 | + ] |
| 240 | +} |
| 241 | +``` |
| 242 | + |
| 243 | +#### Usage |
| 244 | + |
| 245 | +```shell |
| 246 | +cypress run --record --tag "aq-config-regression,aq-config-staging" |
| 247 | +``` |
| 248 | + |
| 249 | +In this case, the `aq-config-regression` profile will be used because it appears first in the `profiles` array, even though both tags match profile names. |
0 commit comments