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/partials/_views.mdx
+18-5
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
Cypress automatically groups certain URL patterns to create views. However, for URLs that are not automatically grouped (e.g., `/users/alice` and `/users/bob` are not automatically grouped into `/users/*`), the `views` property allows you to specify custom URL patterns to define views. This configuration enhances the clarity and organization of your coverage reports.
2
2
3
-
The `groupBy` property of a view definition allows you to create multiple views with a single URL pattern, grouping URLs by the specified named parameter(s).
3
+
The `groupBy` property allows you to create multiple views from a single URL pattern by specifying which parts of the URL should create distinct groupings.
4
4
5
5
## Why use views?
6
6
@@ -11,6 +11,19 @@ This cannot be nested.
11
11
12
12
-**Group Dynamic URLs**: Group URLs with dynamic path parameters (e.g., `/users/alice` and `/users/bob`) that are not ids or uuids into a single view.
13
13
-**Organize by Query Parameters**: Create views based on query parameters to group URLs where query strings are important to the context of the page.
14
+
-**Create Distinct View Groups**: Use `groupBy` to maintain separate views for meaningful URL parameters while still grouping dynamic content.
15
+
16
+
## Using groupBy
17
+
18
+
The `groupBy` property creates distinct views based on named parameters in your URL pattern. For example, if your pattern is `/analytics/:type/:id`, using `groupBy: ["type"]` would create separate views for each unique value of `type` (like `/analytics/performance/:id` and `/analytics/usage/:id`).
19
+
20
+
This is particularly useful when:
21
+
22
+
- Different parameter values represent distinct functional areas
23
+
- You want to track coverage separately for different categories of content
24
+
- URL parameters determine significant UI changes
25
+
26
+
URLs with the same values for the specified parameters will be grouped together, while different values create distinct views.
14
27
15
28
## Syntax
16
29
@@ -31,10 +44,10 @@ This cannot be nested.
31
44
32
45
The first pattern that a given URL matches is used as its view. If a URL doesn't match any of the patterns, it is grouped by the default view grouping rules, if possible.
|`pattern`| Required || A URL pattern to group matching URLs into a single view. Uses [URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) syntax. |
37
-
|`groupBy`| Optional || An array of named URL parameters used to further subdivide the URLs into multiple views within the same pattern. This is useful for dynamic applications where URLs represent different user interactions or data segments.|
|`pattern`| Required || A URL pattern to group matching URLs into a single view. Uses [URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API) syntax. |
50
+
|`groupBy`| Optional || An array of named parameters from your pattern that should create separate views. |
0 commit comments