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/react-testing-library/setup.md
+58-13Lines changed: 58 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -147,31 +147,76 @@ module.exports = {
147
147
<details>
148
148
<summary>Customize queries globally with custom render</summary>
149
149
150
-
You can override and append queries via the render function by passing a [`queries`](api.md#render-options) option.
150
+
In the example below, a new set of query variants are created for getting
151
+
elements by `data-cy`, an attribute used and recommended by [Cypress.io](https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements).
151
152
152
-
You can define your own custom queries as described in the example in the [Helpers API](api-helpers.md) documentation.
153
+
It is worth noting that generally you should not need to use this feature of
154
+
react-testing-library and, where you do use it, you should really consider whether
155
+
your new queries encourage you to test in a user-centric way, without testing
156
+
implementation detail.
153
157
154
-
If you want to add custom queries globally, you can do this by defining a custom render method:
158
+
`data-testid` is supported by Cypress.io, so even in this case, you would not technically
159
+
need to create a new set of queries and you could just replace `data-cy` with
160
+
`data-testid` attributes throughout your project.
161
+
162
+
You can define your own custom queries as described in the example in the
163
+
[Helpers API](/doc/dom-testing-library/api-helpers.md) documentation, or via the
0 commit comments