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
docs: adjust ByTestId misleading warnings; add guidelines about accessibilityHint (#542)
* docs: remove byTestId misleading warnings
* change caution to warning, mention principles and accessibility guideline
* promote new aliases in docs example
* rephrase
Copy file name to clipboardExpand all lines: website/docs/MigrationV2.md
-4Lines changed: 0 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -113,10 +113,6 @@ In v2 we fixed this inconsistency, which may result in failing tests, if you rel
113
113
- replace `testID` with proper `accessibilityHint` or `accessibilityLabel` if it benefits the user
114
114
- use safe queries like `*ByText` or `*ByA11yHint`
115
115
116
-
:::caution
117
-
In general, you should avoid `*byTestId` queries when possible. Use queries that check things that the user can interact with. Like `*ByText` or `*ByPlaceholderText` or accessibility queries (e.g. `*ByA11yHint`, `*ByA11yLabel`).
118
-
:::
119
-
120
116
## Deprecated `flushMicrotasksQueue`
121
117
122
118
We have deprecated `flushMicrotasksQueue` and plan to remove it in the next major. We have better alternatives available for helping you write async tests – `findBy` async queries and `waitFor` helper.
Please be mindful when using these API and **treat it as an escape hatch**. Your users can't interact with `testID`anyhow, so you may end up writing tests that provide false sense of security. Favor text and accessibility queries instead.
110
+
:::info
111
+
In the spirit of [the guiding principles](https://testing-library.com/docs/guiding-principles), it is recommended to use this only after the other queries don't work for your use case. Using `testID`attributes do not resemble how your software is used and should be avoided if possible. However, they are particularly useful for end-to-end testing on real devices, e.g. using Detox and it's an encouraged technique to use there. Learn more from the blog post ["Making your UI tests resilient to change"](https://kentcdodds.com/blog/making-your-ui-tests-resilient-to-change).
Please consult [Apple guidelines on how `accessibilityHint` should be used](https://developer.apple.com/documentation/objectivec/nsobject/1615093-accessibilityhint).
0 commit comments